@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,59 +1,44 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MOJFrontend = global.MOJFrontend || {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- /**
8
- * @typedef {object} ButtonMenuConfig
9
- * @property {string} [buttonText=Actions] - Label for the toggle button
10
- * @property {"left" | "right"} [alignMenu=left] - the alignment of the menu
11
- * @property {string} [buttonClasses=govuk-button--secondary] - css classes applied to the toggle button
12
- */
13
-
1
+ class ButtonMenu {
14
2
  /**
15
- * @param {HTMLElement} $module
16
- * @param {ButtonMenuConfig} config
17
- * @class
3
+ * @param {Element | null} $module - HTML element to use for button menu
4
+ * @param {ButtonMenuConfig} [config] - Button menu config
18
5
  */
19
- function ButtonMenu($module, config = {}) {
20
- if (!$module) {
21
- return this
6
+ constructor($module, config = {}) {
7
+ if (!$module || !($module instanceof HTMLElement)) {
8
+ return this;
22
9
  }
23
-
24
10
  const schema = Object.freeze({
25
11
  properties: {
26
- buttonText: { type: 'string' },
27
- buttonClasses: { type: 'string' },
28
- alignMenu: { type: 'string' }
12
+ buttonText: {
13
+ type: 'string'
14
+ },
15
+ buttonClasses: {
16
+ type: 'string'
17
+ },
18
+ alignMenu: {
19
+ type: 'string'
20
+ }
29
21
  }
30
22
  });
31
-
32
23
  const defaults = {
33
24
  buttonText: 'Actions',
34
25
  alignMenu: 'left',
35
26
  buttonClasses: ''
36
27
  };
37
28
  // data attributes override JS config, which overrides defaults
38
- this.config = this.mergeConfigs(
39
- defaults,
40
- config,
41
- this.parseDataset(schema, $module.dataset)
42
- );
43
-
29
+ this.config = this.mergeConfigs(defaults, config, this.parseDataset(schema, $module.dataset));
44
30
  this.$module = $module;
45
- }
46
31
 
47
- ButtonMenu.prototype.init = function () {
48
32
  // If only one button is provided, don't initiate a menu and toggle button
49
33
  // if classes have been provided for the toggleButton, apply them to the single item
50
34
  if (this.$module.children.length === 1) {
51
35
  const button = this.$module.children[0];
52
- button.classList.forEach((className) => {
36
+ button.classList.forEach(className => {
53
37
  if (className.startsWith('govuk-button-')) {
54
38
  button.classList.remove(className);
55
39
  }
56
40
  button.classList.remove('moj-button-menu__item');
41
+ button.classList.add('moj-button-menu__single-button');
57
42
  });
58
43
  if (this.config.buttonClasses) {
59
44
  button.classList.add(...this.config.buttonClasses.split(' '));
@@ -63,32 +48,26 @@
63
48
  if (this.$module.children.length > 1) {
64
49
  this.initMenu();
65
50
  }
66
- };
67
-
68
- ButtonMenu.prototype.initMenu = function () {
51
+ }
52
+ initMenu() {
69
53
  this.$menu = this.createMenu();
70
54
  this.$module.insertAdjacentHTML('afterbegin', this.toggleTemplate());
71
55
  this.setupMenuItems();
72
-
73
56
  this.$menuToggle = this.$module.querySelector(':scope > button');
74
57
  this.items = this.$menu.querySelectorAll('a, button');
75
-
76
- this.$menuToggle.addEventListener('click', (event) => {
58
+ this.$menuToggle.addEventListener('click', event => {
77
59
  this.toggleMenu(event);
78
60
  });
79
-
80
- this.$module.addEventListener('keydown', (event) => {
61
+ this.$module.addEventListener('keydown', event => {
81
62
  this.handleKeyDown(event);
82
63
  });
83
-
84
- document.addEventListener('click', (event) => {
64
+ document.addEventListener('click', event => {
85
65
  if (!this.$module.contains(event.target)) {
86
66
  this.closeMenu(false);
87
67
  }
88
68
  });
89
- };
90
-
91
- ButtonMenu.prototype.createMenu = function () {
69
+ }
70
+ createMenu() {
92
71
  const $menu = document.createElement('ul');
93
72
  $menu.setAttribute('role', 'list');
94
73
  $menu.hidden = true;
@@ -96,44 +75,37 @@
96
75
  if (this.config.alignMenu === 'right') {
97
76
  $menu.classList.add('moj-button-menu__wrapper--right');
98
77
  }
99
-
100
78
  this.$module.appendChild($menu);
101
79
  while (this.$module.firstChild !== $menu) {
102
80
  $menu.appendChild(this.$module.firstChild);
103
81
  }
104
-
105
- return $menu
106
- };
107
-
108
- ButtonMenu.prototype.setupMenuItems = function () {
109
- Array.from(this.$menu.children).forEach((item) => {
82
+ return $menu;
83
+ }
84
+ setupMenuItems() {
85
+ Array.from(this.$menu.children).forEach(item => {
110
86
  // wrap item in li tag
111
87
  const listItem = document.createElement('li');
112
88
  this.$menu.insertBefore(listItem, item);
113
89
  listItem.appendChild(item);
114
-
115
- item.setAttribute('tabindex', -1);
116
-
90
+ item.setAttribute('tabindex', '-1');
117
91
  if (item.tagName === 'BUTTON') {
118
92
  item.setAttribute('type', 'button');
119
93
  }
120
-
121
- item.classList.forEach((className) => {
94
+ item.classList.forEach(className => {
122
95
  if (className.startsWith('govuk-button')) {
123
96
  item.classList.remove(className);
124
97
  }
125
98
  });
126
99
 
127
100
  // add a slight delay after click before closing the menu, makes it *feel* better
128
- item.addEventListener('click', (event) => {
101
+ item.addEventListener('click', () => {
129
102
  setTimeout(() => {
130
103
  this.closeMenu(false);
131
104
  }, 50);
132
105
  });
133
106
  });
134
- };
135
-
136
- ButtonMenu.prototype.toggleTemplate = function () {
107
+ }
108
+ toggleTemplate() {
137
109
  return `
138
110
  <button type="button" class="govuk-button moj-button-menu__toggle-button ${this.config.buttonClasses || ''}" aria-haspopup="true" aria-expanded="false">
139
111
  <span>
@@ -142,92 +114,85 @@
142
114
  <path d="M5.5 0L11 5L0 5L5.5 0Z" fill="currentColor"/>
143
115
  </svg>
144
116
  </span>
145
- </button>`
146
- };
117
+ </button>`;
118
+ }
147
119
 
148
120
  /**
149
121
  * @returns {boolean}
150
122
  */
151
- ButtonMenu.prototype.isOpen = function () {
152
- return this.$menuToggle.getAttribute('aria-expanded') === 'true'
153
- };
154
-
155
- ButtonMenu.prototype.toggleMenu = function (event) {
123
+ isOpen() {
124
+ return this.$menuToggle.getAttribute('aria-expanded') === 'true';
125
+ }
126
+ toggleMenu(event) {
156
127
  event.preventDefault();
157
128
 
158
129
  // If menu is triggered with mouse don't move focus to first item
159
130
  const keyboardEvent = event.detail === 0;
160
131
  const focusIndex = keyboardEvent ? 0 : -1;
161
-
162
132
  if (this.isOpen()) {
163
133
  this.closeMenu();
164
134
  } else {
165
135
  this.openMenu(focusIndex);
166
136
  }
167
- };
137
+ }
168
138
 
169
139
  /**
170
140
  * Opens the menu and optionally sets the focus to the item with given index
171
141
  *
172
142
  * @param {number} focusIndex - The index of the item to focus
173
143
  */
174
- ButtonMenu.prototype.openMenu = function (focusIndex = 0) {
144
+ openMenu(focusIndex = 0) {
175
145
  this.$menu.hidden = false;
176
146
  this.$menuToggle.setAttribute('aria-expanded', 'true');
177
147
  if (focusIndex !== -1) {
178
148
  this.focusItem(focusIndex);
179
149
  }
180
- };
150
+ }
181
151
 
182
152
  /**
183
153
  * Closes the menu and optionally returns focus back to menuToggle
184
154
  *
185
155
  * @param {boolean} moveFocus - whether to return focus to the toggle button
186
156
  */
187
- ButtonMenu.prototype.closeMenu = function (moveFocus = true) {
157
+ closeMenu(moveFocus = true) {
188
158
  this.$menu.hidden = true;
189
159
  this.$menuToggle.setAttribute('aria-expanded', 'false');
190
160
  if (moveFocus) {
191
161
  this.$menuToggle.focus();
192
162
  }
193
- };
163
+ }
194
164
 
195
165
  /**
196
166
  * Focuses the menu item at the specified index
197
167
  *
198
168
  * @param {number} index - the index of the item to focus
199
169
  */
200
- ButtonMenu.prototype.focusItem = function (index) {
170
+ focusItem(index) {
201
171
  if (index >= this.items.length) index = 0;
202
172
  if (index < 0) index = this.items.length - 1;
203
-
204
173
  const menuItem = this.items.item(index);
205
174
  if (menuItem) {
206
175
  menuItem.focus();
207
176
  }
208
- };
209
-
210
- ButtonMenu.prototype.currentFocusIndex = function () {
177
+ }
178
+ currentFocusIndex() {
211
179
  const activeElement = document.activeElement;
212
180
  const menuItems = Array.from(this.items);
213
-
214
- return menuItems.indexOf(activeElement)
215
- };
216
-
217
- ButtonMenu.prototype.handleKeyDown = function (event) {
181
+ return menuItems.indexOf(activeElement);
182
+ }
183
+ handleKeyDown(event) {
218
184
  if (event.target === this.$menuToggle) {
219
185
  switch (event.key) {
220
186
  case 'ArrowDown':
221
187
  event.preventDefault();
222
188
  this.openMenu();
223
- break
189
+ break;
224
190
  case 'ArrowUp':
225
191
  event.preventDefault();
226
192
  this.openMenu(this.items.length - 1);
227
- break
193
+ break;
228
194
  }
229
195
  }
230
-
231
196
  if (this.$menu.contains(event.target) && this.isOpen()) {
232
197
  switch (event.key) {
233
198
  case 'ArrowDown':
@@ -235,31 +200,30 @@
235
200
  if (this.currentFocusIndex() !== -1) {
236
201
  this.focusItem(this.currentFocusIndex() + 1);
237
202
  }
238
- break
203
+ break;
239
204
  case 'ArrowUp':
240
205
  event.preventDefault();
241
206
  if (this.currentFocusIndex() !== -1) {
242
207
  this.focusItem(this.currentFocusIndex() - 1);
243
208
  }
244
- break
209
+ break;
245
210
  case 'Home':
246
211
  event.preventDefault();
247
212
  this.focusItem(0);
248
- break
213
+ break;
249
214
  case 'End':
250
215
  event.preventDefault();
251
216
  this.focusItem(this.items.length - 1);
252
- break
217
+ break;
253
218
  }
254
219
  }
255
-
256
220
  if (event.key === 'Escape' && this.isOpen()) {
257
221
  this.closeMenu();
258
222
  }
259
223
  if (event.key === 'Tab' && this.isOpen()) {
260
224
  this.closeMenu(false);
261
225
  }
262
- };
226
+ }
263
227
 
264
228
  /**
265
229
  * Parse dataset
@@ -271,19 +235,17 @@
271
235
  * @param {DOMStringMap} dataset - HTML element dataset
272
236
  * @returns {object} Normalised dataset
273
237
  */
274
- ButtonMenu.prototype.parseDataset = function (schema, dataset) {
238
+ parseDataset(schema, dataset) {
275
239
  const parsed = {};
276
-
277
- for (const [field, ,] of Object.entries(schema.properties)) {
240
+ for (const [field,,] of Object.entries(schema.properties)) {
278
241
  if (field in dataset) {
279
242
  if (dataset[field]) {
280
243
  parsed[field] = dataset[field];
281
244
  }
282
245
  }
283
246
  }
284
-
285
- return parsed
286
- };
247
+ return parsed;
248
+ }
287
249
 
288
250
  /**
289
251
  * Config merging function
@@ -294,7 +256,7 @@
294
256
  * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge
295
257
  * @returns {{ [key: string]: unknown }} A merged config object
296
258
  */
297
- ButtonMenu.prototype.mergeConfigs = function (...configObjects) {
259
+ mergeConfigs(...configObjects) {
298
260
  const formattedConfigObject = {};
299
261
 
300
262
  // Loop through each of the passed objects
@@ -314,25 +276,16 @@
314
276
  }
315
277
  }
316
278
  }
279
+ return formattedConfigObject;
280
+ }
281
+ }
317
282
 
318
- return formattedConfigObject
319
- };
320
-
321
- /**
322
- * Schema for component config
323
- *
324
- * @typedef {object} Schema
325
- * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
326
- */
327
-
328
- /**
329
- * Schema property for component config
330
- *
331
- * @typedef {object} SchemaProperty
332
- * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
333
- */
334
-
335
- exports.ButtonMenu = ButtonMenu;
283
+ /**
284
+ * @typedef {object} ButtonMenuConfig
285
+ * @property {string} [buttonText='Actions'] - Label for the toggle button
286
+ * @property {"left" | "right"} [alignMenu='left'] - the alignment of the menu
287
+ * @property {string} [buttonClasses='govuk-button--secondary'] - css classes applied to the toggle button
288
+ */
336
289
 
337
- }));
338
- //# sourceMappingURL=button-menu.js.map
290
+ export { ButtonMenu };
291
+ //# sourceMappingURL=button-menu.bundle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button-menu.bundle.mjs","sources":["../../../../src/moj/components/button-menu/button-menu.mjs"],"sourcesContent":["export class ButtonMenu {\n /**\n * @param {Element | null} $module - HTML element to use for button menu\n * @param {ButtonMenuConfig} [config] - Button menu 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 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 // 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 button.classList.add('moj-button-menu__single-button')\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\n initMenu() {\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\n createMenu() {\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\n setupMenuItems() {\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', () => {\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 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 menuItems.indexOf(activeElement)\n }\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 (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 */\n parseDataset(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 */\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} 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"],"names":["ButtonMenu","constructor","$module","config","HTMLElement","schema","Object","freeze","properties","buttonText","type","buttonClasses","alignMenu","defaults","mergeConfigs","parseDataset","dataset","children","length","button","classList","forEach","className","startsWith","remove","add","split","initMenu","$menu","createMenu","insertAdjacentHTML","toggleTemplate","setupMenuItems","$menuToggle","querySelector","items","querySelectorAll","addEventListener","event","toggleMenu","handleKeyDown","document","contains","target","closeMenu","createElement","setAttribute","hidden","appendChild","firstChild","Array","from","item","listItem","insertBefore","tagName","setTimeout","isOpen","getAttribute","preventDefault","keyboardEvent","detail","focusIndex","openMenu","focusItem","moveFocus","focus","index","menuItem","currentFocusIndex","activeElement","menuItems","indexOf","key","parsed","field","entries","configObjects","formattedConfigObject","configObject","keys","option","override"],"mappings":"AAAO,MAAMA,UAAU,CAAC;AACtB;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,UAAU,EAAE;AAAEC,UAAAA,IAAI,EAAE;SAAU;AAC9BC,QAAAA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