@ons/design-system 67.2.0 → 68.0.1
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.
- package/README.md +6 -0
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +2 -10
- package/components/access-code/access-code.dom.js +1 -1
- package/components/access-code/access-code.spec.js +2 -2
- package/components/access-code/example-access-code-error.njk +9 -14
- package/components/access-code/example-access-code.njk +3 -5
- package/components/accordion/accordion.js +4 -4
- package/components/address-input/_macro.spec.js +3 -15
- package/components/address-input/autosuggest.address.dom.js +1 -1
- package/components/address-input/autosuggest.address.js +3 -2
- package/components/address-input/autosuggest.address.setter.js +3 -3
- package/components/address-input/autosuggest.address.spec.js +66 -69
- package/components/address-output/_macro.spec.js +6 -30
- package/components/autosuggest/_autosuggest.scss +1 -1
- package/components/autosuggest/autosuggest.dom.js +1 -1
- package/components/autosuggest/autosuggest.helpers.js +1 -1
- package/components/back-to-top/_back-to-top.scss +34 -0
- package/components/back-to-top/_macro.njk +17 -0
- package/components/back-to-top/_macro.spec.js +60 -0
- package/components/back-to-top/back-to-top.dom.js +12 -0
- package/components/back-to-top/back-to-top.js +58 -0
- package/components/back-to-top/back-to-top.spec.js +117 -0
- package/components/back-to-top/example-back-to-top.njk +37 -0
- package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
- package/components/browser-banner/_macro.spec.js +4 -12
- package/components/button/_macro.njk +6 -6
- package/components/button/_macro.spec.js +1 -5
- package/components/button/button.js +7 -8
- package/components/button/button.spec.js +17 -39
- package/components/call-to-action/_macro.spec.js +2 -6
- package/components/card/_macro.njk +25 -25
- package/components/card/_macro.spec.js +10 -34
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/char-check-limit/_macro.spec.js +3 -7
- package/components/char-check-limit/character-check.spec.js +24 -20
- package/components/checkboxes/_checkbox-macro.njk +1 -1
- package/components/checkboxes/_checkbox.scss +0 -3
- package/components/checkboxes/_macro.spec.js +1 -5
- package/components/checkboxes/checkbox-with-autoselect.js +3 -3
- package/components/checkboxes/checkbox-with-fieldset.js +2 -2
- package/components/checkboxes/checkboxes-with-reveal.js +4 -2
- package/components/checkboxes/checkboxes.dom.js +2 -2
- package/components/checkboxes/checkboxes.spec.js +13 -13
- package/components/content-pagination/_macro.spec.js +2 -2
- package/components/cookies-banner/cookies-banner.dom.js +1 -1
- package/components/cookies-banner/cookies-banner.js +1 -1
- package/components/cookies-banner/cookies-banner.spec.js +7 -7
- package/components/date-input/_macro.njk +71 -69
- package/components/date-input/_macro.spec.js +20 -5
- package/components/date-input/example-date-input-double-field.njk +27 -0
- package/components/date-input/example-date-input-single-field.njk +18 -0
- package/components/details/details.spec.js +12 -12
- package/components/details/example-details-with-warning.njk +5 -7
- package/components/document-list/_macro.spec.js +9 -27
- package/components/document-list/document-list.scss +1 -1
- package/components/document-list/example-document-list-downloads.njk +3 -3
- package/components/document-list/example-document-list-search-result-featured.njk +1 -1
- package/components/document-list/example-document-list-search-results.njk +3 -3
- package/components/download-resources/download-resources.js +54 -54
- package/components/download-resources/download-resources.spec.js +3 -1
- package/components/duration/_macro.njk +52 -48
- package/components/duration/_macro.spec.js +112 -4
- package/components/duration/example-duration-error-for-single-field.njk +1 -1
- package/components/duration/example-duration-single-field.njk +24 -0
- package/components/error/_macro.njk +1 -1
- package/components/error/_macro.spec.js +2 -6
- package/components/feedback/_macro.njk +1 -1
- package/components/feedback/_macro.spec.js +4 -20
- package/components/field/_field-group.scss +3 -4
- package/components/field/_macro.spec.js +1 -3
- package/components/fieldset/_fieldset.scss +1 -2
- package/components/fieldset/_macro.spec.js +3 -9
- package/components/footer/_footer.scss +8 -0
- package/components/footer/_macro.njk +8 -7
- package/components/footer/_macro.spec.js +14 -2
- package/components/header/_macro.njk +1 -1
- package/components/header/_macro.spec.js +1 -1
- package/components/helpers/grid.njk +15 -15
- package/components/icon/_macro.njk +17 -13
- package/components/icon/_macro.spec.js +8 -16
- package/components/image/_macro.spec.js +1 -5
- package/components/input/_macro.njk +22 -23
- package/components/input/_macro.spec.js +1 -1
- package/components/input/character-check.dom.js +1 -1
- package/components/input/input.spec.js +1 -4
- package/components/label/_label.scss +1 -0
- package/components/label/_macro.njk +3 -3
- package/components/label/_macro.spec.js +4 -13
- package/components/list/_macro.spec.js +4 -12
- package/components/message/_macro.njk +17 -17
- package/components/message/_macro.spec.js +9 -33
- package/components/message-list/_macro.spec.js +7 -39
- package/components/metadata/_macro.njk +10 -10
- package/components/modal/_macro.spec.js +3 -9
- package/components/modal/modal.dom.js +1 -1
- package/components/modal/modal.spec.js +5 -5
- package/components/multiple-input-fields/_macro.njk +49 -0
- package/components/mutually-exclusive/_macro.spec.js +2 -10
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +128 -14
- package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +129 -8
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.js +13 -13
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
- package/components/navigation/navigation.spec.js +0 -2
- package/components/pagination/_macro.spec.js +11 -53
- package/components/panel/_macro.njk +17 -17
- package/components/panel/_macro.spec.js +25 -25
- package/components/panel/_panel.scss +10 -9
- package/components/panel/example-panel-bare.njk +3 -4
- package/components/panel/example-panel-with-announcement.njk +6 -10
- package/components/panel/example-panel-with-error-summary.njk +2 -2
- package/components/panel/example-panel-with-information.njk +0 -1
- package/components/panel/example-panel-with-success-message.njk +1 -1
- package/components/panel/example-panel-with-warning.njk +2 -3
- package/components/password/password.dom.js +1 -1
- package/components/phase-banner/_macro.spec.js +3 -9
- package/components/question/_macro.njk +1 -1
- package/components/question/_macro.spec.js +5 -19
- package/components/question/_question.scss +1 -4
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/quote/_macro.spec.js +2 -10
- package/components/radios/clear-radios.js +3 -3
- package/components/radios/radio-with-fieldset.js +4 -4
- package/components/radios/radios.dom.js +1 -1
- package/components/radios/radios.spec.js +26 -26
- package/components/related-content/_macro.spec.js +2 -4
- package/components/related-content/_section-macro.spec.js +2 -8
- package/components/relationships/example-relationships-error.njk +16 -18
- package/components/relationships/relationships.dom.js +1 -1
- package/components/relationships/relationships.js +2 -2
- package/components/reply/_macro.spec.js +3 -3
- package/components/reply/reply.dom.js +1 -1
- package/components/reply/reply.spec.js +3 -3
- package/components/section-navigation/_macro.njk +12 -12
- package/components/section-navigation/_macro.spec.js +13 -21
- package/components/select/_macro.spec.js +6 -6
- package/components/share-page/_macro.spec.js +6 -14
- package/components/skip-to-content/_macro.spec.js +3 -11
- package/components/skip-to-content/skip-to-content.dom.js +1 -1
- package/components/skip-to-content/skip-to-content.js +1 -1
- package/components/skip-to-content/skip-to-content.spec.js +2 -2
- package/components/status/_macro.njk +2 -2
- package/components/status/_macro.spec.js +5 -9
- package/components/status/example-status-dead.njk +1 -1
- package/components/status/example-status-error.njk +1 -1
- package/components/status/example-status-pending.njk +1 -1
- package/components/status/example-status-small.njk +1 -1
- package/components/status/example-status-success.njk +1 -1
- package/components/summary/_macro.njk +7 -8
- package/components/summary/_macro.spec.js +27 -9
- package/components/table/_macro.spec.js +6 -10
- package/components/table/scrollable-table.dom.js +1 -1
- package/components/table/scrollable-table.js +1 -1
- package/components/table/sortable-table.js +4 -4
- package/components/table/table.spec.js +21 -17
- package/components/table-of-contents/_macro.njk +31 -31
- package/components/table-of-contents/_macro.spec.js +3 -11
- package/components/table-of-contents/toc.dom.js +1 -1
- package/components/table-of-contents/toc.spec.js +36 -32
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/tabs/tabs.dom.js +1 -1
- package/components/tabs/tabs.js +8 -8
- package/components/text-indent/_macro.spec.js +2 -6
- package/components/textarea/textarea.dom.js +1 -1
- package/components/textarea/textarea.spec.js +8 -8
- package/components/timeout-modal/_macro.spec.js +1 -3
- package/components/timeout-modal/timeout-modal.dom.js +1 -1
- package/components/timeout-modal/timeout-modal.spec.js +10 -10
- package/components/timeout-panel/_macro.njk +16 -17
- package/components/timeout-panel/_macro.spec.js +1 -1
- package/components/timeout-panel/timeout-panel.dom.js +1 -1
- package/components/timeout-panel/timeout-panel.spec.js +8 -8
- package/components/video/_macro.spec.js +1 -5
- package/components/video/video.dom.js +1 -1
- package/components/video/video.spec.js +16 -12
- package/css/main.css +1 -1
- package/favicons/safari-pinned-tab.svg +23 -23
- package/js/analytics.js +15 -14
- package/js/cookies-settings.dom.js +1 -1
- package/js/cookies-settings.spec.js +19 -19
- package/js/domready.js +1 -1
- package/js/fetch.js +1 -1
- package/js/inpagelink.js +3 -3
- package/js/main.js +1 -0
- package/js/print-button.js +1 -1
- package/js/timeout.js +1 -1
- package/package.json +2 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_typography.scss +8 -2
- package/scss/main.scss +1 -0
- package/scss/overrides/hcm.scss +8 -1
- package/scss/vars/_colors.scss +2 -1
- 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
|
|
|
@@ -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
|
-
|
|
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
|
|
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 `
|
|
32
|
+
it('has the provided `variant`', () => {
|
|
33
33
|
const $ = cheerio.load(
|
|
34
34
|
renderComponent('status', {
|
|
35
|
-
|
|
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
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% macro onsSummary(params) %}
|
|
2
2
|
{% set className = "ons-summary" %}
|
|
3
|
-
{% set
|
|
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
|
|
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{{
|
|
25
|
+
<h{{ headingLevel }} class="ons-summary__group-title">{{ group.groupTitle }}</h{{ headingLevel }}>
|
|
26
26
|
{% endif %}
|
|
27
27
|
{% if group.rows %}
|
|
28
|
-
<
|
|
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
|
-
<
|
|
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
|
-
</
|
|
106
|
+
</div>
|
|
108
107
|
{% endfor %}
|
|
109
108
|
</div>
|
|
110
109
|
{% endfor %}
|
|
111
|
-
</
|
|
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(
|
|
440
|
-
'
|
|
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)
|
|
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', () => {
|
|
@@ -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 =>
|
|
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 =>
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|