@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,134 +1,94 @@
1
- /**
2
- * @typedef {object} ButtonMenuConfig
3
- * @property {string} [buttonText=Actions] - Label for the toggle button
4
- * @property {"left" | "right"} [alignMenu=left] - the alignment of the menu
5
- * @property {string} [buttonClasses=govuk-button--secondary] - css classes applied to the toggle button
6
- */
1
+ import { ConfigurableComponent } from 'govuk-frontend';
7
2
 
8
3
  /**
9
- * @param {HTMLElement} $module
10
- * @param {ButtonMenuConfig} config
11
- * @class
4
+ * @augments {ConfigurableComponent<ButtonMenuConfig>}
12
5
  */
13
- function ButtonMenu($module, config = {}) {
14
- if (!$module) {
15
- return this
16
- }
17
-
18
- const schema = Object.freeze({
19
- properties: {
20
- buttonText: { type: 'string' },
21
- buttonClasses: { type: 'string' },
22
- alignMenu: { type: 'string' }
23
- }
24
- });
25
-
26
- const defaults = {
27
- buttonText: 'Actions',
28
- alignMenu: 'left',
29
- buttonClasses: ''
30
- };
31
- // data attributes override JS config, which overrides defaults
32
- this.config = this.mergeConfigs(
33
- defaults,
34
- config,
35
- this.parseDataset(schema, $module.dataset)
36
- );
37
-
38
- this.$module = $module;
39
- }
40
-
41
- ButtonMenu.prototype.init = function () {
42
- // If only one button is provided, don't initiate a menu and toggle button
43
- // if classes have been provided for the toggleButton, apply them to the single item
44
- if (this.$module.children.length === 1) {
45
- const button = this.$module.children[0];
46
- button.classList.forEach((className) => {
47
- if (className.startsWith('govuk-button-')) {
48
- button.classList.remove(className);
6
+ class ButtonMenu extends ConfigurableComponent {
7
+ /**
8
+ * @param {Element | null} $root - HTML element to use for button menu
9
+ * @param {ButtonMenuConfig} [config] - Button menu config
10
+ */
11
+ constructor($root, config = {}) {
12
+ super($root, config);
13
+
14
+ // If only one button is provided, don't initiate a menu and toggle button
15
+ // if classes have been provided for the toggleButton, apply them to the single item
16
+ if (this.$root.children.length === 1) {
17
+ const $button = this.$root.children[0];
18
+ $button.classList.forEach(className => {
19
+ if (className.startsWith('govuk-button-')) {
20
+ $button.classList.remove(className);
21
+ }
22
+ $button.classList.remove('moj-button-menu__item');
23
+ $button.classList.add('moj-button-menu__single-button');
24
+ });
25
+ if (this.config.buttonClasses) {
26
+ $button.classList.add(...this.config.buttonClasses.split(' '));
49
27
  }
50
- button.classList.remove('moj-button-menu__item');
51
- });
52
- if (this.config.buttonClasses) {
53
- button.classList.add(...this.config.buttonClasses.split(' '));
54
28
  }
55
- }
56
- // Otherwise intialise a button menu
57
- if (this.$module.children.length > 1) {
58
- this.initMenu();
59
- }
60
- };
61
-
62
- ButtonMenu.prototype.initMenu = function () {
63
- this.$menu = this.createMenu();
64
- this.$module.insertAdjacentHTML('afterbegin', this.toggleTemplate());
65
- this.setupMenuItems();
66
-
67
- this.$menuToggle = this.$module.querySelector(':scope > button');
68
- this.items = this.$menu.querySelectorAll('a, button');
69
-
70
- this.$menuToggle.addEventListener('click', (event) => {
71
- this.toggleMenu(event);
72
- });
73
-
74
- this.$module.addEventListener('keydown', (event) => {
75
- this.handleKeyDown(event);
76
- });
77
-
78
- document.addEventListener('click', (event) => {
79
- if (!this.$module.contains(event.target)) {
80
- this.closeMenu(false);
29
+ // Otherwise initialise a button menu
30
+ if (this.$root.children.length > 1) {
31
+ this.initMenu();
81
32
  }
82
- });
83
- };
84
-
85
- ButtonMenu.prototype.createMenu = function () {
86
- const $menu = document.createElement('ul');
87
- $menu.setAttribute('role', 'list');
88
- $menu.hidden = true;
89
- $menu.classList.add('moj-button-menu__wrapper');
90
- if (this.config.alignMenu === 'right') {
91
- $menu.classList.add('moj-button-menu__wrapper--right');
92
33
  }
93
-
94
- this.$module.appendChild($menu);
95
- while (this.$module.firstChild !== $menu) {
96
- $menu.appendChild(this.$module.firstChild);
34
+ initMenu() {
35
+ this.$menu = this.createMenu();
36
+ this.$root.insertAdjacentHTML('afterbegin', this.toggleTemplate());
37
+ this.setupMenuItems();
38
+ this.$menuToggle = this.$root.querySelector(':scope > button');
39
+ this.$items = this.$menu.querySelectorAll('a, button');
40
+ this.$menuToggle.addEventListener('click', event => {
41
+ this.toggleMenu(event);
42
+ });
43
+ this.$root.addEventListener('keydown', event => {
44
+ this.handleKeyDown(event);
45
+ });
46
+ document.addEventListener('click', event => {
47
+ if (event.target instanceof Node && !this.$root.contains(event.target)) {
48
+ this.closeMenu(false);
49
+ }
50
+ });
97
51
  }
98
-
99
- return $menu
100
- };
101
-
102
- ButtonMenu.prototype.setupMenuItems = function () {
103
- Array.from(this.$menu.children).forEach((item) => {
104
- // wrap item in li tag
105
- const listItem = document.createElement('li');
106
- this.$menu.insertBefore(listItem, item);
107
- listItem.appendChild(item);
108
-
109
- item.setAttribute('tabindex', -1);
110
-
111
- if (item.tagName === 'BUTTON') {
112
- item.setAttribute('type', 'button');
52
+ createMenu() {
53
+ const $menu = document.createElement('ul');
54
+ $menu.setAttribute('role', 'list');
55
+ $menu.hidden = true;
56
+ $menu.classList.add('moj-button-menu__wrapper');
57
+ if (this.config.alignMenu === 'right') {
58
+ $menu.classList.add('moj-button-menu__wrapper--right');
113
59
  }
114
-
115
- item.classList.forEach((className) => {
116
- if (className.startsWith('govuk-button')) {
117
- item.classList.remove(className);
60
+ this.$root.appendChild($menu);
61
+ while (this.$root.firstChild !== $menu) {
62
+ $menu.appendChild(this.$root.firstChild);
63
+ }
64
+ return $menu;
65
+ }
66
+ setupMenuItems() {
67
+ Array.from(this.$menu.children).forEach($menuItem => {
68
+ // wrap item in li tag
69
+ const $listItem = document.createElement('li');
70
+ this.$menu.insertBefore($listItem, $menuItem);
71
+ $listItem.appendChild($menuItem);
72
+ $menuItem.setAttribute('tabindex', '-1');
73
+ if ($menuItem.tagName === 'BUTTON') {
74
+ $menuItem.setAttribute('type', 'button');
118
75
  }
76
+ $menuItem.classList.forEach(className => {
77
+ if (className.startsWith('govuk-button')) {
78
+ $menuItem.classList.remove(className);
79
+ }
80
+ });
81
+
82
+ // add a slight delay after click before closing the menu, makes it *feel* better
83
+ $menuItem.addEventListener('click', () => {
84
+ setTimeout(() => {
85
+ this.closeMenu(false);
86
+ }, 50);
87
+ });
119
88
  });
120
-
121
- // add a slight delay after click before closing the menu, makes it *feel* better
122
- item.addEventListener('click', (event) => {
123
- setTimeout(() => {
124
- this.closeMenu(false);
125
- }, 50);
126
- });
127
- });
128
- };
129
-
130
- ButtonMenu.prototype.toggleTemplate = function () {
131
- return `
89
+ }
90
+ toggleTemplate() {
91
+ return `
132
92
  <button type="button" class="govuk-button moj-button-menu__toggle-button ${this.config.buttonClasses || ''}" aria-haspopup="true" aria-expanded="false">
133
93
  <span>
134
94
  ${this.config.buttonText}
@@ -136,195 +96,169 @@ ButtonMenu.prototype.toggleTemplate = function () {
136
96
  <path d="M5.5 0L11 5L0 5L5.5 0Z" fill="currentColor"/>
137
97
  </svg>
138
98
  </span>
139
- </button>`
140
- };
141
-
142
- /**
143
- * @returns {boolean}
144
- */
145
- ButtonMenu.prototype.isOpen = function () {
146
- return this.$menuToggle.getAttribute('aria-expanded') === 'true'
147
- };
148
-
149
- ButtonMenu.prototype.toggleMenu = function (event) {
150
- event.preventDefault();
151
-
152
- // If menu is triggered with mouse don't move focus to first item
153
- const keyboardEvent = event.detail === 0;
154
- const focusIndex = keyboardEvent ? 0 : -1;
155
-
156
- if (this.isOpen()) {
157
- this.closeMenu();
158
- } else {
159
- this.openMenu(focusIndex);
99
+ </button>`;
160
100
  }
161
- };
162
101
 
163
- /**
164
- * Opens the menu and optionally sets the focus to the item with given index
165
- *
166
- * @param {number} focusIndex - The index of the item to focus
167
- */
168
- ButtonMenu.prototype.openMenu = function (focusIndex = 0) {
169
- this.$menu.hidden = false;
170
- this.$menuToggle.setAttribute('aria-expanded', 'true');
171
- if (focusIndex !== -1) {
172
- this.focusItem(focusIndex);
102
+ /**
103
+ * @returns {boolean}
104
+ */
105
+ isOpen() {
106
+ return this.$menuToggle.getAttribute('aria-expanded') === 'true';
173
107
  }
174
- };
175
-
176
- /**
177
- * Closes the menu and optionally returns focus back to menuToggle
178
- *
179
- * @param {boolean} moveFocus - whether to return focus to the toggle button
180
- */
181
- ButtonMenu.prototype.closeMenu = function (moveFocus = true) {
182
- this.$menu.hidden = true;
183
- this.$menuToggle.setAttribute('aria-expanded', 'false');
184
- if (moveFocus) {
185
- this.$menuToggle.focus();
186
- }
187
- };
188
-
189
- /**
190
- * Focuses the menu item at the specified index
191
- *
192
- * @param {number} index - the index of the item to focus
193
- */
194
- ButtonMenu.prototype.focusItem = function (index) {
195
- if (index >= this.items.length) index = 0;
196
- if (index < 0) index = this.items.length - 1;
197
108
 
198
- const menuItem = this.items.item(index);
199
- if (menuItem) {
200
- menuItem.focus();
109
+ /**
110
+ * @param {MouseEvent} event - Click event
111
+ */
112
+ toggleMenu(event) {
113
+ event.preventDefault();
114
+
115
+ // If menu is triggered with mouse don't move focus to first item
116
+ const keyboardEvent = event.detail === 0;
117
+ const focusIndex = keyboardEvent ? 0 : -1;
118
+ if (this.isOpen()) {
119
+ this.closeMenu();
120
+ } else {
121
+ this.openMenu(focusIndex);
122
+ }
201
123
  }
202
- };
203
124
 
204
- ButtonMenu.prototype.currentFocusIndex = function () {
205
- const activeElement = document.activeElement;
206
- const menuItems = Array.from(this.items);
207
-
208
- return menuItems.indexOf(activeElement)
209
- };
210
-
211
- ButtonMenu.prototype.handleKeyDown = function (event) {
212
- if (event.target === this.$menuToggle) {
213
- switch (event.key) {
214
- case 'ArrowDown':
215
- event.preventDefault();
216
- this.openMenu();
217
- break
218
- case 'ArrowUp':
219
- event.preventDefault();
220
- this.openMenu(this.items.length - 1);
221
- break
125
+ /**
126
+ * Opens the menu and optionally sets the focus to the item with given index
127
+ *
128
+ * @param {number} focusIndex - The index of the item to focus
129
+ */
130
+ openMenu(focusIndex = 0) {
131
+ this.$menu.hidden = false;
132
+ this.$menuToggle.setAttribute('aria-expanded', 'true');
133
+ if (focusIndex !== -1) {
134
+ this.focusItem(focusIndex);
222
135
  }
223
136
  }
224
137
 
225
- if (this.$menu.contains(event.target) && this.isOpen()) {
226
- switch (event.key) {
227
- case 'ArrowDown':
228
- event.preventDefault();
229
- if (this.currentFocusIndex() !== -1) {
230
- this.focusItem(this.currentFocusIndex() + 1);
231
- }
232
- break
233
- case 'ArrowUp':
234
- event.preventDefault();
235
- if (this.currentFocusIndex() !== -1) {
236
- this.focusItem(this.currentFocusIndex() - 1);
237
- }
238
- break
239
- case 'Home':
240
- event.preventDefault();
241
- this.focusItem(0);
242
- break
243
- case 'End':
244
- event.preventDefault();
245
- this.focusItem(this.items.length - 1);
246
- break
138
+ /**
139
+ * Closes the menu and optionally returns focus back to menuToggle
140
+ *
141
+ * @param {boolean} moveFocus - whether to return focus to the toggle button
142
+ */
143
+ closeMenu(moveFocus = true) {
144
+ this.$menu.hidden = true;
145
+ this.$menuToggle.setAttribute('aria-expanded', 'false');
146
+ if (moveFocus) {
147
+ this.$menuToggle.focus();
247
148
  }
248
149
  }
249
150
 
250
- if (event.key === 'Escape' && this.isOpen()) {
251
- this.closeMenu();
151
+ /**
152
+ * Focuses the menu item at the specified index
153
+ *
154
+ * @param {number} index - the index of the item to focus
155
+ */
156
+ focusItem(index) {
157
+ if (index >= this.$items.length) index = 0;
158
+ if (index < 0) index = this.$items.length - 1;
159
+ const $menuItem = this.$items.item(index);
160
+ if ($menuItem) {
161
+ $menuItem.focus();
162
+ }
252
163
  }
253
- if (event.key === 'Tab' && this.isOpen()) {
254
- this.closeMenu(false);
164
+ currentFocusIndex() {
165
+ const $activeElement = document.activeElement;
166
+ const $menuItems = Array.from(this.$items);
167
+ return ($activeElement instanceof HTMLAnchorElement || $activeElement instanceof HTMLButtonElement) && $menuItems.indexOf($activeElement);
255
168
  }
256
- };
257
-
258
- /**
259
- * Parse dataset
260
- *
261
- * Loop over an object and normalise each value using {@link normaliseString},
262
- * optionally expanding nested `i18n.field`
263
- *
264
- * @param {Schema} schema - component schema
265
- * @param {DOMStringMap} dataset - HTML element dataset
266
- * @returns {object} Normalised dataset
267
- */
268
- ButtonMenu.prototype.parseDataset = function (schema, dataset) {
269
- const parsed = {};
270
169
 
271
- for (const [field, ,] of Object.entries(schema.properties)) {
272
- if (field in dataset) {
273
- if (dataset[field]) {
274
- parsed[field] = dataset[field];
170
+ /**
171
+ * @param {KeyboardEvent} event - Keydown event
172
+ */
173
+ handleKeyDown(event) {
174
+ if (event.target === this.$menuToggle) {
175
+ switch (event.key) {
176
+ case 'ArrowDown':
177
+ event.preventDefault();
178
+ this.openMenu();
179
+ break;
180
+ case 'ArrowUp':
181
+ event.preventDefault();
182
+ this.openMenu(this.$items.length - 1);
183
+ break;
184
+ }
185
+ }
186
+ if (event.target instanceof Node && this.$menu.contains(event.target) && this.isOpen()) {
187
+ switch (event.key) {
188
+ case 'ArrowDown':
189
+ event.preventDefault();
190
+ if (this.currentFocusIndex() !== -1) {
191
+ this.focusItem(this.currentFocusIndex() + 1);
192
+ }
193
+ break;
194
+ case 'ArrowUp':
195
+ event.preventDefault();
196
+ if (this.currentFocusIndex() !== -1) {
197
+ this.focusItem(this.currentFocusIndex() - 1);
198
+ }
199
+ break;
200
+ case 'Home':
201
+ event.preventDefault();
202
+ this.focusItem(0);
203
+ break;
204
+ case 'End':
205
+ event.preventDefault();
206
+ this.focusItem(this.$items.length - 1);
207
+ break;
275
208
  }
276
209
  }
210
+ if (event.key === 'Escape' && this.isOpen()) {
211
+ this.closeMenu();
212
+ }
213
+ if (event.key === 'Tab' && this.isOpen()) {
214
+ this.closeMenu(false);
215
+ }
277
216
  }
278
217
 
279
- return parsed
280
- };
218
+ /**
219
+ * Name for the component used when initialising using data-module attributes.
220
+ */
221
+ }
281
222
 
282
223
  /**
283
- * Config merging function
284
- *
285
- * Takes any number of objects and combines them together, with
286
- * greatest priority on the LAST item passed in.
287
- *
288
- * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge
289
- * @returns {{ [key: string]: unknown }} A merged config object
224
+ * @typedef {object} ButtonMenuConfig
225
+ * @property {string} [buttonText='Actions'] - Label for the toggle button
226
+ * @property {"left" | "right"} [alignMenu='left'] - the alignment of the menu
227
+ * @property {string} [buttonClasses='govuk-button--secondary'] - css classes applied to the toggle button
290
228
  */
291
- ButtonMenu.prototype.mergeConfigs = function (...configObjects) {
292
- const formattedConfigObject = {};
293
-
294
- // Loop through each of the passed objects
295
- for (const configObject of configObjects) {
296
- for (const key of Object.keys(configObject)) {
297
- const option = formattedConfigObject[key];
298
- const override = configObject[key];
299
-
300
- // Push their keys one-by-one into formattedConfigObject. Any duplicate
301
- // keys with object values will be merged, otherwise the new value will
302
- // override the existing value.
303
- if (typeof option === 'object' && typeof override === 'object') {
304
- // @ts-expect-error Index signature for type 'string' is missing
305
- formattedConfigObject[key] = this.mergeConfigs(option, override);
306
- } else {
307
- formattedConfigObject[key] = override;
308
- }
309
- }
310
- }
311
-
312
- return formattedConfigObject
313
- };
314
229
 
315
230
  /**
316
- * Schema for component config
231
+ * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'
232
+ */
233
+ ButtonMenu.moduleName = 'moj-button-menu';
234
+ /**
235
+ * Button menu config
317
236
  *
318
- * @typedef {object} Schema
319
- * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
237
+ * @type {ButtonMenuConfig}
320
238
  */
321
-
239
+ ButtonMenu.defaults = Object.freeze({
240
+ buttonText: 'Actions',
241
+ alignMenu: 'left',
242
+ buttonClasses: ''
243
+ });
322
244
  /**
323
- * Schema property for component config
245
+ * Button menu config schema
324
246
  *
325
- * @typedef {object} SchemaProperty
326
- * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
247
+ * @type {Schema<ButtonMenuConfig>}
327
248
  */
249
+ ButtonMenu.schema = Object.freeze(/** @type {const} */{
250
+ properties: {
251
+ buttonText: {
252
+ type: 'string'
253
+ },
254
+ buttonClasses: {
255
+ type: 'string'
256
+ },
257
+ alignMenu: {
258
+ type: 'string'
259
+ }
260
+ }
261
+ });
328
262
 
329
263
  export { ButtonMenu };
330
264
  //# sourceMappingURL=button-menu.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"button-menu.mjs","sources":["../../../../src/moj/components/button-menu/button-menu.mjs"],"sourcesContent":["/**\n * @typedef {object} ButtonMenuConfig\n * @property {string} [buttonText=Actions] - Label for the toggle button\n * @property {\"left\" | \"right\"} [alignMenu=left] - the alignment of the menu\n * @property {string} [buttonClasses=govuk-button--secondary] - css classes applied to the toggle button\n */\n\n/**\n * @param {HTMLElement} $module\n * @param {ButtonMenuConfig} config\n * @class\n */\nexport function ButtonMenu($module, config = {}) {\n if (!$module) {\n return this\n }\n\n const schema = Object.freeze({\n properties: {\n buttonText: { type: 'string' },\n buttonClasses: { type: 'string' },\n alignMenu: { type: 'string' }\n }\n })\n\n const defaults = {\n buttonText: 'Actions',\n alignMenu: 'left',\n buttonClasses: ''\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\nButtonMenu.prototype.init = function () {\n // If only one button is provided, don't initiate a menu and toggle button\n // if classes have been provided for the toggleButton, apply them to the single item\n if (this.$module.children.length === 1) {\n const button = this.$module.children[0]\n button.classList.forEach((className) => {\n if (className.startsWith('govuk-button-')) {\n button.classList.remove(className)\n }\n button.classList.remove('moj-button-menu__item')\n })\n if (this.config.buttonClasses) {\n button.classList.add(...this.config.buttonClasses.split(' '))\n }\n }\n // Otherwise intialise a button menu\n if (this.$module.children.length > 1) {\n this.initMenu()\n }\n}\n\nButtonMenu.prototype.initMenu = function () {\n this.$menu = this.createMenu()\n this.$module.insertAdjacentHTML('afterbegin', this.toggleTemplate())\n this.setupMenuItems()\n\n this.$menuToggle = this.$module.querySelector(':scope > button')\n this.items = this.$menu.querySelectorAll('a, button')\n\n this.$menuToggle.addEventListener('click', (event) => {\n this.toggleMenu(event)\n })\n\n this.$module.addEventListener('keydown', (event) => {\n this.handleKeyDown(event)\n })\n\n document.addEventListener('click', (event) => {\n if (!this.$module.contains(event.target)) {\n this.closeMenu(false)\n }\n })\n}\n\nButtonMenu.prototype.createMenu = function () {\n const $menu = document.createElement('ul')\n $menu.setAttribute('role', 'list')\n $menu.hidden = true\n $menu.classList.add('moj-button-menu__wrapper')\n if (this.config.alignMenu === 'right') {\n $menu.classList.add('moj-button-menu__wrapper--right')\n }\n\n this.$module.appendChild($menu)\n while (this.$module.firstChild !== $menu) {\n $menu.appendChild(this.$module.firstChild)\n }\n\n return $menu\n}\n\nButtonMenu.prototype.setupMenuItems = function () {\n Array.from(this.$menu.children).forEach((item) => {\n // wrap item in li tag\n const listItem = document.createElement('li')\n this.$menu.insertBefore(listItem, item)\n listItem.appendChild(item)\n\n item.setAttribute('tabindex', -1)\n\n if (item.tagName === 'BUTTON') {\n item.setAttribute('type', 'button')\n }\n\n item.classList.forEach((className) => {\n if (className.startsWith('govuk-button')) {\n item.classList.remove(className)\n }\n })\n\n // add a slight delay after click before closing the menu, makes it *feel* better\n item.addEventListener('click', (event) => {\n setTimeout(() => {\n this.closeMenu(false)\n }, 50)\n })\n })\n}\n\nButtonMenu.prototype.toggleTemplate = function () {\n return `\n <button type=\"button\" class=\"govuk-button moj-button-menu__toggle-button ${this.config.buttonClasses || ''}\" aria-haspopup=\"true\" aria-expanded=\"false\">\n <span>\n ${this.config.buttonText}\n <svg width=\"11\" height=\"5\" viewBox=\"0 0 11 5\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5.5 0L11 5L0 5L5.5 0Z\" fill=\"currentColor\"/>\n </svg>\n </span>\n </button>`\n}\n\n/**\n * @returns {boolean}\n */\nButtonMenu.prototype.isOpen = function () {\n return this.$menuToggle.getAttribute('aria-expanded') === 'true'\n}\n\nButtonMenu.prototype.toggleMenu = function (event) {\n event.preventDefault()\n\n // If menu is triggered with mouse don't move focus to first item\n const keyboardEvent = event.detail === 0\n const focusIndex = keyboardEvent ? 0 : -1\n\n if (this.isOpen()) {\n this.closeMenu()\n } else {\n this.openMenu(focusIndex)\n }\n}\n\n/**\n * Opens the menu and optionally sets the focus to the item with given index\n *\n * @param {number} focusIndex - The index of the item to focus\n */\nButtonMenu.prototype.openMenu = function (focusIndex = 0) {\n this.$menu.hidden = false\n this.$menuToggle.setAttribute('aria-expanded', 'true')\n if (focusIndex !== -1) {\n this.focusItem(focusIndex)\n }\n}\n\n/**\n * Closes the menu and optionally returns focus back to menuToggle\n *\n * @param {boolean} moveFocus - whether to return focus to the toggle button\n */\nButtonMenu.prototype.closeMenu = function (moveFocus = true) {\n this.$menu.hidden = true\n this.$menuToggle.setAttribute('aria-expanded', 'false')\n if (moveFocus) {\n this.$menuToggle.focus()\n }\n}\n\n/**\n * Focuses the menu item at the specified index\n *\n * @param {number} index - the index of the item to focus\n */\nButtonMenu.prototype.focusItem = function (index) {\n if (index >= this.items.length) index = 0\n if (index < 0) index = this.items.length - 1\n\n const menuItem = this.items.item(index)\n if (menuItem) {\n menuItem.focus()\n }\n}\n\nButtonMenu.prototype.currentFocusIndex = function () {\n const activeElement = document.activeElement\n const menuItems = Array.from(this.items)\n\n return menuItems.indexOf(activeElement)\n}\n\nButtonMenu.prototype.handleKeyDown = function (event) {\n if (event.target === this.$menuToggle) {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n this.openMenu()\n break\n case 'ArrowUp':\n event.preventDefault()\n this.openMenu(this.items.length - 1)\n break\n }\n }\n\n if (this.$menu.contains(event.target) && this.isOpen()) {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n if (this.currentFocusIndex() !== -1) {\n this.focusItem(this.currentFocusIndex() + 1)\n }\n break\n case 'ArrowUp':\n event.preventDefault()\n if (this.currentFocusIndex() !== -1) {\n this.focusItem(this.currentFocusIndex() - 1)\n }\n break\n case 'Home':\n event.preventDefault()\n this.focusItem(0)\n break\n case 'End':\n event.preventDefault()\n this.focusItem(this.items.length - 1)\n break\n }\n }\n\n if (event.key === 'Escape' && this.isOpen()) {\n this.closeMenu()\n }\n if (event.key === 'Tab' && this.isOpen()) {\n this.closeMenu(false)\n }\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 */\nButtonMenu.prototype.parseDataset = function (schema, dataset) {\n const parsed = {}\n\n for (const [field, ,] of Object.entries(schema.properties)) {\n if (field in dataset) {\n if (dataset[field]) {\n parsed[field] = dataset[field]\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 */\nButtonMenu.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":"AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,EAAE;AACjD,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,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;AACpC,MAAM,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;AACvC,MAAM,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ;AACjC;AACA,GAAG;;AAEH,EAAE,MAAM,QAAQ,GAAG;AACnB,IAAI,UAAU,EAAE,SAAS;AACzB,IAAI,SAAS,EAAE,MAAM;AACrB,IAAI,aAAa,EAAE;AACnB;AACA;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,UAAU,CAAC,SAAS,CAAC,IAAI,GAAG,YAAY;AACxC;AACA;AACA,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;AAC1C,IAAI,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC1C,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK;AAC5C,M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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":"button-menu.mjs","sources":["../../../../src/moj/components/button-menu/button-menu.mjs"],"sourcesContent":["import { ConfigurableComponent } from 'govuk-frontend'\n\n/**\n * @augments {ConfigurableComponent<ButtonMenuConfig>}\n */\nexport class ButtonMenu extends ConfigurableComponent {\n /**\n * @param {Element | null} $root - HTML element to use for button menu\n * @param {ButtonMenuConfig} [config] - Button menu config\n */\n constructor($root, config = {}) {\n super($root, config)\n\n // If only one button is provided, don't initiate a menu and toggle button\n // if classes have been provided for the toggleButton, apply them to the single item\n if (this.$root.children.length === 1) {\n const $button = this.$root.children[0]\n\n $button.classList.forEach((className) => {\n if (className.startsWith('govuk-button-')) {\n $button.classList.remove(className)\n }\n\n $button.classList.remove('moj-button-menu__item')\n $button.classList.add('moj-button-menu__single-button')\n })\n\n if (this.config.buttonClasses) {\n $button.classList.add(...this.config.buttonClasses.split(' '))\n }\n }\n // Otherwise initialise a button menu\n if (this.$root.children.length > 1) {\n this.initMenu()\n }\n }\n\n initMenu() {\n this.$menu = this.createMenu()\n this.$root.insertAdjacentHTML('afterbegin', this.toggleTemplate())\n this.setupMenuItems()\n\n this.$menuToggle = this.$root.querySelector(':scope > button')\n this.$items = this.$menu.querySelectorAll('a, button')\n\n this.$menuToggle.addEventListener('click', (event) => {\n this.toggleMenu(event)\n })\n\n this.$root.addEventListener('keydown', (event) => {\n this.handleKeyDown(event)\n })\n\n document.addEventListener('click', (event) => {\n if (event.target instanceof Node && !this.$root.contains(event.target)) {\n this.closeMenu(false)\n }\n })\n }\n\n createMenu() {\n const $menu = document.createElement('ul')\n\n $menu.setAttribute('role', 'list')\n $menu.hidden = true\n $menu.classList.add('moj-button-menu__wrapper')\n\n if (this.config.alignMenu === 'right') {\n $menu.classList.add('moj-button-menu__wrapper--right')\n }\n\n this.$root.appendChild($menu)\n\n while (this.$root.firstChild !== $menu) {\n $menu.appendChild(this.$root.firstChild)\n }\n\n return $menu\n }\n\n setupMenuItems() {\n Array.from(this.$menu.children).forEach(($menuItem) => {\n // wrap item in li tag\n const $listItem = document.createElement('li')\n this.$menu.insertBefore($listItem, $menuItem)\n $listItem.appendChild($menuItem)\n\n $menuItem.setAttribute('tabindex', '-1')\n\n if ($menuItem.tagName === 'BUTTON') {\n $menuItem.setAttribute('type', 'button')\n }\n\n $menuItem.classList.forEach((className) => {\n if (className.startsWith('govuk-button')) {\n $menuItem.classList.remove(className)\n }\n })\n\n // add a slight delay after click before closing the menu, makes it *feel* better\n $menuItem.addEventListener('click', () => {\n setTimeout(() => {\n this.closeMenu(false)\n }, 50)\n })\n })\n }\n\n toggleTemplate() {\n return `\n <button type=\"button\" class=\"govuk-button moj-button-menu__toggle-button ${this.config.buttonClasses || ''}\" aria-haspopup=\"true\" aria-expanded=\"false\">\n <span>\n ${this.config.buttonText}\n <svg width=\"11\" height=\"5\" viewBox=\"0 0 11 5\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5.5 0L11 5L0 5L5.5 0Z\" fill=\"currentColor\"/>\n </svg>\n </span>\n </button>`\n }\n\n /**\n * @returns {boolean}\n */\n isOpen() {\n return this.$menuToggle.getAttribute('aria-expanded') === 'true'\n }\n\n /**\n * @param {MouseEvent} event - Click event\n */\n toggleMenu(event) {\n event.preventDefault()\n\n // If menu is triggered with mouse don't move focus to first item\n const keyboardEvent = event.detail === 0\n const focusIndex = keyboardEvent ? 0 : -1\n\n if (this.isOpen()) {\n this.closeMenu()\n } else {\n this.openMenu(focusIndex)\n }\n }\n\n /**\n * Opens the menu and optionally sets the focus to the item with given index\n *\n * @param {number} focusIndex - The index of the item to focus\n */\n openMenu(focusIndex = 0) {\n this.$menu.hidden = false\n this.$menuToggle.setAttribute('aria-expanded', 'true')\n if (focusIndex !== -1) {\n this.focusItem(focusIndex)\n }\n }\n\n /**\n * Closes the menu and optionally returns focus back to menuToggle\n *\n * @param {boolean} moveFocus - whether to return focus to the toggle button\n */\n closeMenu(moveFocus = true) {\n this.$menu.hidden = true\n this.$menuToggle.setAttribute('aria-expanded', 'false')\n if (moveFocus) {\n this.$menuToggle.focus()\n }\n }\n\n /**\n * Focuses the menu item at the specified index\n *\n * @param {number} index - the index of the item to focus\n */\n focusItem(index) {\n if (index >= this.$items.length) index = 0\n if (index < 0) index = this.$items.length - 1\n\n const $menuItem = this.$items.item(index)\n if ($menuItem) {\n $menuItem.focus()\n }\n }\n\n currentFocusIndex() {\n const $activeElement = document.activeElement\n const $menuItems = Array.from(this.$items)\n\n return (\n ($activeElement instanceof HTMLAnchorElement ||\n $activeElement instanceof HTMLButtonElement) &&\n $menuItems.indexOf($activeElement)\n )\n }\n\n /**\n * @param {KeyboardEvent} event - Keydown event\n */\n handleKeyDown(event) {\n if (event.target === this.$menuToggle) {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n this.openMenu()\n break\n case 'ArrowUp':\n event.preventDefault()\n this.openMenu(this.$items.length - 1)\n break\n }\n }\n\n if (\n event.target instanceof Node &&\n this.$menu.contains(event.target) &&\n this.isOpen()\n ) {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n if (this.currentFocusIndex() !== -1) {\n this.focusItem(this.currentFocusIndex() + 1)\n }\n break\n case 'ArrowUp':\n event.preventDefault()\n if (this.currentFocusIndex() !== -1) {\n this.focusItem(this.currentFocusIndex() - 1)\n }\n break\n case 'Home':\n event.preventDefault()\n this.focusItem(0)\n break\n case 'End':\n event.preventDefault()\n this.focusItem(this.$items.length - 1)\n break\n }\n }\n\n if (event.key === 'Escape' && this.isOpen()) {\n this.closeMenu()\n }\n if (event.key === 'Tab' && this.isOpen()) {\n this.closeMenu(false)\n }\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'moj-button-menu'\n\n /**\n * Button menu config\n *\n * @type {ButtonMenuConfig}\n */\n static defaults = Object.freeze({\n buttonText: 'Actions',\n alignMenu: 'left',\n buttonClasses: ''\n })\n\n /**\n * Button menu config schema\n *\n * @type {Schema<ButtonMenuConfig>}\n */\n static schema = Object.freeze(\n /** @type {const} */ ({\n properties: {\n buttonText: { type: 'string' },\n buttonClasses: { type: 'string' },\n alignMenu: { type: 'string' }\n }\n })\n )\n}\n\n/**\n * @typedef {object} ButtonMenuConfig\n * @property {string} [buttonText='Actions'] - Label for the toggle button\n * @property {\"left\" | \"right\"} [alignMenu='left'] - the alignment of the menu\n * @property {string} [buttonClasses='govuk-button--secondary'] - css classes applied to the toggle button\n */\n\n/**\n * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'\n */\n"],"names":["ButtonMenu","ConfigurableComponent","constructor","$root","config","children","length","$button","classList","forEach","className","startsWith","remove","add","buttonClasses","split","initMenu","$menu","createMenu","insertAdjacentHTML","toggleTemplate","setupMenuItems","$menuToggle","querySelector","$items","querySelectorAll","addEventListener","event","toggleMenu","handleKeyDown","document","target","Node","contains","closeMenu","createElement","setAttribute","hidden","alignMenu","appendChild","firstChild","Array","from","$menuItem","$listItem","insertBefore","tagName","setTimeout","buttonText","isOpen","getAttribute","preventDefault","keyboardEvent","detail","focusIndex","openMenu","focusItem","moveFocus","focus","index","item","currentFocusIndex","$activeElement","activeElement","$menuItems","HTMLAnchorElement","HTMLButtonElement","indexOf","key","moduleName","defaults","Object","freeze","schema","properties","type"],"mappings":";;AAEA;AACA;AACA;AACO,MAAMA,UAAU,SAASC,qBAAqB,CAAC;AACpD;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC,KAAK,EAAEC,MAAM,GAAG,EAAE,EAAE;AAC9B,IAAA,KAAK,CAACD,KAAK,EAAEC,MAAM,CAAC;;AAEpB;AACA;IACA,IAAI,IAAI,CAACD,KAAK,CAACE,QAAQ,CAACC,MAAM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AAS,EAAE;AAAEqC,MAAAA,IAAI,EAAE;AAAS;AAC9B;AACF,CACF,CAAC;;;;"}
@@ -41,3 +41,5 @@
41
41
  display: none !important;
42
42
  }
43
43
  }
44
+
45
+ /*# sourceMappingURL=_cookie-banner.scss.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/moj/components/cookie-banner/_cookie-banner.scss"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,uCAAuC;;AAEvC;EACE,sBAAsB;EACtB,aAAa;EACb,sBAAsB;;EAEtB,6BAA6B;EAC7B,+BAA+B;EAC/B,gCAAgC;EAChC,uCAAuC;EACvC,uBAAuB;;EAEvB;IACE,sDAAsD;IACtD,yBAAyB;EAC3B;;EAEA;IACE,SAAS;IACT,4BAA4B;EAC9B;;EAEA;IACE;MACE,eAAe;IACjB;EACF;;EAEA;IACE;MACE,UAAU;IACZ;EACF;AACF;;AAEA;EACE;IACE,sDAAsD;IACtD,wBAAwB;EAC1B;AACF","file":"_cookie-banner.scss","sourcesContent":["@use \"../../objects/width-container\" as *;\n@use \"../../vendor/govuk-frontend\" as *;\n\n.moj-cookie-banner {\n box-sizing: border-box;\n display: none;\n left: govuk-spacing(3);\n\n padding-top: govuk-spacing(3);\n padding-right: govuk-spacing(3);\n padding-bottom: govuk-spacing(3);\n background-color: govuk-colour(\"white\");\n @include govuk-font(16);\n\n &--show {\n // stylelint-disable-next-line declaration-no-important\n display: block !important;\n }\n\n &__message {\n margin: 0;\n @include moj-width-container;\n }\n\n &__buttons {\n .govuk-grid-column-full {\n padding-left: 0;\n }\n }\n\n .govuk-button {\n @include govuk-media-query($from: tablet) {\n width: 90%;\n }\n }\n}\n\n@include govuk-media-query($media-type: print) {\n .moj-cookie-banner {\n // stylelint-disable-next-line declaration-no-important\n display: none !important;\n }\n}\n"]}
@@ -28,3 +28,5 @@
28
28
  margin: 0;
29
29
  padding-left: 40px;
30
30
  }
31
+
32
+ /*# sourceMappingURL=_currency-input.scss.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/moj/components/currency-input/_currency-input.scss"],"names":[],"mappings":"AAAA,uCAAuC;;AAEvC;;+EAE+E;;AAE/E;EACE,kBAAkB;EAClB,sDAAsD;EACtD,8BAA8B;EAC9B,mBAAmB;EACnB,6CAA6C;EAC7C,4CAA4C;EAC5C,uBAAuB;;EAEvB;IACE,2CAA2C;IAC3C,4BAA4B;IAC5B,qCAAqC;EACvC;;EAEA;IACE,iBAAiB;EACnB;AACF;;AAEA;EACE,SAAS;EACT,kBAAkB;AACpB","file":"_currency-input.scss","sourcesContent":["@use \"../../vendor/govuk-frontend\" as *;\n\n/* ==========================================================================\n #DENOTE\n ========================================================================== */\n\n.moj-label__currency {\n position: absolute;\n // stylelint-disable-next-line declaration-no-important\n margin: 2px 0 0 2px !important;\n padding: 5.5px 12px;\n border-right: 2px solid govuk-colour(\"black\");\n background-color: govuk-colour(\"light-grey\");\n @include govuk-font(19);\n\n &--error {\n border-right: 2px solid $govuk-error-colour;\n color: govuk-colour(\"white\");\n background-color: $govuk-error-colour;\n }\n\n @include govuk-media-query($until: tablet) {\n padding: 8px 12px;\n }\n}\n\n.moj-input__currency {\n margin: 0;\n padding-left: 40px;\n}\n"]}
@@ -306,3 +306,5 @@
306
306
  background-color: $moj-button-menu-color;
307
307
  }
308
308
  }
309
+
310
+ /*# sourceMappingURL=_date-picker.scss.map */