@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
@@ -0,0 +1,140 @@
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
+ * @param {Element} $element - Element to remove attribute value from
9
+ * @param {string} attr - Attribute name
10
+ * @param {string} value - Attribute value
11
+ */
12
+ function removeAttributeValue($element, attr, value) {
13
+ let re, m;
14
+ if ($element.getAttribute(attr)) {
15
+ if ($element.getAttribute(attr) === value) {
16
+ $element.removeAttribute(attr);
17
+ } else {
18
+ re = new RegExp(`(^|\\s)${value}(\\s|$)`);
19
+ m = $element.getAttribute(attr).match(re);
20
+ if (m && m.length === 3) {
21
+ $element.setAttribute(attr, $element.getAttribute(attr).replace(re, m[1] && m[2] ? ' ' : ''));
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ /**
28
+ * @param {Element} $element - Element to add attribute value to
29
+ * @param {string} attr - Attribute name
30
+ * @param {string} value - Attribute value
31
+ */
32
+ function addAttributeValue($element, attr, value) {
33
+ let re;
34
+ if (!$element.getAttribute(attr)) {
35
+ $element.setAttribute(attr, value);
36
+ } else {
37
+ re = new RegExp(`(^|\\s)${value}(\\s|$)`);
38
+ if (!re.test($element.getAttribute(attr))) {
39
+ $element.setAttribute(attr, `${$element.getAttribute(attr)} ${value}`);
40
+ }
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Find an elements next sibling
46
+ *
47
+ * Utility function to find an elements next sibling matching the provided
48
+ * selector.
49
+ *
50
+ * @param {Element | null} $element - Element to find siblings for
51
+ * @param {string} [selector] - selector for required sibling
52
+ */
53
+ function getNextSibling($element, selector) {
54
+ if (!$element || !($element instanceof HTMLElement)) {
55
+ return;
56
+ }
57
+
58
+ // Get the next sibling element
59
+ let $sibling = $element.nextElementSibling;
60
+
61
+ // If there's no selector, return the first sibling
62
+ if (!selector) return $sibling;
63
+
64
+ // If the sibling matches our selector, use it
65
+ // If not, jump to the next sibling and continue the loop
66
+ while ($sibling) {
67
+ if ($sibling.matches(selector)) return $sibling;
68
+ $sibling = $sibling.nextElementSibling;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Find an elements preceding sibling
74
+ *
75
+ * Utility function to find an elements previous sibling matching the provided
76
+ * selector.
77
+ *
78
+ * @param {Element | null} $element - Element to find siblings for
79
+ * @param {string} [selector] - selector for required sibling
80
+ */
81
+ function getPreviousSibling($element, selector) {
82
+ if (!$element || !($element instanceof HTMLElement)) {
83
+ return;
84
+ }
85
+
86
+ // Get the previous sibling element
87
+ let $sibling = $element.previousElementSibling;
88
+
89
+ // If there's no selector, return the first sibling
90
+ if (!selector) return $sibling;
91
+
92
+ // If the sibling matches our selector, use it
93
+ // If not, jump to the next sibling and continue the loop
94
+ while ($sibling) {
95
+ if ($sibling.matches(selector)) return $sibling;
96
+ $sibling = $sibling.previousElementSibling;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @param {Element | null} $element
102
+ * @param {string} [selector]
103
+ */
104
+ function findNearestMatchingElement($element, selector) {
105
+ // If no element or selector is provided, return
106
+ if (!$element || !($element instanceof HTMLElement) || !selector) {
107
+ return;
108
+ }
109
+
110
+ // Start with the current element
111
+ let $currentElement = $element;
112
+ while ($currentElement) {
113
+ // First check the current element
114
+ if ($currentElement.matches(selector)) {
115
+ return $currentElement;
116
+ }
117
+
118
+ // Check all previous siblings
119
+ let $sibling = $currentElement.previousElementSibling;
120
+ while ($sibling) {
121
+ // Check if the sibling itself is a heading
122
+ if ($sibling.matches(selector)) {
123
+ return $sibling;
124
+ }
125
+ $sibling = $sibling.previousElementSibling;
126
+ }
127
+
128
+ // If no match found in siblings, move up to parent
129
+ $currentElement = $currentElement.parentElement;
130
+ }
131
+ }
132
+
133
+ exports.addAttributeValue = addAttributeValue;
134
+ exports.findNearestMatchingElement = findNearestMatchingElement;
135
+ exports.getNextSibling = getNextSibling;
136
+ exports.getPreviousSibling = getPreviousSibling;
137
+ exports.removeAttributeValue = removeAttributeValue;
138
+
139
+ }));
140
+ //# sourceMappingURL=helpers.bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.bundle.js","sources":["../../src/moj/helpers.mjs"],"sourcesContent":["/**\n * @param {Element} $element - Element to remove attribute value from\n * @param {string} attr - Attribute name\n * @param {string} value - Attribute value\n */\nexport function removeAttributeValue($element, attr, value) {\n let re, m\n if ($element.getAttribute(attr)) {\n if ($element.getAttribute(attr) === value) {\n $element.removeAttribute(attr)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n m = $element.getAttribute(attr).match(re)\n if (m && m.length === 3) {\n $element.setAttribute(\n attr,\n $element.getAttribute(attr).replace(re, m[1] && m[2] ? ' ' : '')\n )\n }\n }\n }\n}\n\n/**\n * @param {Element} $element - Element to add attribute value to\n * @param {string} attr - Attribute name\n * @param {string} value - Attribute value\n */\nexport function addAttributeValue($element, attr, value) {\n let re\n if (!$element.getAttribute(attr)) {\n $element.setAttribute(attr, value)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n if (!re.test($element.getAttribute(attr))) {\n $element.setAttribute(attr, `${$element.getAttribute(attr)} ${value}`)\n }\n }\n}\n\n/**\n * Find an elements next sibling\n *\n * Utility function to find an elements next sibling matching the provided\n * selector.\n *\n * @param {Element | null} $element - Element to find siblings for\n * @param {string} [selector] - selector for required sibling\n */\nexport function getNextSibling($element, selector) {\n if (!$element || !($element instanceof HTMLElement)) {\n return\n }\n\n // Get the next sibling element\n let $sibling = $element.nextElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.nextElementSibling\n }\n}\n\n/**\n * Find an elements preceding sibling\n *\n * Utility function to find an elements previous sibling matching the provided\n * selector.\n *\n * @param {Element | null} $element - Element to find siblings for\n * @param {string} [selector] - selector for required sibling\n */\nexport function getPreviousSibling($element, selector) {\n if (!$element || !($element instanceof HTMLElement)) {\n return\n }\n\n // Get the previous sibling element\n let $sibling = $element.previousElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.previousElementSibling\n }\n}\n\n/**\n * @param {Element | null} $element\n * @param {string} [selector]\n */\nexport function findNearestMatchingElement($element, selector) {\n // If no element or selector is provided, return\n if (!$element || !($element instanceof HTMLElement) || !selector) {\n return\n }\n\n // Start with the current element\n let $currentElement = $element\n\n while ($currentElement) {\n // First check the current element\n if ($currentElement.matches(selector)) {\n return $currentElement\n }\n\n // Check all previous siblings\n let $sibling = $currentElement.previousElementSibling\n while ($sibling) {\n // Check if the sibling itself is a heading\n if ($sibling.matches(selector)) {\n return $sibling\n }\n $sibling = $sibling.previousElementSibling\n }\n\n // If no match found in siblings, move up to parent\n $currentElement = $currentElement.parentElement\n }\n}\n"],"names":["removeAttributeValue","$element","attr","value","re","m","getAttribute","removeAttribute","RegExp","match","length","setAttribute","replace","addAttributeValue","test","getNextSibling","selector","HTMLElement","$sibling","nextElementSibling","matches","getPreviousSibling","previousElementSibling","findNearestMatchingElement","$currentElement","parentElement"],"mappings":";;;;;;EAAA;EACA;EACA;EACA;EACA;EACO,SAASA,oBAAoBA,CAACC,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE;IAC1D,IAAIC,EAAE,EAAEC,CAAC;EACT,EAAA,IAAIJ,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,EAAE;MAC/B,IAAID,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,KAAKC,KAAK,EAAE;EACzCF,MAAAA,QAAQ,CAACM,eAAe,CAACL,IAAI,CAAC;EAChC,KAAC,MAAM;EACLE,MAAAA,EAAE,GAAG,IAAII,MAAM,CAAC,CAAUL,OAAAA,EAAAA,KAAK,SAAS,CAAC;QACzCE,CAAC,GAAGJ,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,CAACO,KAAK,CAACL,EAAE,CAAC;EACzC,MAAA,IAAIC,CAAC,IAAIA,CAAC,CAACK,MAAM,KAAK,CAAC,EAAE;EACvBT,QAAAA,QAAQ,CAACU,YAAY,CACnBT,IAAI,EACJD,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,CAACU,OAAO,CAACR,EAAE,EAAEC,CAAC,CAAC,CAAC,CAAC,IAAIA,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CACjE,CAAC;EACH;EACF;EACF;EACF;;EAEA;EACA;EACA;EACA;EACA;EACO,SAASQ,iBAAiBA,CAACZ,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE;EACvD,EAAA,IAAIC,EAAE;EACN,EAAA,IAAI,CAACH,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,EAAE;EAChCD,IAAAA,QAAQ,CAACU,YAAY,CAACT,IAAI,EAAEC,KAAK,CAAC;EACpC,GAAC,MAAM;E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AAE,OAAOE,QAAQ;MAC/CA,QAAQ,GAAGA,QAAQ,CAACI,sBAAsB;EAC5C;EACF;;EAEA;EACA;EACA;EACA;EACO,SAASC,0BAA0BA,CAACtB,QAAQ,EAAEe,QAAQ,EAAE;EAC7D;IACA,IAAI,CAACf,QAAQ,IAAI,EAAEA,QAAQ,YAAYgB,WAAW,CAAC,IAAI,CAACD,QAAQ,EAAE;EAChE,IAAA;EACF;;EAEA;IACA,IAAIQ,eAAe,GAAGvB,QAAQ;EAE9B,EAAA,OAAOuB,eAAe,EAAE;EACtB;EACA,IAAA,IAAIA,eAAe,CAACJ,OAAO,CAACJ,QAAQ,CAAC,EAAE;EACrC,MAAA,OAAOQ,eAAe;EACxB;;EAEA;EACA,IAAA,IAAIN,QAAQ,GAAGM,eAAe,CAACF,sBAAsB;EACrD,IAAA,OAAOJ,QAAQ,EAAE;EACf;EACA,MAAA,IAAIA,QAAQ,CAACE,OAAO,CAACJ,QAAQ,CAAC,EAAE;EAC9B,QAAA,OAAOE,QAAQ;EACjB;QACAA,QAAQ,GAAGA,QAAQ,CAACI,sBAAsB;EAC5C;;EAEA;MACAE,eAAe,GAAGA,eAAe,CAACC,aAAa;EACjD;EACF;;;;;;;;;;;;"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @param {Element} $element - Element to remove attribute value from
3
+ * @param {string} attr - Attribute name
4
+ * @param {string} value - Attribute value
5
+ */
6
+ function removeAttributeValue($element, attr, value) {
7
+ let re, m;
8
+ if ($element.getAttribute(attr)) {
9
+ if ($element.getAttribute(attr) === value) {
10
+ $element.removeAttribute(attr);
11
+ } else {
12
+ re = new RegExp(`(^|\\s)${value}(\\s|$)`);
13
+ m = $element.getAttribute(attr).match(re);
14
+ if (m && m.length === 3) {
15
+ $element.setAttribute(attr, $element.getAttribute(attr).replace(re, m[1] && m[2] ? ' ' : ''));
16
+ }
17
+ }
18
+ }
19
+ }
20
+
21
+ /**
22
+ * @param {Element} $element - Element to add attribute value to
23
+ * @param {string} attr - Attribute name
24
+ * @param {string} value - Attribute value
25
+ */
26
+ function addAttributeValue($element, attr, value) {
27
+ let re;
28
+ if (!$element.getAttribute(attr)) {
29
+ $element.setAttribute(attr, value);
30
+ } else {
31
+ re = new RegExp(`(^|\\s)${value}(\\s|$)`);
32
+ if (!re.test($element.getAttribute(attr))) {
33
+ $element.setAttribute(attr, `${$element.getAttribute(attr)} ${value}`);
34
+ }
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Find an elements next sibling
40
+ *
41
+ * Utility function to find an elements next sibling matching the provided
42
+ * selector.
43
+ *
44
+ * @param {Element | null} $element - Element to find siblings for
45
+ * @param {string} [selector] - selector for required sibling
46
+ */
47
+ function getNextSibling($element, selector) {
48
+ if (!$element || !($element instanceof HTMLElement)) {
49
+ return;
50
+ }
51
+
52
+ // Get the next sibling element
53
+ let $sibling = $element.nextElementSibling;
54
+
55
+ // If there's no selector, return the first sibling
56
+ if (!selector) return $sibling;
57
+
58
+ // If the sibling matches our selector, use it
59
+ // If not, jump to the next sibling and continue the loop
60
+ while ($sibling) {
61
+ if ($sibling.matches(selector)) return $sibling;
62
+ $sibling = $sibling.nextElementSibling;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Find an elements preceding sibling
68
+ *
69
+ * Utility function to find an elements previous sibling matching the provided
70
+ * selector.
71
+ *
72
+ * @param {Element | null} $element - Element to find siblings for
73
+ * @param {string} [selector] - selector for required sibling
74
+ */
75
+ function getPreviousSibling($element, selector) {
76
+ if (!$element || !($element instanceof HTMLElement)) {
77
+ return;
78
+ }
79
+
80
+ // Get the previous sibling element
81
+ let $sibling = $element.previousElementSibling;
82
+
83
+ // If there's no selector, return the first sibling
84
+ if (!selector) return $sibling;
85
+
86
+ // If the sibling matches our selector, use it
87
+ // If not, jump to the next sibling and continue the loop
88
+ while ($sibling) {
89
+ if ($sibling.matches(selector)) return $sibling;
90
+ $sibling = $sibling.previousElementSibling;
91
+ }
92
+ }
93
+
94
+ /**
95
+ * @param {Element | null} $element
96
+ * @param {string} [selector]
97
+ */
98
+ function findNearestMatchingElement($element, selector) {
99
+ // If no element or selector is provided, return
100
+ if (!$element || !($element instanceof HTMLElement) || !selector) {
101
+ return;
102
+ }
103
+
104
+ // Start with the current element
105
+ let $currentElement = $element;
106
+ while ($currentElement) {
107
+ // First check the current element
108
+ if ($currentElement.matches(selector)) {
109
+ return $currentElement;
110
+ }
111
+
112
+ // Check all previous siblings
113
+ let $sibling = $currentElement.previousElementSibling;
114
+ while ($sibling) {
115
+ // Check if the sibling itself is a heading
116
+ if ($sibling.matches(selector)) {
117
+ return $sibling;
118
+ }
119
+ $sibling = $sibling.previousElementSibling;
120
+ }
121
+
122
+ // If no match found in siblings, move up to parent
123
+ $currentElement = $currentElement.parentElement;
124
+ }
125
+ }
126
+
127
+ export { addAttributeValue, findNearestMatchingElement, getNextSibling, getPreviousSibling, removeAttributeValue };
128
+ //# sourceMappingURL=helpers.bundle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.bundle.mjs","sources":["../../src/moj/helpers.mjs"],"sourcesContent":["/**\n * @param {Element} $element - Element to remove attribute value from\n * @param {string} attr - Attribute name\n * @param {string} value - Attribute value\n */\nexport function removeAttributeValue($element, attr, value) {\n let re, m\n if ($element.getAttribute(attr)) {\n if ($element.getAttribute(attr) === value) {\n $element.removeAttribute(attr)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n m = $element.getAttribute(attr).match(re)\n if (m && m.length === 3) {\n $element.setAttribute(\n attr,\n $element.getAttribute(attr).replace(re, m[1] && m[2] ? ' ' : '')\n )\n }\n }\n }\n}\n\n/**\n * @param {Element} $element - Element to add attribute value to\n * @param {string} attr - Attribute name\n * @param {string} value - Attribute value\n */\nexport function addAttributeValue($element, attr, value) {\n let re\n if (!$element.getAttribute(attr)) {\n $element.setAttribute(attr, value)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n if (!re.test($element.getAttribute(attr))) {\n $element.setAttribute(attr, `${$element.getAttribute(attr)} ${value}`)\n }\n }\n}\n\n/**\n * Find an elements next sibling\n *\n * Utility function to find an elements next sibling matching the provided\n * selector.\n *\n * @param {Element | null} $element - Element to find siblings for\n * @param {string} [selector] - selector for required sibling\n */\nexport function getNextSibling($element, selector) {\n if (!$element || !($element instanceof HTMLElement)) {\n return\n }\n\n // Get the next sibling element\n let $sibling = $element.nextElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.nextElementSibling\n }\n}\n\n/**\n * Find an elements preceding sibling\n *\n * Utility function to find an elements previous sibling matching the provided\n * selector.\n *\n * @param {Element | null} $element - Element to find siblings for\n * @param {string} [selector] - selector for required sibling\n */\nexport function getPreviousSibling($element, selector) {\n if (!$element || !($element instanceof HTMLElement)) {\n return\n }\n\n // Get the previous sibling element\n let $sibling = $element.previousElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.previousElementSibling\n }\n}\n\n/**\n * @param {Element | null} $element\n * @param {string} [selector]\n */\nexport function findNearestMatchingElement($element, selector) {\n // If no element or selector is provided, return\n if (!$element || !($element instanceof HTMLElement) || !selector) {\n return\n }\n\n // Start with the current element\n let $currentElement = $element\n\n while ($currentElement) {\n // First check the current element\n if ($currentElement.matches(selector)) {\n return $currentElement\n }\n\n // Check all previous siblings\n let $sibling = $currentElement.previousElementSibling\n while ($sibling) {\n // Check if the sibling itself is a heading\n if ($sibling.matches(selector)) {\n return $sibling\n }\n $sibling = $sibling.previousElementSibling\n }\n\n // If no match found in siblings, move up to parent\n $currentElement = $currentElement.parentElement\n }\n}\n"],"names":["removeAttributeValue","$element","attr","value","re","m","getAttribute","removeAttribute","RegExp","match","length","setAttribute","replace","addAttributeValue","test","getNextSibling","selector","HTMLElement","$sibling","nextElementSibling","matches","getPreviousSibling","previousElementSibling","findNearestMatchingElement","$currentElement","parentElement"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAoBA,CAACC,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE;EAC1D,IAAIC,EAAE,EAAEC,CAAC;AACT,EAAA,IAAIJ,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,EAAE;IAC/B,IAAID,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,KAAKC,KAAK,EAAE;AACzCF,MAAAA,QAAQ,CAACM,eAAe,CAACL,IAAI,CAAC;AAChC,KAAC,MAAM;AACLE,MAAAA,EAAE,GAAG,IAAII,MAAM,CAAC,CAAUL,OAAAA,EAAAA,KAAK,SAAS,CAAC;MACzCE,CAAC,GAAGJ,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,CAACO,KAAK,CAACL,EAAE,CAAC;AACzC,MAAA,IAAIC,CAAC,IAAIA,CAAC,CAACK,MAAM,KAAK,CAAC,EAAE;AACvBT,QAAAA,QAAQ,CAACU,YAAY,CACnBT,IAAI,EACJD,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,CAACU,OAAO,CAACR,EAAE,EAAEC,CAAC,CAAC,CAAC,CAAC,IAAIA,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CACjE,CAAC;AACH;AACF;AACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASQ,iBAAiBA,CAACZ,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE;AACvD,EAAA,IAAIC,EAAE;AACN,EAAA,IAAI,CAACH,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,EAAE;AAChCD,IAAAA,QAAQ,CAACU,YAAY,CAACT,IAAI,EAAEC,KAAK,CAAC;AACpC,GAAC,MAAM;AACLC,IAAAA,EAAE,GAAG,IAAII,MAAM,CAAC,C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AAQ,CAACI,sBAAsB;AAC5C;AACF;;AAEA;AACA;AACA;AACA;AACO,SAASC,0BAA0BA,CAACtB,QAAQ,EAAEe,QAAQ,EAAE;AAC7D;EACA,IAAI,CAACf,QAAQ,IAAI,EAAEA,QAAQ,YAAYgB,WAAW,CAAC,IAAI,CAACD,QAAQ,EAAE;AAChE,IAAA;AACF;;AAEA;EACA,IAAIQ,eAAe,GAAGvB,QAAQ;AAE9B,EAAA,OAAOuB,eAAe,EAAE;AACtB;AACA,IAAA,IAAIA,eAAe,CAACJ,OAAO,CAACJ,QAAQ,CAAC,EAAE;AACrC,MAAA,OAAOQ,eAAe;AACxB;;AAEA;AACA,IAAA,IAAIN,QAAQ,GAAGM,eAAe,CAACF,sBAAsB;AACrD,IAAA,OAAOJ,QAAQ,EAAE;AACf;AACA,MAAA,IAAIA,QAAQ,CAACE,OAAO,CAACJ,QAAQ,CAAC,EAAE;AAC9B,QAAA,OAAOE,QAAQ;AACjB;MACAA,QAAQ,GAAGA,QAAQ,CAACI,sBAAsB;AAC5C;;AAEA;IACAE,eAAe,GAAGA,eAAe,CAACC,aAAa;AACjD;AACF;;;;"}
package/moj/helpers.mjs CHANGED
@@ -1,24 +1,37 @@
1
- function dragAndDropSupported() {
2
- const div = document.createElement('div');
3
- return typeof div.ondrop !== 'undefined'
4
- }
5
-
6
- function formDataSupported() {
7
- return typeof FormData === 'function'
8
- }
9
-
10
- function fileApiSupported() {
11
- const input = document.createElement('input');
12
- input.type = 'file';
13
- return typeof input.files !== 'undefined'
1
+ /**
2
+ * @param {Element} $element - Element to remove attribute value from
3
+ * @param {string} attr - Attribute name
4
+ * @param {string} value - Attribute value
5
+ */
6
+ function removeAttributeValue($element, attr, value) {
7
+ let re, m;
8
+ if ($element.getAttribute(attr)) {
9
+ if ($element.getAttribute(attr) === value) {
10
+ $element.removeAttribute(attr);
11
+ } else {
12
+ re = new RegExp(`(^|\\s)${value}(\\s|$)`);
13
+ m = $element.getAttribute(attr).match(re);
14
+ if (m && m.length === 3) {
15
+ $element.setAttribute(attr, $element.getAttribute(attr).replace(re, m[1] && m[2] ? ' ' : ''));
16
+ }
17
+ }
18
+ }
14
19
  }
15
20
 
16
- function nodeListForEach(nodes, callback) {
17
- if (window.NodeList.prototype.forEach) {
18
- return nodes.forEach(callback)
19
- }
20
- for (let i = 0; i < nodes.length; i++) {
21
- callback.call(window, nodes[i], i, nodes);
21
+ /**
22
+ * @param {Element} $element - Element to add attribute value to
23
+ * @param {string} attr - Attribute name
24
+ * @param {string} value - Attribute value
25
+ */
26
+ function addAttributeValue($element, attr, value) {
27
+ let re;
28
+ if (!$element.getAttribute(attr)) {
29
+ $element.setAttribute(attr, value);
30
+ } else {
31
+ re = new RegExp(`(^|\\s)${value}(\\s|$)`);
32
+ if (!re.test($element.getAttribute(attr))) {
33
+ $element.setAttribute(attr, `${$element.getAttribute(attr)} ${value}`);
34
+ }
22
35
  }
23
36
  }
24
37
 
@@ -28,33 +41,41 @@ function nodeListForEach(nodes, callback) {
28
41
  * Utility function to find an elements previous sibling matching the provided
29
42
  * selector.
30
43
  *
31
- * @param {HTMLElement} $element - Element to find siblings for
32
- * @param {string} selector - selector for required sibling
44
+ * @param {Element | null} $element - Element to find siblings for
45
+ * @param {string} [selector] - selector for required sibling
33
46
  */
34
47
  function getPreviousSibling($element, selector) {
35
- if (!$element) return
48
+ if (!$element || !($element instanceof HTMLElement)) {
49
+ return;
50
+ }
51
+
36
52
  // Get the previous sibling element
37
53
  let $sibling = $element.previousElementSibling;
38
54
 
39
55
  // If the sibling matches our selector, use it
40
56
  // If not, jump to the next sibling and continue the loop
41
57
  while ($sibling) {
42
- if ($sibling.matches(selector)) return $sibling
58
+ if ($sibling.matches(selector)) return $sibling;
43
59
  $sibling = $sibling.previousElementSibling;
44
60
  }
45
61
  }
46
62
 
63
+ /**
64
+ * @param {Element | null} $element
65
+ * @param {string} [selector]
66
+ */
47
67
  function findNearestMatchingElement($element, selector) {
48
- // If no element or selector is provided, return null
49
- if (!$element) return
68
+ // If no element or selector is provided, return
69
+ if (!$element || !($element instanceof HTMLElement) || false) {
70
+ return;
71
+ }
50
72
 
51
73
  // Start with the current element
52
74
  let $currentElement = $element;
53
-
54
75
  while ($currentElement) {
55
76
  // First check the current element
56
77
  if ($currentElement.matches(selector)) {
57
- return $currentElement
78
+ return $currentElement;
58
79
  }
59
80
 
60
81
  // Check all previous siblings
@@ -62,7 +83,7 @@ function findNearestMatchingElement($element, selector) {
62
83
  while ($sibling) {
63
84
  // Check if the sibling itself is a heading
64
85
  if ($sibling.matches(selector)) {
65
- return $sibling
86
+ return $sibling;
66
87
  }
67
88
  $sibling = $sibling.previousElementSibling;
68
89
  }
@@ -72,53 +93,5 @@ function findNearestMatchingElement($element, selector) {
72
93
  }
73
94
  }
74
95
 
75
- /**
76
- * Move focus to element
77
- *
78
- * Sets tabindex to -1 to make the element programmatically focusable,
79
- * but removes it on blur as the element doesn't need to be focused again.
80
- *
81
- * @param {HTMLElement} $element - HTML element
82
- * @param {object} [options] - Handler options
83
- * @param {function(this: HTMLElement): void} [options.onBeforeFocus] - Callback before focus
84
- * @param {function(this: HTMLElement): void} [options.onBlur] - Callback on blur
85
- */
86
- function setFocus($element, options = {}) {
87
- const isFocusable = $element.getAttribute('tabindex');
88
-
89
- if (!isFocusable) {
90
- $element.setAttribute('tabindex', '-1');
91
- }
92
-
93
- /**
94
- * Handle element focus
95
- */
96
- function onFocus() {
97
- $element.addEventListener('blur', onBlur, { once: true });
98
- }
99
-
100
- /**
101
- * Handle element blur
102
- */
103
- function onBlur() {
104
- if (options.onBlur) {
105
- options.onBlur.call($element);
106
- }
107
-
108
- if (!isFocusable) {
109
- $element.removeAttribute('tabindex');
110
- }
111
- }
112
-
113
- // Add listener to reset element on blur, after focus
114
- $element.addEventListener('focus', onFocus, { once: true });
115
-
116
- // Focus element
117
- if (options.onBeforeFocus) {
118
- options.onBeforeFocus.call($element);
119
- }
120
- $element.focus();
121
- }
122
-
123
- export { dragAndDropSupported, fileApiSupported, findNearestMatchingElement, formDataSupported, getPreviousSibling, nodeListForEach, setFocus };
96
+ export { addAttributeValue, findNearestMatchingElement, getPreviousSibling, removeAttributeValue };
124
97
  //# sourceMappingURL=helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","sources":["../../src/moj/helpers.mjs"],"sourcesContent":["export function removeAttributeValue(el, attr, value) {\n let re, m\n if (el.getAttribute(attr)) {\n if (el.getAttribute(attr) === value) {\n el.removeAttribute(attr)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n m = el.getAttribute(attr).match(re)\n if (m && m.length === 3) {\n el.setAttribute(\n attr,\n el.getAttribute(attr).replace(re, m[1] && m[2] ? ' ' : '')\n )\n }\n }\n }\n}\n\nexport function addAttributeValue(el, attr, value) {\n let re\n if (!el.getAttribute(attr)) {\n el.setAttribute(attr, value)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n if (!re.test(el.getAttribute(attr))) {\n el.setAttribute(attr, `${el.getAttribute(attr)} ${value}`)\n }\n }\n}\n\nexport function dragAndDropSupported() {\n const div = document.createElement('div')\n return typeof div.ondrop !== 'undefined'\n}\n\nexport function formDataSupported() {\n return typeof FormData === 'function'\n}\n\nexport function fileApiSupported() {\n const input = document.createElement('input')\n input.type = 'file'\n return typeof input.files !== 'undefined'\n}\n\nexport function nodeListForEach(nodes, callback) {\n if (window.NodeList.prototype.forEach) {\n return nodes.forEach(callback)\n }\n for (let i = 0; i < nodes.length; i++) {\n callback.call(window, nodes[i], i, nodes)\n }\n}\n\n/**\n * Find an elements next sibling\n *\n * Utility function to find an elements next sibling matching the provided\n * selector.\n *\n * @param {HTMLElement} $element - Element to find siblings for\n * @param {string} selector - selector for required sibling\n */\nexport function getNextSibling($element, selector) {\n if (!$element) return\n // Get the next sibling element\n let $sibling = $element.nextElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.nextElementSibling\n }\n}\n\n/**\n * Find an elements preceding sibling\n *\n * Utility function to find an elements previous sibling matching the provided\n * selector.\n *\n * @param {HTMLElement} $element - Element to find siblings for\n * @param {string} selector - selector for required sibling\n */\nexport function getPreviousSibling($element, selector) {\n if (!$element) return\n // Get the previous sibling element\n let $sibling = $element.previousElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.previousElementSibling\n }\n}\n\nexport function findNearestMatchingElement($element, selector) {\n // If no element or selector is provided, return null\n if (!$element) return\n if (!selector) return\n\n // Start with the current element\n let $currentElement = $element\n\n while ($currentElement) {\n // First check the current element\n if ($currentElement.matches(selector)) {\n return $currentElement\n }\n\n // Check all previous siblings\n let $sibling = $currentElement.previousElementSibling\n while ($sibling) {\n // Check if the sibling itself is a heading\n if ($sibling.matches(selector)) {\n return $sibling\n }\n $sibling = $sibling.previousElementSibling\n }\n\n // If no match found in siblings, move up to parent\n $currentElement = $currentElement.parentElement\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @param {HTMLElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: HTMLElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: HTMLElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n if (options.onBlur) {\n options.onBlur.call($element)\n }\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n if (options.onBeforeFocus) {\n options.onBeforeFocus.call($element)\n }\n $element.focus()\n}\n"],"names":[],"mappings":"AA8BO,SAAS,oBAAoB,GAAG;AACvC,EAAE,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK;AAC1C,EAAE,OAAO,OAAO,GAAG,CAAC,MAAM,KAAK;AAC/B;;AAEO,SAAS,iBAAiB,GAAG;AACpC,EAAE,OAAO,OAAO,QAAQ,KAAK;AAC7B;;AAEO,SAAS,gBAAgB,GAAG;AACnC,EAAE,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO;AAC9C,EAAE,KAAK,CAAC,IAAI,GAAG;AACf,EAAE,OAAO,OAAO,KAAK,CAAC,KAAK,KAAK;AAChC;;AAEO,SAAS,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE;AACjD,EAAE,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE;AACzC,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ;AACjC;AACA,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACzC,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK;AAC5C;AACA;;AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE;AACvD,EAAE,IAAI,CAAC,QAAQ,EAAE;AACjB;AACA,EAAE,IAAI,QAAQ,GAAG,QAAQ,CAAC;;AAK1B;AACA;AACA,EAAE,OAAO,QAAQ,EAAE;AACnB,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO;AAC3C,IAA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;;AAEA;AACA,EAAE,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;;AAE5D;AACA,EAAE,IAAI,OAAO,CAAC,aAAa,EAAE;AAC7B,IAAI,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ;AACvC;AACA,EAAE,QAAQ,CAAC,KAAK;AAChB;;;;"}
1
+ {"version":3,"file":"helpers.mjs","sources":["../../src/moj/helpers.mjs"],"sourcesContent":["/**\n * @param {Element} $element - Element to remove attribute value from\n * @param {string} attr - Attribute name\n * @param {string} value - Attribute value\n */\nexport function removeAttributeValue($element, attr, value) {\n let re, m\n if ($element.getAttribute(attr)) {\n if ($element.getAttribute(attr) === value) {\n $element.removeAttribute(attr)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n m = $element.getAttribute(attr).match(re)\n if (m && m.length === 3) {\n $element.setAttribute(\n attr,\n $element.getAttribute(attr).replace(re, m[1] && m[2] ? ' ' : '')\n )\n }\n }\n }\n}\n\n/**\n * @param {Element} $element - Element to add attribute value to\n * @param {string} attr - Attribute name\n * @param {string} value - Attribute value\n */\nexport function addAttributeValue($element, attr, value) {\n let re\n if (!$element.getAttribute(attr)) {\n $element.setAttribute(attr, value)\n } else {\n re = new RegExp(`(^|\\\\s)${value}(\\\\s|$)`)\n if (!re.test($element.getAttribute(attr))) {\n $element.setAttribute(attr, `${$element.getAttribute(attr)} ${value}`)\n }\n }\n}\n\n/**\n * Find an elements next sibling\n *\n * Utility function to find an elements next sibling matching the provided\n * selector.\n *\n * @param {Element | null} $element - Element to find siblings for\n * @param {string} [selector] - selector for required sibling\n */\nexport function getNextSibling($element, selector) {\n if (!$element || !($element instanceof HTMLElement)) {\n return\n }\n\n // Get the next sibling element\n let $sibling = $element.nextElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.nextElementSibling\n }\n}\n\n/**\n * Find an elements preceding sibling\n *\n * Utility function to find an elements previous sibling matching the provided\n * selector.\n *\n * @param {Element | null} $element - Element to find siblings for\n * @param {string} [selector] - selector for required sibling\n */\nexport function getPreviousSibling($element, selector) {\n if (!$element || !($element instanceof HTMLElement)) {\n return\n }\n\n // Get the previous sibling element\n let $sibling = $element.previousElementSibling\n\n // If there's no selector, return the first sibling\n if (!selector) return $sibling\n\n // If the sibling matches our selector, use it\n // If not, jump to the next sibling and continue the loop\n while ($sibling) {\n if ($sibling.matches(selector)) return $sibling\n $sibling = $sibling.previousElementSibling\n }\n}\n\n/**\n * @param {Element | null} $element\n * @param {string} [selector]\n */\nexport function findNearestMatchingElement($element, selector) {\n // If no element or selector is provided, return\n if (!$element || !($element instanceof HTMLElement) || !selector) {\n return\n }\n\n // Start with the current element\n let $currentElement = $element\n\n while ($currentElement) {\n // First check the current element\n if ($currentElement.matches(selector)) {\n return $currentElement\n }\n\n // Check all previous siblings\n let $sibling = $currentElement.previousElementSibling\n while ($sibling) {\n // Check if the sibling itself is a heading\n if ($sibling.matches(selector)) {\n return $sibling\n }\n $sibling = $sibling.previousElementSibling\n }\n\n // If no match found in siblings, move up to parent\n $currentElement = $currentElement.parentElement\n }\n}\n"],"names":["removeAttributeValue","$element","attr","value","re","m","getAttribute","removeAttribute","RegExp","match","length","setAttribute","replace","addAttributeValue","test","getPreviousSibling","selector","HTMLElement","$sibling","previousElementSibling","matches","findNearestMatchingElement","$currentElement","parentElement"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAoBA,CAACC,QAAQ,EAAEC,IAAI,EAAEC,KAAK,EAAE;EAC1D,IAAIC,EAAE,EAAEC,CAAC;AACT,EAAA,IAAIJ,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,EAAE;IAC/B,IAAID,QAAQ,CAACK,YAAY,CAACJ,IAAI,CAAC,KAAKC,KAAK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CAACd,QAAQ,EAAEe,QAAQ,EAAE;EACrD,IAAI,CAACf,QAAQ,IAAI,EAAEA,QAAQ,YAAYgB,WAAW,CAAC,EAAE;AACnD,IAAA;AACF;;AAEA;AACA,EAAA,IAAIC,QAAQ,GAAGjB,QAAQ,CAACkB,sBAAsB;;AAK9C;AACA;AACA,EAAA,OAAOD,QAAQ,EAAE;IACf,IAAIA,QAAQ,CAACE,OAAO,CAACJ,QAAQ,CAAC,EAAE,OAAOE,QAAQ;IAC/CA,QAAQ,GAAGA,QAAQ,CAACC,sBAAsB;AAC5C;AACF;;AAEA;AACA;AACA;AACA;AACO,SAASE,0BAA0BA,CAACpB,QAAQ,EAAEe,QAAQ,EAAE;AAC7D;EACA,IAAI,CAACf,QAAQ,IAAI,EAAEA,QAAQ,YAAYgB,WAAW,CAAC,IAAI,KAAS,EAAE;AAChE,IAAA;AACF;;AAEA;EACA,IAAIK,eAAe,GAAGrB,QAAQ;AAE9B,EAAA,OAAOqB,eAAe,EAAE;AACtB;AACA,IAAA,IAAIA,eAAe,CAACF,OAAO,CAACJ,QAAQ,CAAC,EAAE;AACrC,MAAA,OAAOM,eAAe;AACxB;;AAEA;AACA,IAAA,IAAIJ,QAAQ,GAAGI,eAAe,CAACH,sBAAsB;AACrD,IAAA,OAAOD,QAAQ,EAAE;AACf;AACA,MAAA,IAAIA,QAAQ,CAACE,OAAO,CAACJ,QAAQ,CAAC,EAAE;AAC9B,QAAA,OAAOE,QAAQ;AACjB;MACAA,QAAQ,GAAGA,QAAQ,CAACC,sBAAsB;AAC5C;;AAEA;IACAG,eAAe,GAAGA,eAAe,CAACC,aAAa;AACjD;AACF;;;;"}
package/moj/init.js CHANGED
@@ -1,5 +1,14 @@
1
- if (window.GOVUKPrototypeKit && window.GOVUKPrototypeKit.documentReady) {
2
- window.GOVUKPrototypeKit.documentReady(function () {
1
+ import * as MOJFrontend from '../moj/moj-frontend.min.js'
2
+
3
+ // Maintain window global for compatibility
4
+ window.MOJFrontend = MOJFrontend
5
+
6
+ if (
7
+ window.GOVUKPrototypeKit &&
8
+ window.GOVUKPrototypeKit.documentReady &&
9
+ window.GOVUKPrototypeKit.majorVersion >= 13
10
+ ) {
11
+ window.GOVUKPrototypeKit.documentReady(() => {
3
12
  window.MOJFrontend.initAll()
4
13
  })
5
14
  }