@ons/design-system 68.0.0 → 70.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 (198) hide show
  1. package/README.md +6 -0
  2. package/components/access-code/_macro.njk +1 -1
  3. package/components/access-code/_macro.spec.js +2 -10
  4. package/components/access-code/access-code.dom.js +1 -1
  5. package/components/access-code/access-code.spec.js +2 -2
  6. package/components/access-code/example-access-code-error.njk +9 -14
  7. package/components/access-code/example-access-code.njk +3 -5
  8. package/components/accordion/accordion.js +4 -4
  9. package/components/address-input/_macro.spec.js +3 -15
  10. package/components/address-input/autosuggest.address.dom.js +1 -1
  11. package/components/address-input/autosuggest.address.js +3 -2
  12. package/components/address-input/autosuggest.address.setter.js +3 -3
  13. package/components/address-input/autosuggest.address.spec.js +66 -69
  14. package/components/address-output/_macro.spec.js +6 -30
  15. package/components/autosuggest/_autosuggest.scss +1 -1
  16. package/components/autosuggest/autosuggest.dom.js +1 -1
  17. package/components/autosuggest/autosuggest.helpers.js +1 -1
  18. package/components/back-to-top/_back-to-top.scss +34 -0
  19. package/components/back-to-top/_macro.njk +17 -0
  20. package/components/back-to-top/_macro.spec.js +60 -0
  21. package/components/back-to-top/back-to-top.dom.js +12 -0
  22. package/components/back-to-top/back-to-top.js +58 -0
  23. package/components/back-to-top/back-to-top.spec.js +117 -0
  24. package/components/back-to-top/example-back-to-top.njk +37 -0
  25. package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
  26. package/components/browser-banner/_macro.spec.js +4 -12
  27. package/components/button/_macro.njk +6 -6
  28. package/components/button/_macro.spec.js +1 -5
  29. package/components/button/button.js +7 -8
  30. package/components/button/button.spec.js +17 -39
  31. package/components/call-to-action/_macro.spec.js +2 -6
  32. package/components/card/_macro.njk +25 -25
  33. package/components/card/_macro.spec.js +10 -34
  34. package/components/char-check-limit/_macro.njk +1 -1
  35. package/components/char-check-limit/_macro.spec.js +3 -7
  36. package/components/char-check-limit/character-check.spec.js +24 -20
  37. package/components/checkboxes/_checkbox-macro.njk +1 -1
  38. package/components/checkboxes/_checkbox.scss +0 -3
  39. package/components/checkboxes/_macro.spec.js +1 -5
  40. package/components/checkboxes/checkbox-with-autoselect.js +3 -3
  41. package/components/checkboxes/checkbox-with-fieldset.js +2 -2
  42. package/components/checkboxes/checkboxes-with-reveal.js +4 -2
  43. package/components/checkboxes/checkboxes.dom.js +2 -2
  44. package/components/checkboxes/checkboxes.spec.js +13 -13
  45. package/components/content-pagination/_macro.spec.js +2 -2
  46. package/components/cookies-banner/cookies-banner.dom.js +1 -1
  47. package/components/cookies-banner/cookies-banner.js +1 -1
  48. package/components/cookies-banner/cookies-banner.spec.js +7 -7
  49. package/components/date-input/_macro.njk +71 -69
  50. package/components/date-input/_macro.spec.js +20 -5
  51. package/components/date-input/example-date-input-double-field.njk +27 -0
  52. package/components/date-input/example-date-input-single-field.njk +18 -0
  53. package/components/details/details.spec.js +12 -12
  54. package/components/details/example-details-with-warning.njk +5 -7
  55. package/components/document-list/_macro.spec.js +9 -27
  56. package/components/document-list/document-list.scss +1 -1
  57. package/components/document-list/example-document-list-downloads.njk +3 -3
  58. package/components/document-list/example-document-list-search-result-featured.njk +1 -1
  59. package/components/document-list/example-document-list-search-results.njk +3 -3
  60. package/components/download-resources/download-resources.js +54 -54
  61. package/components/download-resources/download-resources.spec.js +3 -1
  62. package/components/duration/_macro.njk +52 -48
  63. package/components/duration/_macro.spec.js +112 -4
  64. package/components/duration/example-duration-error-for-single-field.njk +1 -1
  65. package/components/duration/example-duration-single-field.njk +24 -0
  66. package/components/error/_macro.njk +1 -1
  67. package/components/error/_macro.spec.js +2 -6
  68. package/components/feedback/_macro.njk +1 -1
  69. package/components/feedback/_macro.spec.js +4 -20
  70. package/components/field/_macro.spec.js +1 -3
  71. package/components/fieldset/_fieldset.scss +1 -2
  72. package/components/fieldset/_macro.spec.js +3 -9
  73. package/components/footer/_footer.scss +8 -0
  74. package/components/footer/_macro.njk +8 -7
  75. package/components/footer/_macro.spec.js +14 -2
  76. package/components/header/_macro.njk +1 -1
  77. package/components/header/_macro.spec.js +1 -1
  78. package/components/helpers/grid.njk +15 -15
  79. package/components/icon/_macro.njk +15 -11
  80. package/components/icon/_macro.spec.js +8 -16
  81. package/components/image/_macro.spec.js +1 -5
  82. package/components/input/_macro.njk +22 -23
  83. package/components/input/_macro.spec.js +1 -1
  84. package/components/input/character-check.dom.js +1 -1
  85. package/components/input/input.spec.js +1 -4
  86. package/components/label/_label.scss +1 -0
  87. package/components/label/_macro.njk +2 -2
  88. package/components/label/_macro.spec.js +4 -13
  89. package/components/list/_macro.spec.js +4 -12
  90. package/components/message/_macro.njk +17 -17
  91. package/components/message/_macro.spec.js +9 -33
  92. package/components/message-list/_macro.spec.js +7 -39
  93. package/components/metadata/_macro.njk +10 -10
  94. package/components/modal/_macro.spec.js +3 -9
  95. package/components/modal/modal.dom.js +1 -1
  96. package/components/modal/modal.spec.js +5 -5
  97. package/components/multiple-input-fields/_macro.njk +49 -0
  98. package/components/mutually-exclusive/_macro.spec.js +2 -10
  99. package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
  100. package/components/mutually-exclusive/mutually-exclusive.date.spec.js +9 -9
  101. package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
  102. package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +8 -8
  103. package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
  104. package/components/mutually-exclusive/mutually-exclusive.js +13 -13
  105. package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
  106. package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
  107. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
  108. package/components/navigation/navigation.spec.js +0 -2
  109. package/components/pagination/_macro.spec.js +11 -53
  110. package/components/panel/_macro.njk +17 -17
  111. package/components/panel/_macro.spec.js +25 -25
  112. package/components/panel/_panel.scss +10 -9
  113. package/components/panel/example-panel-bare.njk +3 -4
  114. package/components/panel/example-panel-with-announcement.njk +6 -10
  115. package/components/panel/example-panel-with-error-summary.njk +2 -2
  116. package/components/panel/example-panel-with-information.njk +0 -1
  117. package/components/panel/example-panel-with-success-message.njk +1 -1
  118. package/components/panel/example-panel-with-warning.njk +2 -3
  119. package/components/password/password.dom.js +1 -1
  120. package/components/phase-banner/_macro.spec.js +3 -9
  121. package/components/question/_macro.njk +1 -1
  122. package/components/question/_macro.spec.js +5 -19
  123. package/components/question/_question.scss +1 -4
  124. package/components/question/example-question-interviewer-note.njk +1 -1
  125. package/components/quote/_macro.spec.js +2 -10
  126. package/components/radios/clear-radios.js +3 -3
  127. package/components/radios/radio-with-fieldset.js +4 -4
  128. package/components/radios/radios.dom.js +1 -1
  129. package/components/radios/radios.spec.js +26 -26
  130. package/components/related-content/_macro.spec.js +2 -4
  131. package/components/related-content/_section-macro.spec.js +2 -8
  132. package/components/relationships/example-relationships-error.njk +16 -18
  133. package/components/relationships/relationships.dom.js +1 -1
  134. package/components/relationships/relationships.js +2 -2
  135. package/components/reply/_macro.spec.js +3 -3
  136. package/components/reply/reply.dom.js +1 -1
  137. package/components/reply/reply.spec.js +3 -3
  138. package/components/section-navigation/_macro.njk +12 -12
  139. package/components/section-navigation/_macro.spec.js +13 -21
  140. package/components/select/_macro.spec.js +6 -6
  141. package/components/share-page/_macro.spec.js +6 -14
  142. package/components/skip-to-content/_macro.spec.js +3 -11
  143. package/components/skip-to-content/skip-to-content.dom.js +1 -1
  144. package/components/skip-to-content/skip-to-content.js +1 -1
  145. package/components/skip-to-content/skip-to-content.spec.js +2 -2
  146. package/components/status/_macro.njk +2 -2
  147. package/components/status/_macro.spec.js +5 -9
  148. package/components/status/example-status-dead.njk +1 -1
  149. package/components/status/example-status-error.njk +1 -1
  150. package/components/status/example-status-pending.njk +1 -1
  151. package/components/status/example-status-small.njk +1 -1
  152. package/components/status/example-status-success.njk +1 -1
  153. package/components/summary/_macro.njk +7 -8
  154. package/components/summary/_macro.spec.js +27 -9
  155. package/components/table/_macro.spec.js +6 -10
  156. package/components/table/scrollable-table.dom.js +1 -1
  157. package/components/table/scrollable-table.js +1 -1
  158. package/components/table/sortable-table.js +4 -4
  159. package/components/table/table.spec.js +21 -17
  160. package/components/table-of-contents/_macro.njk +31 -31
  161. package/components/table-of-contents/_macro.spec.js +3 -11
  162. package/components/table-of-contents/toc.dom.js +1 -1
  163. package/components/table-of-contents/toc.spec.js +36 -32
  164. package/components/tabs/example-tabs-details.njk +1 -1
  165. package/components/tabs/tabs.dom.js +1 -1
  166. package/components/tabs/tabs.js +8 -8
  167. package/components/text-indent/_macro.spec.js +2 -6
  168. package/components/textarea/textarea.dom.js +1 -1
  169. package/components/textarea/textarea.spec.js +8 -8
  170. package/components/timeout-modal/_macro.spec.js +1 -3
  171. package/components/timeout-modal/timeout-modal.dom.js +1 -1
  172. package/components/timeout-modal/timeout-modal.spec.js +10 -10
  173. package/components/timeout-panel/_macro.njk +16 -17
  174. package/components/timeout-panel/_macro.spec.js +1 -1
  175. package/components/timeout-panel/timeout-panel.dom.js +1 -1
  176. package/components/timeout-panel/timeout-panel.spec.js +8 -8
  177. package/components/video/_macro.spec.js +1 -5
  178. package/components/video/video.dom.js +1 -1
  179. package/components/video/video.spec.js +16 -12
  180. package/css/main.css +1 -1
  181. package/favicons/safari-pinned-tab.svg +23 -23
  182. package/js/analytics.js +15 -14
  183. package/js/cookies-settings.dom.js +1 -1
  184. package/js/cookies-settings.spec.js +19 -19
  185. package/js/domready.js +1 -1
  186. package/js/fetch.js +1 -1
  187. package/js/inpagelink.js +3 -3
  188. package/js/main.js +1 -0
  189. package/js/print-button.js +1 -1
  190. package/js/timeout.js +1 -1
  191. package/package.json +2 -1
  192. package/scripts/main.es5.js +1 -1
  193. package/scripts/main.js +1 -1
  194. package/scss/base/_typography.scss +8 -2
  195. package/scss/main.scss +1 -0
  196. package/scss/overrides/hcm.scss +8 -1
  197. package/scss/vars/_colors.scss +2 -1
  198. package/components/date-field-input/_macro.njk +0 -86
@@ -145,10 +145,10 @@ describe('macro: section-navigation', () => {
145
145
  it('renders top level navigation items', () => {
146
146
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION));
147
147
 
148
- const itemLabels = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
148
+ const itemLabels = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.text().trim());
149
149
  expect(itemLabels).toEqual(['Results', 'Dashboard']);
150
150
 
151
- const itemLinks = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.attr('href'));
151
+ const itemLinks = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.attr('href'));
152
152
  expect(itemLinks).toEqual(['/results', '/results/dashboard']);
153
153
  });
154
154
 
@@ -173,11 +173,7 @@ describe('macro: section-navigation', () => {
173
173
  it('marks the current item with a class when `currentPath` is provided', () => {
174
174
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION));
175
175
 
176
- expect(
177
- $('.ons-section-nav__item--active')
178
- .text()
179
- .trim(),
180
- ).toBe('Results');
176
+ expect($('.ons-section-nav__item--active').text().trim()).toBe('Results');
181
177
  });
182
178
 
183
179
  it('marks the current item with a class when `tabQuery` is provided', () => {
@@ -189,11 +185,7 @@ describe('macro: section-navigation', () => {
189
185
  }),
190
186
  );
191
187
 
192
- expect(
193
- $('.ons-section-nav__item--active')
194
- .text()
195
- .trim(),
196
- ).toBe('Dashboard');
188
+ expect($('.ons-section-nav__item--active').text().trim()).toBe('Dashboard');
197
189
  });
198
190
 
199
191
  it('marks the current item with `aria-current` when `currentPath` is provided', () => {
@@ -226,12 +218,14 @@ describe('macro: section-navigation', () => {
226
218
  it('renders the expected anchor navigation items', () => {
227
219
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION_VERTICAL));
228
220
 
229
- const itemLabels = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node =>
221
+ const itemLabels = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
230
222
  node.text().trim(),
231
223
  );
232
224
  expect(itemLabels).toEqual(['Sub section 1', 'Sub section 2', 'Sub section 3']);
233
225
 
234
- const itemLinks = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node => node.attr('href'));
226
+ const itemLinks = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
227
+ node.attr('href'),
228
+ );
235
229
  expect(itemLinks).toEqual(['#sub-section-1', '#sub-section-2', '#sub-section-3']);
236
230
  });
237
231
  });
@@ -247,17 +241,15 @@ describe('macro: section-navigation', () => {
247
241
  it('renders itemsLists, anchors and heading for each section', () => {
248
242
  const $ = cheerio.load(renderComponent('section-navigation', EXAMPLE_SECTION_NAVIGATION_VERTICAL_WITH_SECTIONS));
249
243
 
250
- const anchors = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
244
+ const anchors = mapAll($('.ons-section-nav__sub-items .ons-section-nav__item .ons-section-nav__link'), (node) =>
245
+ node.text().trim(),
246
+ );
251
247
  expect(anchors).toEqual(['Sub section 1', 'Sub section 2', 'Sub section 3']);
252
248
 
253
- const itemLists = mapAll($('.ons-section-nav__item .ons-section-nav__link'), node => node.text().trim());
249
+ const itemLists = mapAll($('.ons-section-nav__item .ons-section-nav__link'), (node) => node.text().trim());
254
250
  expect(itemLists).toEqual(['Section 1', 'Section 2', 'Sub section 1', 'Sub section 2', 'Sub section 3', 'Section 3']);
255
251
 
256
- const headings = mapAll($('h3'), node =>
257
- $(node)
258
- .text()
259
- .trim(),
260
- );
252
+ const headings = mapAll($('h3'), (node) => $(node).text().trim());
261
253
  expect(headings).toEqual(['Section Title']);
262
254
  });
263
255
  });
@@ -155,35 +155,35 @@ describe('macro: select', () => {
155
155
  it('has expected text', () => {
156
156
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
157
157
 
158
- const values = mapAll($('select > option'), node => node.text().trim());
158
+ const values = mapAll($('select > option'), (node) => node.text().trim());
159
159
  expect(values).toEqual(['First option', 'Second option', 'Disabled option']);
160
160
  });
161
161
 
162
162
  it('has a provided `id` attribute', () => {
163
163
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
164
164
 
165
- const values = mapAll($('select > option'), node => node.attr('id'));
165
+ const values = mapAll($('select > option'), (node) => node.attr('id'));
166
166
  expect(values).toEqual([undefined, 'second-option', undefined]);
167
167
  });
168
168
 
169
169
  it('marks the correct option as selected', () => {
170
170
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
171
171
 
172
- const values = mapAll($('select > option'), node => node.attr('selected'));
172
+ const values = mapAll($('select > option'), (node) => node.attr('selected'));
173
173
  expect(values).toEqual([undefined, 'selected', undefined]);
174
174
  });
175
175
 
176
176
  it('marks the correct option as disabled', () => {
177
177
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
178
178
 
179
- const values = mapAll($('select > option'), node => node.attr('disabled'));
179
+ const values = mapAll($('select > option'), (node) => node.attr('disabled'));
180
180
  expect(values).toEqual([undefined, undefined, 'disabled']);
181
181
  });
182
182
 
183
183
  it('has a provided `value` attribute', () => {
184
184
  const $ = cheerio.load(renderComponent('select', EXAMPLE_SELECT));
185
185
 
186
- const values = mapAll($('select > option'), node => node.attr('value'));
186
+ const values = mapAll($('select > option'), (node) => node.attr('value'));
187
187
  expect(values).toEqual(['1', '2', '3']);
188
188
  });
189
189
 
@@ -195,7 +195,7 @@ describe('macro: select', () => {
195
195
  }),
196
196
  );
197
197
 
198
- const values = mapAll($('select > option'), node => node.attr('value'));
198
+ const values = mapAll($('select > option'), (node) => node.attr('value'));
199
199
  expect(values).toEqual(['First option', 'Second option']);
200
200
  });
201
201
  });
@@ -24,11 +24,7 @@ describe('macro: share-page', () => {
24
24
  it('wraps title in <h2> element by default', () => {
25
25
  const $ = cheerio.load(renderComponent('share-page', EXAMPLE_SHARE_PAGE));
26
26
 
27
- expect(
28
- $('h2')
29
- .text()
30
- .trim(),
31
- ).toBe('Share page');
27
+ expect($('h2').text().trim()).toBe('Share page');
32
28
  });
33
29
 
34
30
  it('wraps title in custom element when `titleTag` is provided', () => {
@@ -39,11 +35,7 @@ describe('macro: share-page', () => {
39
35
  }),
40
36
  );
41
37
 
42
- expect(
43
- $('h4')
44
- .text()
45
- .trim(),
46
- ).toBe('Share page');
38
+ expect($('h4').text().trim()).toBe('Share page');
47
39
  });
48
40
 
49
41
  it('uses the provided icon size', () => {
@@ -65,7 +57,7 @@ describe('macro: share-page', () => {
65
57
 
66
58
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
67
59
 
68
- const twitterItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Twitter');
60
+ const twitterItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Twitter');
69
61
  expect(twitterItem.url).toBe(
70
62
  'https://twitter.com/intent/tweet?original_referer&text=An%20example%20page&url=https%3A%2F%2Fexample.com%2Fan-example-page',
71
63
  );
@@ -77,7 +69,7 @@ describe('macro: share-page', () => {
77
69
 
78
70
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
79
71
 
80
- const twitterItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Twitter');
72
+ const twitterItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Twitter');
81
73
  expect(twitterItem.rel).toContain('noreferrer');
82
74
  expect(twitterItem.rel).toContain('external');
83
75
  expect(twitterItem.target).toBe('_blank');
@@ -91,7 +83,7 @@ describe('macro: share-page', () => {
91
83
 
92
84
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
93
85
 
94
- const facebookItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Facebook');
86
+ const facebookItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Facebook');
95
87
  expect(facebookItem.url).toBe('https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fexample.com%2Fan-example-page');
96
88
  });
97
89
 
@@ -101,7 +93,7 @@ describe('macro: share-page', () => {
101
93
 
102
94
  faker.renderComponent('share-page', EXAMPLE_SHARE_PAGE);
103
95
 
104
- const facebookItem = listsSpy.occurrences[0].itemsList.find(item => item.text === 'Facebook');
96
+ const facebookItem = listsSpy.occurrences[0].itemsList.find((item) => item.text === 'Facebook');
105
97
  expect(facebookItem.rel).toContain('noreferrer');
106
98
  expect(facebookItem.rel).toContain('external');
107
99
  expect(facebookItem.target).toBe('_blank');
@@ -3,7 +3,7 @@
3
3
  import * as cheerio from 'cheerio';
4
4
 
5
5
  import axe from '../../tests/helpers/axe';
6
- import { renderComponent, templateFaker } from '../../tests/helpers/rendering';
6
+ import { renderComponent } from '../../tests/helpers/rendering';
7
7
 
8
8
  describe('macro: skip-to-content', () => {
9
9
  it('passes jest-axe checks', async () => {
@@ -48,11 +48,7 @@ describe('macro: skip-to-content', () => {
48
48
  }),
49
49
  );
50
50
 
51
- expect(
52
- $('.ons-skip-to-content')
53
- .text()
54
- .trim(),
55
- ).toBe('Skip to the content');
51
+ expect($('.ons-skip-to-content').text().trim()).toBe('Skip to the content');
56
52
  });
57
53
 
58
54
  it('has skip link with the default text if no text provided`', async () => {
@@ -62,10 +58,6 @@ describe('macro: skip-to-content', () => {
62
58
  }),
63
59
  );
64
60
 
65
- expect(
66
- $('.ons-skip-to-content')
67
- .text()
68
- .trim(),
69
- ).toBe('Skip to content');
61
+ expect($('.ons-skip-to-content').text().trim()).toBe('Skip to content');
70
62
  });
71
63
  });
@@ -4,7 +4,7 @@ import skipToMain from './skip-to-content';
4
4
  async function initaliseSkipToLink() {
5
5
  const links = [...document.querySelectorAll('.ons-skip-to-content')];
6
6
  if (links.length) {
7
- links.forEach(link => {
7
+ links.forEach((link) => {
8
8
  skipToMain(link);
9
9
  });
10
10
  }
@@ -1,6 +1,6 @@
1
1
  export default function skipToMain(link) {
2
2
  const id = link.getAttribute('href').replace('#', '');
3
- link.addEventListener('click', event => {
3
+ link.addEventListener('click', (event) => {
4
4
  event.preventDefault();
5
5
  document.getElementById(id).tabIndex = -1;
6
6
  document.getElementById(id).style.outline = 'none';
@@ -18,7 +18,7 @@ describe('script: skip-to-content', () => {
18
18
  await page.focus('.ons-skip-to-content');
19
19
  await page.keyboard.press('Enter');
20
20
 
21
- const targetTabIndex = await page.$eval('#target-element', el => el.tabIndex);
21
+ const targetTabIndex = await page.$eval('#target-element', (el) => el.tabIndex);
22
22
  expect(targetTabIndex).toBe(-1);
23
23
  });
24
24
 
@@ -28,7 +28,7 @@ describe('script: skip-to-content', () => {
28
28
  await page.focus('.ons-skip-to-content');
29
29
  await page.keyboard.press('Enter');
30
30
 
31
- const targetOutline = await page.$eval('#target-element', el => el.style.outline);
31
+ const targetOutline = await page.$eval('#target-element', (el) => el.style.outline);
32
32
  expect(targetOutline).toBe('none');
33
33
  });
34
34
 
@@ -1,6 +1,6 @@
1
1
  {% macro onsStatus(params) %}
2
- {% if params.type %}
3
- {% set typeClass = ' ons-status--' + params.type %}
2
+ {% if params.variant %}
3
+ {% set typeClass = ' ons-status--' + params.variant %}
4
4
  {% else %}
5
5
  {% set typeClass = ' ons-status--info' %}
6
6
  {% endif %}
@@ -9,7 +9,7 @@ describe('macro: status', () => {
9
9
  it('passes jest-axe checks', async () => {
10
10
  const $ = cheerio.load(
11
11
  renderComponent('status', {
12
- type: 'success',
12
+ variant: 'success',
13
13
  label: 'Example status message',
14
14
  size: 'small',
15
15
  }),
@@ -19,7 +19,7 @@ describe('macro: status', () => {
19
19
  expect(results).toHaveNoViolations();
20
20
  });
21
21
 
22
- it('has the default type "info" when `type` is not provided', () => {
22
+ it('has the default variant "info" when `variant` is not provided', () => {
23
23
  const $ = cheerio.load(
24
24
  renderComponent('status', {
25
25
  label: 'Example status message',
@@ -29,10 +29,10 @@ describe('macro: status', () => {
29
29
  expect($('.ons-status').hasClass('ons-status--info')).toBe(true);
30
30
  });
31
31
 
32
- it('has the provided `type`', () => {
32
+ it('has the provided `variant`', () => {
33
33
  const $ = cheerio.load(
34
34
  renderComponent('status', {
35
- type: 'success',
35
+ variant: 'success',
36
36
  label: 'Example status message',
37
37
  }),
38
38
  );
@@ -68,10 +68,6 @@ describe('macro: status', () => {
68
68
  }),
69
69
  );
70
70
 
71
- expect(
72
- $('.ons-status')
73
- .text()
74
- .trim(),
75
- ).toBe('Example status message');
71
+ expect($('.ons-status').text().trim()).toBe('Example status message');
76
72
  });
77
73
  });
@@ -2,6 +2,6 @@
2
2
  {{
3
3
  onsStatus({
4
4
  "label": 'Not started',
5
- "type": 'dead'
5
+ "variant": 'dead'
6
6
  })
7
7
  }}
@@ -2,6 +2,6 @@
2
2
  {{
3
3
  onsStatus({
4
4
  "label": 'Refused',
5
- "type": 'error'
5
+ "variant": 'error'
6
6
  })
7
7
  }}
@@ -2,6 +2,6 @@
2
2
  {{
3
3
  onsStatus({
4
4
  "label": 'Pending',
5
- "type": 'pending'
5
+ "variant": 'pending'
6
6
  })
7
7
  }}
@@ -2,7 +2,7 @@
2
2
  {{
3
3
  onsStatus({
4
4
  "label": 'Live',
5
- "type": 'success',
5
+ "variant": 'success',
6
6
  "size": 'small'
7
7
  })
8
8
  }}
@@ -2,6 +2,6 @@
2
2
  {{
3
3
  onsStatus({
4
4
  "label": 'In progress',
5
- "type": 'success'
5
+ "variant": 'success'
6
6
  })
7
7
  }}
@@ -1,6 +1,6 @@
1
1
  {% macro onsSummary(params) %}
2
2
  {% set className = "ons-summary" %}
3
- {% set titleSize = "2" %}
3
+ {% set headingLevel = 2 %}
4
4
 
5
5
  {% if params.variant == "hub" %}
6
6
  {% set variantHub = true %}
@@ -17,16 +17,15 @@
17
17
  {% for summary in params.summaries %}
18
18
  {% if summary.summaryTitle %}
19
19
  <h2 class="ons-summary__title ons-u-mb-m{{ " ons-u-mt-m" if loop.index > 1 else "" }}">{{ summary.summaryTitle }}</h2>
20
- {% set titleSize = "3" %}
20
+ {% set headingLevel = 3 %}
21
21
  {% endif %}
22
22
  {% for group in summary.groups %}
23
23
  <div {% if group.id %}id="{{ group.id }}" {% endif %} class="ons-summary__group{{ variantClasses }}">
24
24
  {% if group.groupTitle %}
25
- <h{{ titleSize }} class="ons-summary__group-title">{{ group.groupTitle }}</h{{ titleSize }}>
25
+ <h{{ headingLevel }} class="ons-summary__group-title">{{ group.groupTitle }}</h{{ headingLevel }}>
26
26
  {% endif %}
27
27
  {% if group.rows %}
28
- <div class="ons-summary__items">
29
-
28
+ <dl class="ons-summary__items">
30
29
  {% for row in group.rows %}
31
30
  {% set itemClass = "" %}
32
31
  {% if row.error %} {% set itemClass = " ons-summary__item--error" %}{% endif %}
@@ -40,7 +39,7 @@
40
39
  {% endif %}
41
40
 
42
41
  {% for rowItem in row.rowItems %}
43
- <dl class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}"{% if rowItem.id %} id="{{ rowItem.id }}"{% endif %}>
42
+ <div class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}"{% if rowItem.id %} id="{{ rowItem.id }}"{% endif %}>
44
43
  <dt class="ons-summary__item-title"
45
44
  {% if rowItem.rowTitleAttributes %}{% for attribute, value in (rowItem.rowTitleAttributes.items() if rowItem.rowTitleAttributes is mapping and rowItem.rowTitleAttributes.items else rowItem.rowTitleAttributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
46
45
  >
@@ -104,11 +103,11 @@
104
103
  {% endfor %}
105
104
  </dd>
106
105
  {% endif %}
107
- </dl>
106
+ </div>
108
107
  {% endfor %}
109
108
  </div>
110
109
  {% endfor %}
111
- </div>
110
+ </dl>
112
111
  {% elif group.placeholderText %}
113
112
  <span class="ons-summary__placeholder">{{ group.placeholderText }}</span>
114
113
  {% endif %}
@@ -303,12 +303,26 @@ const EXAMPLE_SUMMARY_MULTIPLE_GROUPS = {
303
303
  ],
304
304
  };
305
305
 
306
+ // To address a DAC issue, we've disabled specific axe definition list rules causing test failures.
307
+ // While resolving it would require a significant refactor, the failures are deemed non-critical for accessibility,
308
+ // leading to their removal in this context. [https://github.com/ONSdigital/design-system/issues/3027]
309
+ const axeRules = {
310
+ rules: {
311
+ dlitem: {
312
+ enabled: false,
313
+ },
314
+ 'definition-list': {
315
+ enabled: false,
316
+ },
317
+ },
318
+ };
319
+
306
320
  describe('macro: summary', () => {
307
321
  describe('mode: general', () => {
308
322
  it('passes jest-axe checks', async () => {
309
323
  const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
324
+ const results = await axe($.html(), axeRules);
310
325
 
311
- const results = await axe($.html());
312
326
  expect(results).toHaveNoViolations();
313
327
  });
314
328
 
@@ -436,15 +450,19 @@ describe('macro: summary', () => {
436
450
  it('displays the `valueList` text', () => {
437
451
  const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
438
452
 
439
- expect($('.ons-summary__items .ons-summary__item:nth-of-type(1) dl .ons-summary__values .ons-summary__text').text().trim()).toBe(
440
- 'row value 1',
441
- );
453
+ expect(
454
+ $('.ons-summary__items .ons-summary__item:nth-of-type(1) .ons-summary__row .ons-summary__values .ons-summary__text')
455
+ .text()
456
+ .trim(),
457
+ ).toBe('row value 1');
442
458
  });
443
459
 
444
460
  it('displays the `other` text', () => {
445
461
  const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));
446
462
 
447
- expect($('.ons-summary__items .ons-summary__item:nth-of-type(1) dl .ons-summary__values ul li').text().trim()).toBe('other value');
463
+ expect($('.ons-summary__items .ons-summary__item:nth-of-type(1) .ons-summary__row .ons-summary__values ul li').text().trim()).toBe(
464
+ 'other value',
465
+ );
448
466
  });
449
467
 
450
468
  it('wraps the `valueList` in a ul if multiple values provided', () => {
@@ -516,8 +534,8 @@ describe('macro: summary', () => {
516
534
  describe('mode: with title', () => {
517
535
  it('passes jest-axe checks', async () => {
518
536
  const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_TITLE));
537
+ const results = await axe($.html(), axeRules);
519
538
 
520
- const results = await axe($.html());
521
539
  expect(results).toHaveNoViolations();
522
540
  });
523
541
 
@@ -536,8 +554,8 @@ describe('macro: summary', () => {
536
554
  variant: 'hub',
537
555
  }),
538
556
  );
557
+ const results = await axe($.html(), axeRules);
539
558
 
540
- const results = await axe($.html());
541
559
  expect(results).toHaveNoViolations();
542
560
  });
543
561
 
@@ -570,7 +588,7 @@ describe('macro: summary', () => {
570
588
  it('passes jest-axe checks', async () => {
571
589
  const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_WITH_NO_ROWS));
572
590
 
573
- const results = await axe($.html());
591
+ const results = await axe($.html(), axeRules);
574
592
  expect(results).toHaveNoViolations();
575
593
  });
576
594
 
@@ -609,8 +627,8 @@ describe('macro: summary', () => {
609
627
  describe('mode: card', () => {
610
628
  it('passes jest-axe checks', async () => {
611
629
  const $ = cheerio.load(renderComponent('summary', { ...EXAMPLE_SUMMARY_BASIC, variant: 'card' }));
630
+ const results = await axe($.html(), axeRules);
612
631
 
613
- const results = await axe($.html());
614
632
  expect(results).toHaveNoViolations();
615
633
  });
616
634
 
@@ -59,7 +59,7 @@ describe('macro: table', () => {
59
59
  it('renders header cells with expected text', () => {
60
60
  const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
61
61
 
62
- const headerCellValues = mapAll($('.ons-table__header'), node => node.text().trim());
62
+ const headerCellValues = mapAll($('.ons-table__header'), (node) => node.text().trim());
63
63
  expect(headerCellValues).toEqual(['Column 1', 'Column 2', 'Column 3']);
64
64
  });
65
65
 
@@ -121,7 +121,7 @@ describe('macro: table', () => {
121
121
  it('does not add visually hidden class to column headers', () => {
122
122
  const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
123
123
 
124
- const hasClass = mapAll($('.ons-table__header > span'), node => node.hasClass('ons-u-vh'));
124
+ const hasClass = mapAll($('.ons-table__header > span'), (node) => node.hasClass('ons-u-vh'));
125
125
  expect(hasClass).toEqual([false, false, false]);
126
126
  });
127
127
 
@@ -139,9 +139,9 @@ describe('macro: table', () => {
139
139
  it('renders expected row cells', () => {
140
140
  const $ = cheerio.load(renderComponent('table', EXAMPLE_TABLE));
141
141
 
142
- const row1Values = mapAll($('.ons-table__row:nth-child(1) .ons-table__cell'), node => node.text().trim());
142
+ const row1Values = mapAll($('.ons-table__row:nth-child(1) .ons-table__cell'), (node) => node.text().trim());
143
143
  expect(row1Values).toEqual(['Row 1 Cell 1', 'Row 1 Cell 2', 'Row 1 Cell 3']);
144
- const row2Values = mapAll($('.ons-table__row:nth-child(2) .ons-table__cell'), node => node.text().trim());
144
+ const row2Values = mapAll($('.ons-table__row:nth-child(2) .ons-table__cell'), (node) => node.text().trim());
145
145
  expect(row2Values).toEqual(['Row 2 Cell 1', 'Row 2 Cell 2', 'Row 2 Cell 3']);
146
146
  });
147
147
 
@@ -401,7 +401,7 @@ describe('macro: table', () => {
401
401
  }),
402
402
  );
403
403
 
404
- const footerCellValues = mapAll($('.ons-table__foot .ons-table__cell'), node => node.text().trim());
404
+ const footerCellValues = mapAll($('.ons-table__foot .ons-table__cell'), (node) => node.text().trim());
405
405
  expect(footerCellValues).toEqual(['Footer Cell 1', 'Footer Cell 2', 'Footer Cell 3']);
406
406
  });
407
407
  });
@@ -515,11 +515,7 @@ describe('macro: table', () => {
515
515
  }),
516
516
  );
517
517
 
518
- expect(
519
- $('.ons-table__caption')
520
- .text()
521
- .trim(),
522
- ).toBe('Example table caption');
518
+ expect($('.ons-table__caption').text().trim()).toBe('Example table caption');
523
519
  });
524
520
 
525
521
  it('does not visually hide caption when `hideCaption` is not provided', () => {
@@ -8,7 +8,7 @@ async function tableScroller() {
8
8
  if (tables.length) {
9
9
  const TableScroll = (await import('./scrollable-table')).default;
10
10
 
11
- tables.forEach(table => new TableScroll(table));
11
+ tables.forEach((table) => new TableScroll(table));
12
12
  }
13
13
  }
14
14
 
@@ -65,7 +65,7 @@ export default class TableScroll {
65
65
  ? rightShadow.classList.remove('ons-visible')
66
66
  : rightShadow.classList.add('ons-visible');
67
67
 
68
- setTimeout(function() {
68
+ setTimeout(function () {
69
69
  return leftShadow.classList.add('ons-with-transition'), rightShadow.classList.add('ons-with-transition');
70
70
  }, 200);
71
71
  }
@@ -59,7 +59,7 @@ export default class TableSort {
59
59
  this.tableBody = this.table.getElementsByClassName(classTableBody);
60
60
  const tableBody = [...this.tableBody];
61
61
 
62
- tableBody.forEach(tbody => {
62
+ tableBody.forEach((tbody) => {
63
63
  const rows = this.getTableRowsArray(tbody);
64
64
  const sortedRows = this.sort(rows, columnNumber, newSortDirection);
65
65
  this.addRows(tbody, sortedRows);
@@ -74,7 +74,7 @@ export default class TableSort {
74
74
  this.trs = tbody.querySelectorAll('tr');
75
75
  const trs = [...this.trs];
76
76
 
77
- trs.forEach(tr => {
77
+ trs.forEach((tr) => {
78
78
  rows.push(tr);
79
79
  });
80
80
 
@@ -123,7 +123,7 @@ export default class TableSort {
123
123
  }
124
124
 
125
125
  addRows(body, rows) {
126
- rows.forEach(row => {
126
+ rows.forEach((row) => {
127
127
  body.append(row);
128
128
  });
129
129
  }
@@ -131,7 +131,7 @@ export default class TableSort {
131
131
  removeButtonStates() {
132
132
  this.sortableHeadings = this.table.querySelectorAll(jsSortableHeadings);
133
133
  const sortableHeadings = [...this.sortableHeadings];
134
- sortableHeadings.forEach(heading => {
134
+ sortableHeadings.forEach((heading) => {
135
135
  heading.setAttribute('aria-sort', 'none');
136
136
  });
137
137
  }