@ons/design-system 68.0.0 → 68.0.2

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 (199) 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/_field-group.scss +3 -4
  71. package/components/field/_macro.spec.js +1 -3
  72. package/components/fieldset/_fieldset.scss +1 -2
  73. package/components/fieldset/_macro.spec.js +3 -9
  74. package/components/footer/_footer.scss +8 -0
  75. package/components/footer/_macro.njk +8 -7
  76. package/components/footer/_macro.spec.js +14 -2
  77. package/components/header/_macro.njk +1 -1
  78. package/components/header/_macro.spec.js +1 -1
  79. package/components/helpers/grid.njk +15 -15
  80. package/components/icon/_macro.njk +17 -13
  81. package/components/icon/_macro.spec.js +8 -16
  82. package/components/image/_macro.spec.js +1 -5
  83. package/components/input/_macro.njk +22 -23
  84. package/components/input/_macro.spec.js +1 -1
  85. package/components/input/character-check.dom.js +1 -1
  86. package/components/input/input.spec.js +1 -4
  87. package/components/label/_label.scss +1 -0
  88. package/components/label/_macro.njk +3 -3
  89. package/components/label/_macro.spec.js +4 -13
  90. package/components/list/_macro.spec.js +4 -12
  91. package/components/message/_macro.njk +17 -17
  92. package/components/message/_macro.spec.js +9 -33
  93. package/components/message-list/_macro.spec.js +7 -39
  94. package/components/metadata/_macro.njk +10 -10
  95. package/components/modal/_macro.spec.js +3 -9
  96. package/components/modal/modal.dom.js +1 -1
  97. package/components/modal/modal.spec.js +5 -5
  98. package/components/multiple-input-fields/_macro.njk +49 -0
  99. package/components/mutually-exclusive/_macro.spec.js +2 -10
  100. package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
  101. package/components/mutually-exclusive/mutually-exclusive.date.spec.js +128 -14
  102. package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
  103. package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +129 -8
  104. package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
  105. package/components/mutually-exclusive/mutually-exclusive.js +13 -13
  106. package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
  107. package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
  108. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
  109. package/components/navigation/navigation.spec.js +0 -2
  110. package/components/pagination/_macro.spec.js +11 -53
  111. package/components/panel/_macro.njk +17 -17
  112. package/components/panel/_macro.spec.js +25 -25
  113. package/components/panel/_panel.scss +10 -9
  114. package/components/panel/example-panel-bare.njk +3 -4
  115. package/components/panel/example-panel-with-announcement.njk +6 -10
  116. package/components/panel/example-panel-with-error-summary.njk +2 -2
  117. package/components/panel/example-panel-with-information.njk +0 -1
  118. package/components/panel/example-panel-with-success-message.njk +1 -1
  119. package/components/panel/example-panel-with-warning.njk +2 -3
  120. package/components/password/password.dom.js +1 -1
  121. package/components/phase-banner/_macro.spec.js +3 -9
  122. package/components/question/_macro.njk +1 -1
  123. package/components/question/_macro.spec.js +5 -19
  124. package/components/question/_question.scss +1 -4
  125. package/components/question/example-question-interviewer-note.njk +1 -1
  126. package/components/quote/_macro.spec.js +2 -10
  127. package/components/radios/clear-radios.js +3 -3
  128. package/components/radios/radio-with-fieldset.js +4 -4
  129. package/components/radios/radios.dom.js +1 -1
  130. package/components/radios/radios.spec.js +26 -26
  131. package/components/related-content/_macro.spec.js +2 -4
  132. package/components/related-content/_section-macro.spec.js +2 -8
  133. package/components/relationships/example-relationships-error.njk +16 -18
  134. package/components/relationships/relationships.dom.js +1 -1
  135. package/components/relationships/relationships.js +2 -2
  136. package/components/reply/_macro.spec.js +3 -3
  137. package/components/reply/reply.dom.js +1 -1
  138. package/components/reply/reply.spec.js +3 -3
  139. package/components/section-navigation/_macro.njk +12 -12
  140. package/components/section-navigation/_macro.spec.js +13 -21
  141. package/components/select/_macro.spec.js +6 -6
  142. package/components/share-page/_macro.spec.js +6 -14
  143. package/components/skip-to-content/_macro.spec.js +3 -11
  144. package/components/skip-to-content/skip-to-content.dom.js +1 -1
  145. package/components/skip-to-content/skip-to-content.js +1 -1
  146. package/components/skip-to-content/skip-to-content.spec.js +2 -2
  147. package/components/status/_macro.njk +2 -2
  148. package/components/status/_macro.spec.js +5 -9
  149. package/components/status/example-status-dead.njk +1 -1
  150. package/components/status/example-status-error.njk +1 -1
  151. package/components/status/example-status-pending.njk +1 -1
  152. package/components/status/example-status-small.njk +1 -1
  153. package/components/status/example-status-success.njk +2 -2
  154. package/components/summary/_macro.njk +7 -8
  155. package/components/summary/_macro.spec.js +27 -9
  156. package/components/table/_macro.spec.js +6 -10
  157. package/components/table/scrollable-table.dom.js +1 -1
  158. package/components/table/scrollable-table.js +1 -1
  159. package/components/table/sortable-table.js +4 -4
  160. package/components/table/table.spec.js +21 -17
  161. package/components/table-of-contents/_macro.njk +31 -31
  162. package/components/table-of-contents/_macro.spec.js +3 -11
  163. package/components/table-of-contents/toc.dom.js +1 -1
  164. package/components/table-of-contents/toc.spec.js +36 -32
  165. package/components/tabs/example-tabs-details.njk +1 -1
  166. package/components/tabs/tabs.dom.js +1 -1
  167. package/components/tabs/tabs.js +8 -8
  168. package/components/text-indent/_macro.spec.js +2 -6
  169. package/components/textarea/textarea.dom.js +1 -1
  170. package/components/textarea/textarea.spec.js +8 -8
  171. package/components/timeout-modal/_macro.spec.js +1 -3
  172. package/components/timeout-modal/timeout-modal.dom.js +1 -1
  173. package/components/timeout-modal/timeout-modal.spec.js +10 -10
  174. package/components/timeout-panel/_macro.njk +16 -17
  175. package/components/timeout-panel/_macro.spec.js +1 -1
  176. package/components/timeout-panel/timeout-panel.dom.js +1 -1
  177. package/components/timeout-panel/timeout-panel.spec.js +8 -8
  178. package/components/video/_macro.spec.js +1 -5
  179. package/components/video/video.dom.js +1 -1
  180. package/components/video/video.spec.js +16 -12
  181. package/css/main.css +1 -1
  182. package/favicons/safari-pinned-tab.svg +23 -23
  183. package/js/analytics.js +12 -15
  184. package/js/cookies-settings.dom.js +1 -1
  185. package/js/cookies-settings.spec.js +19 -19
  186. package/js/domready.js +1 -1
  187. package/js/fetch.js +1 -1
  188. package/js/inpagelink.js +3 -3
  189. package/js/main.js +1 -0
  190. package/js/print-button.js +1 -1
  191. package/js/timeout.js +1 -1
  192. package/package.json +2 -1
  193. package/scripts/main.es5.js +1 -1
  194. package/scripts/main.js +1 -1
  195. package/scss/base/_typography.scss +8 -2
  196. package/scss/main.scss +1 -0
  197. package/scss/overrides/hcm.scss +8 -1
  198. package/scss/vars/_colors.scss +2 -1
  199. package/components/date-field-input/_macro.njk +0 -86
@@ -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
  }}
@@ -1,7 +1,7 @@
1
1
  {% from "components/status/_macro.njk" import onsStatus %}
2
2
  {{
3
3
  onsStatus({
4
- "label": 'In progress',
5
- "type": 'success'
4
+ "label": 'Live',
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
  }
@@ -18,9 +18,9 @@ describe('script: table', () => {
18
18
  });
19
19
 
20
20
  it('should add shadow elements', async () => {
21
- const leftShadowCount = await page.$$eval('.ons-table__left-shadow', nodes => nodes.length);
21
+ const leftShadowCount = await page.$$eval('.ons-table__left-shadow', (nodes) => nodes.length);
22
22
  expect(leftShadowCount).not.toBe(0);
23
- const rightShadowCount = await page.$$eval('.ons-table__right-shadow', nodes => nodes.length);
23
+ const rightShadowCount = await page.$$eval('.ons-table__right-shadow', (nodes) => nodes.length);
24
24
  expect(rightShadowCount).not.toBe(0);
25
25
  });
26
26
 
@@ -33,9 +33,9 @@ describe('script: table', () => {
33
33
  it('should show both shadow elements', async () => {
34
34
  await page.waitForTimeout(200);
35
35
 
36
- const leftShadowVisibleCount = await page.$$eval('.ons-table__left-shadow.ons-visible', nodes => nodes.length);
36
+ const leftShadowVisibleCount = await page.$$eval('.ons-table__left-shadow.ons-visible', (nodes) => nodes.length);
37
37
  expect(leftShadowVisibleCount).not.toBe(0);
38
- const rightShadowVisibleCount = await page.$$eval('.ons-table__right-shadow.ons-visible', nodes => nodes.length);
38
+ const rightShadowVisibleCount = await page.$$eval('.ons-table__right-shadow.ons-visible', (nodes) => nodes.length);
39
39
  expect(rightShadowVisibleCount).not.toBe(0);
40
40
  });
41
41
  });
@@ -86,27 +86,31 @@ describe('script: table', () => {
86
86
  });
87
87
 
88
88
  it('should create a button element in each TH', async () => {
89
- const buttonCount = await page.$$eval('.ons-table__header .ons-table__sort-button', nodes => nodes.length);
89
+ const buttonCount = await page.$$eval('.ons-table__header .ons-table__sort-button', (nodes) => nodes.length);
90
90
  expect(buttonCount).toBe(4);
91
91
  });
92
92
 
93
93
  it('should create a status element with aria attributes', async () => {
94
- const ariaLiveAttribute = await page.$eval('.ons-sortable-table-status', node => node.getAttribute('aria-live'));
94
+ const ariaLiveAttribute = await page.$eval('.ons-sortable-table-status', (node) => node.getAttribute('aria-live'));
95
95
  expect(ariaLiveAttribute).toBe('polite');
96
- const roleAttribute = await page.$eval('.ons-sortable-table-status', node => node.getAttribute('role'));
96
+ const roleAttribute = await page.$eval('.ons-sortable-table-status', (node) => node.getAttribute('role'));
97
97
  expect(roleAttribute).toBe('status');
98
- const ariaAtomicAttribute = await page.$eval('.ons-sortable-table-status', node => node.getAttribute('aria-atomic'));
98
+ const ariaAtomicAttribute = await page.$eval('.ons-sortable-table-status', (node) => node.getAttribute('aria-atomic'));
99
99
  expect(ariaAtomicAttribute).toBe('true');
100
100
  });
101
101
 
102
102
  describe('Each sort button element', () => {
103
103
  it('should contain an aria-label attribute', async () => {
104
- const ariaLabelValues = await page.$$eval('.ons-table__sort-button', nodes => nodes.map(node => node.getAttribute('aria-label')));
104
+ const ariaLabelValues = await page.$$eval('.ons-table__sort-button', (nodes) =>
105
+ nodes.map((node) => node.getAttribute('aria-label')),
106
+ );
105
107
  expect(ariaLabelValues).toEqual(['Sort by Column 1', 'Sort by Column 2', 'Sort by Column 3', 'Sort by Column 4']);
106
108
  });
107
109
 
108
110
  it('should contain a data-index attribute', async () => {
109
- const dataIndexValues = await page.$$eval('.ons-table__sort-button', nodes => nodes.map(node => node.getAttribute('data-index')));
111
+ const dataIndexValues = await page.$$eval('.ons-table__sort-button', (nodes) =>
112
+ nodes.map((node) => node.getAttribute('data-index')),
113
+ );
110
114
  expect(dataIndexValues).toEqual(['0', '1', '2', '3']);
111
115
  });
112
116
  });
@@ -117,19 +121,19 @@ describe('script: table', () => {
117
121
  });
118
122
 
119
123
  it('should update aria-sort value for each column header', async () => {
120
- const ariaSortValues = await page.$$eval('.ons-table__header', nodes => nodes.map(node => node.getAttribute('aria-sort')));
124
+ const ariaSortValues = await page.$$eval('.ons-table__header', (nodes) => nodes.map((node) => node.getAttribute('aria-sort')));
121
125
  expect(ariaSortValues).toEqual(['descending', 'none', 'none', 'none']);
122
126
  });
123
127
 
124
128
  it('should sort the column into descending order', async () => {
125
- const firstColumnValues = await page.$$eval('.ons-table__row .ons-table__cell:first-child', nodes =>
126
- nodes.map(node => node.textContent.trim()),
129
+ const firstColumnValues = await page.$$eval('.ons-table__row .ons-table__cell:first-child', (nodes) =>
130
+ nodes.map((node) => node.textContent.trim()),
127
131
  );
128
132
  expect(firstColumnValues).toEqual(['C', 'B', 'A']);
129
133
  });
130
134
 
131
135
  it('should update the aria-live status', async () => {
132
- const statusText = await page.$eval('.ons-sortable-table-status', node => node.textContent);
136
+ const statusText = await page.$eval('.ons-sortable-table-status', (node) => node.textContent);
133
137
  expect(statusText).toBe('Sort by Column 1 (descending)');
134
138
  });
135
139
 
@@ -139,13 +143,13 @@ describe('script: table', () => {
139
143
  });
140
144
 
141
145
  it('should update aria-sort value for each column header', async () => {
142
- const ariaSortValues = await page.$$eval('.ons-table__header', nodes => nodes.map(node => node.getAttribute('aria-sort')));
146
+ const ariaSortValues = await page.$$eval('.ons-table__header', (nodes) => nodes.map((node) => node.getAttribute('aria-sort')));
143
147
  expect(ariaSortValues).toEqual(['ascending', 'none', 'none', 'none']);
144
148
  });
145
149
 
146
150
  it('should sort the column into ascending order', async () => {
147
- const firstColumnValues = await page.$$eval('.ons-table__row .ons-table__cell:first-child', nodes =>
148
- nodes.map(node => node.textContent.trim()),
151
+ const firstColumnValues = await page.$$eval('.ons-table__row .ons-table__cell:first-child', (nodes) =>
152
+ nodes.map((node) => node.textContent.trim()),
149
153
  );
150
154
  expect(firstColumnValues).toEqual(['A', 'B', 'C']);
151
155
  });
@@ -4,40 +4,40 @@
4
4
 
5
5
  <aside class="ons-toc-container" role="complementary">
6
6
  {% if params.skipLink %}
7
- {{
8
- onsSkipToContent({
9
- "url": params.skipLink.url,
10
- "text": params.skipLink.text
11
- })
12
- }}
7
+ {{
8
+ onsSkipToContent({
9
+ "url": params.skipLink.url,
10
+ "text": params.skipLink.text
11
+ })
12
+ }}
13
13
  {% endif %}
14
14
 
15
15
  <nav class="ons-toc" aria-label="{{ params.ariaLabel | default('Table of contents') }}">
16
- <h2 class="ons-toc__title ons-u-fs-r--b ons-u-mb-s">{{ params.title }}</h2>
17
- {% if params.lists %}
18
- {% for list in params.lists %}
19
- {% if list.listHeading %}
20
- <h3 class="ons-u-fs-r ons-u-mb-xs">{{ list.listHeading }}<span class="ons-u-vh"> {{ list.listHeadingHidden }}</span>:</h3>
21
- {% endif %}
22
- {{
23
- onsList({
24
- "element": 'ol',
25
- "classes": 'ons-u-mb-m',
26
- "variants": 'dashed',
27
- "itemsList": list.itemsList
28
- })
29
- }}
30
- {% endfor %}
31
- {% elif params.itemsList %}
32
- {{
33
- onsList({
34
- "element": 'ol',
35
- "classes": 'ons-u-mb-m',
36
- "variants": 'dashed',
37
- "itemsList": params.itemsList
38
- })
39
- }}
40
- {% endif %}
16
+ <h2 class="ons-toc__title ons-u-fs-r--b ons-u-mb-s">{{ params.title }}</h2>
17
+ {% if params.lists %}
18
+ {% for list in params.lists %}
19
+ {% if list.listHeading %}
20
+ <h3 class="ons-u-fs-r ons-u-mb-xs">{{ list.listHeading }}<span class="ons-u-vh"> {{ list.listHeadingHidden }}</span>:</h3>
21
+ {% endif %}
22
+ {{
23
+ onsList({
24
+ "element": 'ol',
25
+ "classes": 'ons-u-mb-m',
26
+ "variants": 'dashed',
27
+ "itemsList": list.itemsList
28
+ })
29
+ }}
30
+ {% endfor %}
31
+ {% elif params.itemsList %}
32
+ {{
33
+ onsList({
34
+ "element": 'ol',
35
+ "classes": 'ons-u-mb-m',
36
+ "variants": 'dashed',
37
+ "itemsList": params.itemsList
38
+ })
39
+ }}
40
+ {% endif %}
41
41
  </nav>
42
42
  </aside>
43
43
  {% endmacro %}
@@ -76,11 +76,7 @@ describe('macro: table-of-contents', () => {
76
76
  it('renders title as heading element', () => {
77
77
  const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_SINGLE));
78
78
 
79
- expect(
80
- $('.ons-toc__title')
81
- .text()
82
- .trim(),
83
- ).toBe('Contents');
79
+ expect($('.ons-toc__title').text().trim()).toBe('Contents');
84
80
  });
85
81
 
86
82
  describe('skip to content when `skipLink` is provided', () => {
@@ -140,18 +136,14 @@ describe('macro: table-of-contents', () => {
140
136
 
141
137
  $('.ons-u-vh').remove();
142
138
 
143
- const headings = mapAll($('h3'), node =>
144
- $(node)
145
- .text()
146
- .trim(),
147
- );
139
+ const headings = mapAll($('h3'), (node) => $(node).text().trim());
148
140
  expect(headings).toEqual(['Household questions:', 'Individual questions:']);
149
141
  });
150
142
 
151
143
  it('renders visually hidden heading for each list', () => {
152
144
  const $ = cheerio.load(renderComponent('table-of-contents', EXAMPLE_TABLE_OF_CONTENTS_MULTIPLE));
153
145
 
154
- const headings = mapAll($('h3 .ons-u-vh'), node => node.text().trim());
146
+ const headings = mapAll($('h3 .ons-u-vh'), (node) => node.text().trim());
155
147
  expect(headings).toEqual(['help topics', 'help topics']);
156
148
  });
157
149
 
@@ -6,7 +6,7 @@ async function toc() {
6
6
  if (toc.length) {
7
7
  const Toc = (await import('./toc')).default;
8
8
 
9
- toc.forEach(component => new Toc(component));
9
+ toc.forEach((component) => new Toc(component));
10
10
  }
11
11
  }
12
12