@ons/design-system 55.1.0 → 56.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 (81) hide show
  1. package/components/access-code/_macro.njk +3 -3
  2. package/components/accordion/_macro.njk +1 -1
  3. package/components/address-input/_macro.njk +7 -7
  4. package/components/address-output/_macro.njk +7 -7
  5. package/components/autosuggest/_macro.njk +19 -19
  6. package/components/breadcrumbs/_macro.njk +3 -3
  7. package/components/button/_button.scss +49 -51
  8. package/components/button/_macro.njk +61 -35
  9. package/components/button/_macro.spec.js +24 -24
  10. package/components/button/button.spec.js +11 -11
  11. package/components/call-to-action/_macro.njk +1 -1
  12. package/components/card/_macro.njk +10 -10
  13. package/components/checkboxes/_checkbox-macro.njk +9 -9
  14. package/components/checkboxes/_macro.njk +10 -10
  15. package/components/checkboxes/checkbox-with-fieldset.js +6 -5
  16. package/components/checkboxes/checkboxes.dom.js +6 -9
  17. package/components/code-highlight/_macro.njk +1 -1
  18. package/components/collapsible/_macro.njk +7 -7
  19. package/components/date-input/_macro.njk +5 -5
  20. package/components/document-list/_macro.njk +29 -29
  21. package/components/duration/_macro.njk +9 -9
  22. package/components/duration/_macro.spec.js +0 -3
  23. package/components/error/_macro.njk +1 -1
  24. package/components/external-link/_macro.njk +1 -1
  25. package/components/feedback/_macro.njk +2 -2
  26. package/components/field/_macro.njk +5 -5
  27. package/components/fieldset/_fieldset.scss +5 -0
  28. package/components/fieldset/_macro.njk +8 -8
  29. package/components/footer/_macro.njk +19 -23
  30. package/components/footer/_macro.spec.js +0 -6
  31. package/components/header/_macro.njk +39 -41
  32. package/components/header/_macro.spec.js +4 -8
  33. package/components/hero/_macro.njk +15 -15
  34. package/components/icons/_macro.njk +2 -2
  35. package/components/images/_macro.njk +3 -3
  36. package/components/input/_input-type.scss +4 -0
  37. package/components/input/_macro.njk +41 -34
  38. package/components/input/_macro.spec.js +66 -59
  39. package/components/label/_macro.njk +1 -1
  40. package/components/language-selector/_macro.njk +1 -1
  41. package/components/lists/_macro.njk +22 -22
  42. package/components/message/_macro.njk +6 -6
  43. package/components/message-list/_macro.njk +1 -1
  44. package/components/metadata/_macro.njk +2 -2
  45. package/components/modal/_macro.njk +4 -4
  46. package/components/mutually-exclusive/_macro.njk +1 -1
  47. package/components/mutually-exclusive/mutually-exclusive.js +3 -1
  48. package/components/navigation/_macro.njk +11 -10
  49. package/components/navigation/_macro.spec.js +3 -2
  50. package/components/pagination/_macro.njk +3 -3
  51. package/components/panel/_macro.njk +37 -39
  52. package/components/panel/_macro.spec.js +1 -13
  53. package/components/promotional-banner/_macro.njk +2 -2
  54. package/components/question/_macro.njk +20 -20
  55. package/components/question/_macro.spec.js +2 -2
  56. package/components/question/_question.scss +1 -1
  57. package/components/quote/_macro.njk +2 -2
  58. package/components/radios/_macro.njk +8 -8
  59. package/components/radios/check-radios.js +5 -1
  60. package/components/related-content/_macro.njk +2 -2
  61. package/components/relationships/_macro.njk +4 -3
  62. package/components/search/_macro.njk +12 -2
  63. package/components/search/_macro.spec.js +27 -2
  64. package/components/section-navigation/_macro.njk +2 -2
  65. package/components/select/_macro.njk +8 -8
  66. package/components/share-page/_macro.njk +2 -2
  67. package/components/status/_macro.njk +2 -2
  68. package/components/summary/_macro.njk +25 -25
  69. package/components/table/_macro.njk +10 -10
  70. package/components/table-of-contents/_macro.njk +4 -4
  71. package/components/textarea/_macro.njk +8 -8
  72. package/components/timeline/_macro.njk +1 -1
  73. package/components/video/_macro.njk +1 -1
  74. package/css/census.css +1 -1
  75. package/css/ids.css +1 -1
  76. package/css/main.css +1 -1
  77. package/layout/_template.njk +35 -35
  78. package/package.json +1 -1
  79. package/scripts/main.es5.js +1 -1
  80. package/scripts/main.js +1 -1
  81. package/scss/patternlib.scss +2 -2
@@ -41,6 +41,7 @@ const EXAMPLE_WITH_SEARCH = {
41
41
  attributes: { a: 42 },
42
42
  classes: 'extra-search-button-class',
43
43
  iconType: 'search',
44
+ visuallyHideButtonText: true,
44
45
  },
45
46
  };
46
47
 
@@ -79,6 +80,13 @@ const EXAMPLE_INPUT_WITH_MUTUALLY_EXCLUSIVE_WITH_ERROR = {
79
80
  };
80
81
 
81
82
  describe('macro: input', () => {
83
+ it('passes jest-axe checks', async () => {
84
+ const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_WITH_LABEL));
85
+
86
+ const results = await axe($.html());
87
+ expect(results).toHaveNoViolations();
88
+ });
89
+
82
90
  it('has the provided `id` attribute', () => {
83
91
  const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_MINIMAL));
84
92
 
@@ -374,7 +382,7 @@ describe('macro: input', () => {
374
382
  });
375
383
 
376
384
  describe('prefix and suffix', () => {
377
- it('adds `aria-labelledby` attribute when `prefix` is provided', () => {
385
+ it('passes jest-axe checks', async () => {
378
386
  const $ = cheerio.load(
379
387
  renderComponent('input', {
380
388
  ...EXAMPLE_INPUT_MINIMAL,
@@ -385,10 +393,11 @@ describe('macro: input', () => {
385
393
  }),
386
394
  );
387
395
 
388
- expect($('.ons-input').attr('aria-labelledby')).toBe('example-prefix-id');
396
+ const results = await axe($.html());
397
+ expect(results).toHaveNoViolations();
389
398
  });
390
399
 
391
- it('renders prefix element from `prefix.title`', () => {
400
+ it('adds `aria-labelledby` attribute when `prefix` is provided', () => {
392
401
  const $ = cheerio.load(
393
402
  renderComponent('input', {
394
403
  ...EXAMPLE_INPUT_MINIMAL,
@@ -399,13 +408,7 @@ describe('macro: input', () => {
399
408
  }),
400
409
  );
401
410
 
402
- expect($('.ons-input-type--prefix .ons-js-input-abbr').attr('id')).toBe('example-prefix-id');
403
- expect($('.ons-input-type--prefix .ons-js-input-abbr').attr('title')).toBe('Example prefix title');
404
- expect(
405
- $('.ons-input-type--prefix .ons-js-input-abbr')
406
- .text()
407
- .trim(),
408
- ).toBe('Example prefix title');
411
+ expect($('.ons-input').attr('aria-labelledby')).toBe('example-prefix-id');
409
412
  });
410
413
 
411
414
  it('renders prefix element from `prefix.text`', () => {
@@ -443,20 +446,6 @@ describe('macro: input', () => {
443
446
  expect($('.ons-input-type--prefix').length).toBe(0);
444
447
  });
445
448
 
446
- it('does not render prefix element when `prefix.title` not set', () => {
447
- const $ = cheerio.load(
448
- renderComponent('input', {
449
- ...EXAMPLE_INPUT_MINIMAL,
450
- prefix: {
451
- text: 'Example prefix text',
452
- id: 'example-prefix-id',
453
- },
454
- }),
455
- );
456
-
457
- expect($('.ons-input-type--prefix').length).toBe(0);
458
- });
459
-
460
449
  it('adds `aria-labelledby` attribute when `suffix` is provided', () => {
461
450
  const $ = cheerio.load(
462
451
  renderComponent('input', {
@@ -471,13 +460,14 @@ describe('macro: input', () => {
471
460
  expect($('.ons-input').attr('aria-labelledby')).toBe('example-suffix-id');
472
461
  });
473
462
 
474
- it('renders suffix element from `suffix.title`', () => {
463
+ it('renders suffix element from `suffix.text`', () => {
475
464
  const $ = cheerio.load(
476
465
  renderComponent('input', {
477
466
  ...EXAMPLE_INPUT_MINIMAL,
478
467
  suffix: {
479
468
  id: 'example-suffix-id',
480
469
  title: 'Example suffix title',
470
+ text: 'Example suffix text',
481
471
  },
482
472
  }),
483
473
  );
@@ -488,57 +478,51 @@ describe('macro: input', () => {
488
478
  $('.ons-js-input-abbr')
489
479
  .text()
490
480
  .trim(),
491
- ).toBe('Example suffix title');
481
+ ).toBe('Example suffix text');
492
482
  });
493
483
 
494
- it('renders suffix element from `suffix.text`', () => {
484
+ it('does not render suffix element when `suffix.id` not set', () => {
495
485
  const $ = cheerio.load(
496
486
  renderComponent('input', {
497
487
  ...EXAMPLE_INPUT_MINIMAL,
498
488
  suffix: {
499
- id: 'example-suffix-id',
500
489
  title: 'Example suffix title',
501
490
  text: 'Example suffix text',
502
491
  },
503
492
  }),
504
493
  );
505
494
 
506
- expect($('.ons-js-input-abbr').attr('id')).toBe('example-suffix-id');
507
- expect($('.ons-js-input-abbr').attr('title')).toBe('Example suffix title');
508
- expect(
509
- $('.ons-js-input-abbr')
510
- .text()
511
- .trim(),
512
- ).toBe('Example suffix text');
495
+ expect($('.ons-input').length).toBe(0);
513
496
  });
514
- });
515
497
 
516
- it('does not render suffix element when `suffix.id` not set', () => {
517
- const $ = cheerio.load(
518
- renderComponent('input', {
519
- ...EXAMPLE_INPUT_MINIMAL,
520
- suffix: {
521
- title: 'Example suffix title',
522
- text: 'Example suffix text',
523
- },
524
- }),
525
- );
498
+ it('renders an `abbr` tag when `title` set', () => {
499
+ const $ = cheerio.load(
500
+ renderComponent('input', {
501
+ ...EXAMPLE_INPUT_MINIMAL,
502
+ suffix: {
503
+ text: 'Example suffix text',
504
+ title: 'Example suffix title',
505
+ id: 'example-suffix-id',
506
+ },
507
+ }),
508
+ );
526
509
 
527
- expect($('.ons-input').length).toBe(0);
528
- });
510
+ expect($('.ons-input + abbr').length).toBe(1);
511
+ });
529
512
 
530
- it('does not render suffix element when `suffix.title` not set', () => {
531
- const $ = cheerio.load(
532
- renderComponent('input', {
533
- ...EXAMPLE_INPUT_MINIMAL,
534
- suffix: {
535
- text: 'Example suffix text',
536
- id: 'example-suffix-id',
537
- },
538
- }),
539
- );
513
+ it('renders a `span` tag when `title` not set', () => {
514
+ const $ = cheerio.load(
515
+ renderComponent('input', {
516
+ ...EXAMPLE_INPUT_MINIMAL,
517
+ suffix: {
518
+ text: 'Example suffix text',
519
+ id: 'example-suffix-id',
520
+ },
521
+ }),
522
+ );
540
523
 
541
- expect($('.ons-input').length).toBe(0);
524
+ expect($('.ons-input + span').length).toBe(1);
525
+ });
542
526
  });
543
527
 
544
528
  describe('search', () => {
@@ -557,6 +541,7 @@ describe('macro: input', () => {
557
541
  attributes: { a: 42 },
558
542
  classes: 'extra-search-button-class',
559
543
  iconType: 'search',
544
+ visuallyHideButtonText: true,
560
545
  },
561
546
  });
562
547
  });
@@ -577,6 +562,21 @@ describe('macro: input', () => {
577
562
  });
578
563
 
579
564
  describe('with character limit', () => {
565
+ it('passes jest-axe checks', async () => {
566
+ const $ = cheerio.load(
567
+ renderComponent('input', {
568
+ ...EXAMPLE_INPUT_WITH_CHARACTER_LIMIT,
569
+ label: {
570
+ id: 'example-input-label',
571
+ text: 'Example input label',
572
+ },
573
+ }),
574
+ );
575
+
576
+ const results = await axe($.html());
577
+ expect(results).toHaveNoViolations();
578
+ });
579
+
580
580
  it('has the provided minimum length', () => {
581
581
  const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_WITH_CHARACTER_LIMIT));
582
582
 
@@ -673,6 +673,13 @@ describe('macro: input', () => {
673
673
  });
674
674
 
675
675
  describe('mutually exclusive', () => {
676
+ it('passes jest-axe checks', async () => {
677
+ const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_WITH_MUTUALLY_EXCLUSIVE_WITH_ERROR));
678
+
679
+ const results = await axe($.html());
680
+ expect(results).toHaveNoViolations();
681
+ });
682
+
676
683
  it('has the `ons-js-exclusive-group-item` class', () => {
677
684
  const $ = cheerio.load(renderComponent('input', EXAMPLE_INPUT_WITH_MUTUALLY_EXCLUSIVE_WITH_ERROR));
678
685
 
@@ -22,7 +22,7 @@
22
22
  {% if params.description %}aria-describedby="{{ descriptionID }}"{% endif %}
23
23
  {% if params.for %} for="{{ params.for }}"{% endif %}
24
24
  {% if params.id %} id="{{ params.id }}"{% endif %}
25
- {% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}
25
+ {% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}
26
26
  >
27
27
 
28
28
  {{- params.text | safe -}}
@@ -5,7 +5,7 @@
5
5
  <ul class="ons-language-links{% if languageNumber and languageNumber != 2 %} ons-u-d-no@xxs@m{% endif %}">
6
6
  {% for language in alternativeLanguages %}
7
7
  <li class="ons-language-links__item">
8
- <a href="{{ language.url }}" lang="{{ language.ISOCode }}" {% if language.attributes is defined and language.attributes %}{% for attribute, value in (language.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}>{% if language.abbrText %}<span class="ons-u-d-no@s">{{ language.abbrText }}</span><span class="ons-u-d-no@xxs@s">{{ language.text }}</span>{% else %}{{ language.text }}{% endif %}</a>
8
+ <a href="{{ language.url }}" lang="{{ language.ISOCode }}" {% if language.attributes %}{% for attribute, value in (language.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}>{% if language.abbrText %}<span class="ons-u-d-no@s">{{ language.abbrText }}</span><span class="ons-u-d-no@xxs@s">{{ language.text }}</span>{% else %}{{ language.text }}{% endif %}</a>
9
9
  </li>
10
10
  {% endfor %}
11
11
  </ul>
@@ -2,44 +2,44 @@
2
2
  {% set variants = params.variants if params.variants else '' %}
3
3
  {% set listLength = params.itemsList | length %}
4
4
 
5
- {% if params.itemsList[0] is defined and params.itemsList[0].prefix %}
5
+ {% if params.itemsList[0].prefix %}
6
6
  {% set otherClasses = 'ons-list--bare ons-list--prefix' %}
7
- {% elif params.itemsList[0] is defined and params.itemsList[0].suffix %}
7
+ {% elif params.itemsList[0].suffix %}
8
8
  {% set otherClasses = 'ons-list--bare ons-list--suffix' %}
9
- {% elif params.itemsList[0] is defined and params.iconPosition is defined and params.iconPosition %}
9
+ {% elif params.iconPosition %}
10
10
  {% set otherClasses = 'ons-list--bare ons-list--icons' %}
11
11
  {% set iconType = params.iconType if params.iconType else '' %}
12
12
  {% else %}
13
13
  {% set otherClasses = '' %}
14
14
  {% endif %}
15
15
 
16
- {% if params.element is defined and params.element and listLength > 1 %}
16
+ {% if params.element and listLength > 1 %}
17
17
  {% set listEl = params.element | lower %}
18
- {% elif (params.element is defined and params.element == 'ol') and listLength < 2 %}
18
+ {% elif (params.element == 'ol') and listLength < 2 %}
19
19
  {% set listEl = 'p' %}
20
20
  {% else %}
21
21
  {% set listEl = 'ul' %}
22
22
  {% endif %}
23
- <{{listEl}} {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %} class="ons-list{% if listEl == 'p' %} ons-list--p{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes -}}{% endif %}{% if params.variants is defined and params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-list--{{ variant }}{% endfor %}{% else %} ons-list--{{ params.variants }}{% endif %}{% endif %}{% if otherClasses %} {{ otherClasses -}}{% endif %}"{% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}>
23
+ <{{listEl}} {% if params.id %}id="{{ params.id }}"{% endif %} class="ons-list{% if listEl == 'p' %} ons-list--p{% endif %}{% if params.classes %} {{ params.classes -}}{% endif %}{% if params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-list--{{ variant }}{% endfor %}{% else %} ons-list--{{ params.variants }}{% endif %}{% endif %}{% if otherClasses %} {{ otherClasses -}}{% endif %}"{% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}>
24
24
  {%- for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) -%}
25
25
  {% if listLength > 1 or listEl == 'ul' %}
26
- <li class="ons-list__item{% if item.listClasses is defined and item.listClasses %} {{ item.listClasses }}{% endif %}"{% if item.current is defined and item.current %} aria-current="true"{% endif %}>
26
+ <li class="ons-list__item{% if item.listClasses %} {{ item.listClasses }}{% endif %}"{% if item.current %} aria-current="true"{% endif %}>
27
27
  {% endif %}
28
28
  {% set itemText = item.text %}
29
- {% set itemIconType = item.iconType if item.iconType is defined and item.iconType else iconType %}
29
+ {% set itemIconType = item.iconType if item.iconType else iconType %}
30
30
 
31
31
  {# For Craft support we also support title and navigation title #}
32
- {% if item.navigationTitle is defined and item.navigationTitle %}
32
+ {% if item.navigationTitle %}
33
33
  {% set itemText = item.navigationTitle %}
34
- {% elif item.title is defined and item.title %}
34
+ {% elif item.title %}
35
35
  {% set itemText = item.title %}
36
36
  {% endif %}
37
37
 
38
- {%- if item.prefix is defined and item.prefix or (params.iconPosition is defined and params.iconPosition == 'before') -%}
38
+ {%- if item.prefix or (params.iconPosition == 'before') -%}
39
39
  <span class="ons-list__prefix"{% if listEl != 'ol' %} aria-hidden="true"{% endif %}>
40
- {%- if item.prefix is defined and item.prefix -%}
40
+ {%- if item.prefix -%}
41
41
  {{- item.prefix -}}.
42
- {% elif params.iconPosition is defined and params.iconPosition == 'before' %}
42
+ {% elif params.iconPosition == 'before' %}
43
43
  {% from "components/icons/_macro.njk" import onsIcon %}
44
44
  {{
45
45
  onsIcon({
@@ -50,8 +50,8 @@
50
50
  {%- endif -%}
51
51
  </span>
52
52
  {%- endif -%}
53
- {%- if item.url is defined and item.url and item.current != true -%}
54
- {%- if item.external is defined and item.external -%}
53
+ {%- if item.url and item.current != true -%}
54
+ {%- if item.external -%}
55
55
  {% from "components/external-link/_macro.njk" import onsExternalLink %}
56
56
  {{
57
57
  onsExternalLink({
@@ -60,21 +60,21 @@
60
60
  })
61
61
  }}
62
62
  {%- else -%}
63
- <a href="{{ item.url }}" class="ons-list__link{% if item.variants == 'inPageLink' %} ons-js-inpagelink{% endif %}{% if item.classes is defined and item.classes %} {{ item.classes }}{% endif %}"{% if item.target is defined and item.target %} target="{{ item.target }}"{% endif %}{% if item.attributes is defined and item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %} {{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}>
64
- {%- if item.prefix is defined and item.prefix -%}<span class="ons-u-vh">{{- item.prefix -}}</span>{%- endif -%} {{- itemText | safe -}}
65
- {%- if item.target is defined and item.target == "_blank" -%}<span class="ons-u-vh"> ({{- item.screenreaderMessage | default("opens in a new tab") -}})</span>{%- endif -%}
63
+ <a href="{{ item.url }}" class="ons-list__link{% if item.variants == 'inPageLink' %} ons-js-inpagelink{% endif %}{% if item.classes %} {{ item.classes }}{% endif %}"{% if item.target %} target="{{ item.target }}"{% endif %}{% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %} {{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}>
64
+ {%- if item.prefix -%}<span class="ons-u-vh">{{- item.prefix -}}</span>{%- endif -%} {{- itemText | safe -}}
65
+ {%- if item.target == "_blank" -%}<span class="ons-u-vh"> ({{- item.screenreaderMessage | default("opens in a new tab") -}})</span>{%- endif -%}
66
66
  </a>
67
67
  {%- endif -%}
68
68
  {%- else -%}
69
69
  {{- itemText | safe -}}
70
70
  {%- endif -%}
71
- {%- if item.suffix is defined and item.suffix or (params.iconPosition is defined and params.iconPosition == 'after') -%}
71
+ {%- if item.suffix or (params.iconPosition == 'after') -%}
72
72
  <span class="ons-list__suffix"{% if listEl != 'ol' %} aria-hidden="true"{% endif %}>
73
- {%- if item.suffix is defined and item.suffix -%}
73
+ {%- if item.suffix -%}
74
74
  {{- item.suffix -}}
75
- {%- elif (item.index is defined and item.index and listEl != 'ol') or (item.index is defined and item.index and listEl == 'ol' and 'bare' in variants) -%}
75
+ {%- elif (item.index and listEl != 'ol') or (item.index and listEl == 'ol' and 'bare' in variants) -%}
76
76
  {{- loop.index -}}
77
- {% elif params.iconPosition is defined and params.iconPosition == 'after' %}
77
+ {% elif params.iconPosition == 'after' %}
78
78
  {% from "components/icons/_macro.njk" import onsIcon %}
79
79
  {{
80
80
  onsIcon({
@@ -1,21 +1,21 @@
1
1
  {%- macro onsMessage(params) -%}
2
2
  <div class="ons-message ons-message--{{ params.type }}">
3
3
  <div class="ons-message__head">
4
- <dl class="ons-message__metadata" {% if params.id is defined and params.id %} id="{{ params.id }}"{% endif %} {% if params.name is defined and params.name %} name="{{ params.name }}"{% endif %}>
4
+ <dl class="ons-message__metadata" {% if params.id %} id="{{ params.id }}"{% endif %} {% if params.name %} name="{{ params.name }}"{% endif %}>
5
5
  <div class="ons-message__sender">
6
6
  <dt class="ons-message__term ons-u-fw-b">{{ params.fromLabel }}:</dt>
7
- <dd class="ons-message__value ons-u-fw-b" {% if params.fromId is defined and params.fromId %} id="{{ params.fromId }}"{% endif %} {% if params.fromName is defined and params.fromName %} name="{{ params.fromName }}"{% endif %}>{{ params.fromValue }}</dd>
7
+ <dd class="ons-message__value ons-u-fw-b" {% if params.fromId %} id="{{ params.fromId }}"{% endif %} {% if params.fromName %} name="{{ params.fromName }}"{% endif %}>{{ params.fromValue }}</dd>
8
8
  </div>
9
9
  <div class="ons-message__timestamp">
10
10
  <dt class="ons-message__term ons-u-fs-s">{{ params.sentLabel }}:</dt>
11
- <dd class="ons-message__value ons-u-fs-s" {% if params.sentId is defined and params.sentId %} id="{{ params.sentId }}"{% endif %} {% if params.sentName is defined and params.sentName %} name="{{ params.sentName }}"{% endif %}>{{ params.sentValue }}</dd>
11
+ <dd class="ons-message__value ons-u-fs-s" {% if params.sentId %} id="{{ params.sentId }}"{% endif %} {% if params.sentName %} name="{{ params.sentName }}"{% endif %}>{{ params.sentValue }}</dd>
12
12
  </div>
13
13
  </dl>
14
- {% if params.unreadLink is defined and params.unreadLink %}
15
- <a class="ons-message__unread-link" {% if params.unreadLinkId is defined and params.unreadLinkId %}id="{{ params.unreadLinkId }}"{% endif %} href="{{ params.unreadLink }}">{{ params.unreadLinkText }}</a>
14
+ {% if params.unreadLink %}
15
+ <a class="ons-message__unread-link" {% if params.unreadLinkId %}id="{{ params.unreadLinkId }}"{% endif %} href="{{ params.unreadLink }}">{{ params.unreadLinkText }}</a>
16
16
  {% endif %}
17
17
  </div>
18
- <div class="ons-message__body" {% if params.messageID is defined and params.messageID %} id="{{ params.messageID }}"{% endif %} {% if params.messageName is defined and params.messageName %} name="{{ params.messageName }}"{% endif %}>
18
+ <div class="ons-message__body" {% if params.messageID %} id="{{ params.messageID }}"{% endif %} {% if params.messageName %} name="{{ params.messageName }}"{% endif %}>
19
19
  {{ caller() }}
20
20
  </div>
21
21
  </div>
@@ -4,7 +4,7 @@
4
4
  <li class="ons-message-item" aria-labelledby="{{ message.id }}">
5
5
  <h3 class="ons-message-item__subject" id="{{ message.id }}">
6
6
  <a href="{{ message.url }}" class="ons-u-fs-r--b">{{ message.subject }}</a>
7
- {% if message.unread is defined and message.unread %}<span class="ons-message-item__unread ons-u-fs-s">({{ params.unreadText }})</span>{% endif %}
7
+ {% if message.unread %}<span class="ons-message-item__unread ons-u-fs-s">({{ params.unreadText }})</span>{% endif %}
8
8
  </h3>
9
9
  <dl class="ons-message-item__metadata" aria-label="{{ params.ariaLabelMetaData | default("Message metadata") }}">
10
10
  <dt class="ons-message-item__metadata-term ons-message-item__metadata-term--from ons-u-vh">{{ params.fromLabel }}:</dt>
@@ -1,12 +1,12 @@
1
1
  {% macro onsMetadata(params) %}
2
- <dl class="ons-metadata ons-metadata__list ons-grid ons-grid--gutterless ons-u-cf{{ (' ' + params.classes) if params.classes is defined and params.classes }}"{% if params.id is defined and params.id %} id="{{ params.id }}" {% endif %}{% if params.metadataLabel is defined and params.metadataLabel %} title="{{ params.metadataLabel }}" aria-label="{{ params.metadataLabel }}"{% endif %}>
2
+ <dl class="ons-metadata ons-metadata__list ons-grid ons-grid--gutterless ons-u-cf{{ (' ' + params.classes) if params.classes }}"{% if params.id %} id="{{ params.id }}" {% endif %}{% if params.metadataLabel %} title="{{ params.metadataLabel }}" aria-label="{{ params.metadataLabel }}"{% endif %}>
3
3
  {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
4
4
  {% if item.term | length %}
5
5
  <dt class="ons-metadata__term ons-grid__col ons-col-{{ params.termCol }}@m">{{ item.term }}</dt>
6
6
  {% endif %}
7
7
  {% for description in item.descriptions %}
8
8
  {% if description.description | length %}
9
- <dd {% if description.id is defined and description.id %}id="{{ description.id }}" {% endif %}class="ons-metadata__value ons-grid__col ons-col-{{ params.descriptionCol }}@m">{{ description.description }}</dd>
9
+ <dd {% if description.id %}id="{{ description.id }}" {% endif %}class="ons-metadata__value ons-grid__col ons-col-{{ params.descriptionCol }}@m">{{ description.description }}</dd>
10
10
  {% endif %}
11
11
  {% endfor %}
12
12
  {% endfor %}
@@ -1,19 +1,19 @@
1
1
  {% macro onsModal(params) %}
2
2
  {% set modalId = params.id | default('dialog') %}
3
- <dialog class="ons-modal ons-js-modal {{ params.classes if params.classes is defined and params.classes else '' }}"
3
+ <dialog class="ons-modal ons-js-modal {{ params.classes if params.classes else '' }}"
4
4
  id="{{ modalId }}"
5
5
  role="dialog"
6
6
  aria-labelledby="ons-modal-title"
7
- {% if params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}
7
+ {% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %} {{attribute}}="{{value}}"{% endfor %}{% endif %}
8
8
  >
9
9
  <div class="ons-modal__content">
10
10
  <h2 id="ons-modal-title" class="ons-modal__title">
11
11
  {{ params.title }}
12
12
  </h2>
13
13
  <div class="ons-modal__body">
14
- {{ (params.body if params.body is defined and params.body else "") | safe }}{{ caller() if caller }}
14
+ {{ (params.body if params.body else "") | safe }}{{ caller() if caller }}
15
15
  </div>
16
- {% if params.btnText is defined and params.btnText %}
16
+ {% if params.btnText %}
17
17
  {% from "components/button/_macro.njk" import onsButton %}
18
18
  {{ onsButton({
19
19
  "text": params.btnText,
@@ -21,7 +21,7 @@
21
21
  }) %}
22
22
  <div class="ons-js-mutually-exclusive ons-mutually-exclusive">
23
23
  {{ content | safe }}
24
- {% if params.autosuggestResults is defined and params.autosuggestResults %}
24
+ {% if params.autosuggestResults %}
25
25
  {{ params.autosuggestResults | safe }}
26
26
  {% endif %}
27
27
  {% if exclusiveOptionsLength == 1 %}
@@ -106,8 +106,10 @@ export default class MutuallyExclusive {
106
106
  let labelText;
107
107
 
108
108
  if (label) {
109
- if (label.classList.contains(inputAbbrClass)) {
109
+ if (label.classList.contains(inputAbbrClass) && label.querySelector('abbr')) {
110
110
  labelText = label.getAttribute('title');
111
+ } else if (label.classList.contains(inputAbbrClass) && label.querySelector('span')) {
112
+ labelText = label.querySelector('span').innerText;
111
113
  } else if (label.classList.contains(inputLegendClass) && label.querySelector('h1')) {
112
114
  labelText = label.querySelector('h1').innerText;
113
115
  } else {
@@ -3,7 +3,7 @@
3
3
  {% from "components/autosuggest/_macro.njk" import onsAutosuggest %}
4
4
  <div class="ons-navigation-wrapper{% if params.variants == 'neutral' %} ons-navigation-wrapper--neutral{% endif %}">
5
5
  <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.fullWidth or params.navigation.fullWidth }}{{ ' ons-container--wide' if params.wide or params.navigation.wide }}">
6
- {% if params.navigation.siteSearchAutosuggest is defined and params.navigation.siteSearchAutosuggest and isPatternLib is defined and isPatternLib %}
6
+ {% if params.navigation.siteSearchAutosuggest and isPatternLib %}
7
7
  <div class="ons-navigation-search ons-js-navigation-search">
8
8
  {% set autosuggestClasses = "ons-input-search ons-input-search--icon" %}
9
9
  {% set autosuggestLabelClasses = "ons-u-pl-m" %}
@@ -42,30 +42,31 @@
42
42
  <ul class="ons-navigation__list">
43
43
  {% for item in (params.navigation.itemsList if params.navigation.itemsList is iterable else params.navigation.itemsList.items()) %}
44
44
  <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.currentPath) or (item.url != (params.navigation.siteBasePath | default('/')) and item.url in params.navigation.currentPath) }}">
45
- <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}{% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %}>{{ item.title }}</a>
45
+ <a class="ons-navigation__link" href="{{ item.url }}" {% if item.id %}id="{{ item.id }}" {% endif %}{% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %}>{{ item.title }}</a>
46
46
  </li>
47
47
  {% endfor %}
48
48
  </ul>
49
49
  </nav>
50
50
  </div>
51
51
  </div>
52
- {% if params.navigation.subNavigation is defined and params.navigation.subNavigation %}
53
- <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes is defined and params.navigation.subNavigation.classes }}" id="{{ params.navigation.subNavigation.id }}" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
52
+ {% if params.navigation.subNavigation %}
53
+ <nav class="ons-navigation ons-navigation--sub ons-u-d-no@xxs@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes }}" id="{{ params.navigation.subNavigation.id }}" aria-label="{{ params.navigation.subNavigation.ariaLabel | default("Section menu") }}" data-analytics="header-section-navigation">
54
54
  <div class="ons-container ons-container--gutterless@xxs@l{{ ' ons-container--full-width' if params.navigation.fullWidth }}{{ ' ons-container--wide' if params.navigation.wide }}">
55
55
  <ul class="ons-navigation__list ons-navigation__list">
56
56
  {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
57
57
  <li class="ons-navigation__item {{ item.classes }}{{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url != (params.navigation.subNavigation.siteBasePath | default('/')) and item.url in params.navigation.subNavigation.currentPath) }}">
58
- <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id is defined and item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
58
+ <a class="ons-navigation__link ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}" {% endif %}>{{ item.title }}</a>
59
59
  </li>
60
60
  {% endfor %}
61
61
  </ul>
62
62
  </div>
63
63
  </nav>
64
- <div class="ons-u-d-no@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes is defined and params.navigation.subNavigation.classes }}">
64
+ <div class="ons-u-d-no@l{{ ' ' + params.navigation.subNavigation.classes if params.navigation.subNavigation.classes }}">
65
65
  {{ onsButton({
66
66
  "text": params.navigation.currentPageTitle,
67
- "classes": "ons-u-d-no ons-js-sub-navigation-button ons-btn--dropdown",
68
- "buttonStyle": "mobile",
67
+ "classes": "ons-u-d-no ons-js-sub-navigation-button",
68
+ "type": "button",
69
+ "variants": ["mobile", "dropdown"],
69
70
  "attributes": {
70
71
  "aria-label": "Toggle section navigation",
71
72
  "aria-controls": params.navigation.subNavigation.id,
@@ -80,14 +81,14 @@
80
81
  </li>
81
82
  {% for item in (params.navigation.subNavigation.itemsList if params.navigation.subNavigation.itemsList is iterable else params.navigation.subNavigation.itemsList.items()) %}
82
83
  <li class="ons-navigation__item {{ ' ons-navigation__item--active' if (item.url == params.navigation.subNavigation.currentPath) or (item.url != (params.navigation.subNavigation.siteBasePath | default('/')) and item.url in params.navigation.subNavigation.currentPath) }}">
83
- <a class="ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel is defined and item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id is defined and item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
84
+ <a class="ons-navigation__link" href="{{ item.url }}" {% if item.ariaLabel %}aria-label="{{ item.ariaLabel }}" {% endif %} {% if item.id %}id="{{ item.id }}--mobile" {% endif %}>{{ item.title }}</a>
84
85
  {% if item.sections %}
85
86
  {% for section in item.sections %}
86
87
  {% if section.sectionTitle %}<h3 class="ons-navigation__list-header">{{ section.sectionTitle }}</h3>{% endif %}
87
88
  <ul class="ons-navigation__list ons-navigation__list--child ons-list--dashed ons-u-ml-s ons-u-mt-xs">
88
89
  {% for child in section.children %}
89
90
  <li class="ons-navigation__item ons-list__item {{ ' ons-navigation__item--active' if (child.url == params.navigation.subNavigation.currentPath) or (child.url != (params.navigation.subNavigation.sitsiteBasePatheBasePath | default('/')) and child.url in params.navigation.subNavigation.currentPath) }}">
90
- <a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel is defined and child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id is defined and child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
91
+ <a class="ons-navigation__link ons-navigation__link--section" href="{{ child.url }}" {% if child.ariaLabel %}aria-label="{{ child.ariaLabel }}" {% endif %} {% if child.id %}id="{{ child.id }}" {% endif %}>{{ child.title }}</a>
91
92
  </li>
92
93
  {% endfor %}
93
94
  </ul>
@@ -206,8 +206,9 @@ describe('macro: navigation', () => {
206
206
 
207
207
  expect(buttonSpy.occurrences).toContainEqual({
208
208
  text: 'Main nav item 2',
209
- classes: 'ons-u-d-no ons-js-sub-navigation-button ons-btn--dropdown',
210
- buttonStyle: 'mobile',
209
+ classes: 'ons-u-d-no ons-js-sub-navigation-button',
210
+ variants: ['mobile', 'dropdown'],
211
+ type: 'button',
211
212
  attributes: {
212
213
  'aria-label': 'Toggle section navigation',
213
214
  'aria-controls': 'sub-nav',
@@ -1,7 +1,7 @@
1
1
  {% macro onsPagination(params) %}
2
2
  {% set currentPageIndex = "" %}
3
3
  {% for page in params.pages %}
4
- {% if page.current is defined and page.current %}
4
+ {% if page.current %}
5
5
  {% set currentPageIndex = loop.index %}
6
6
  {% endif %}
7
7
  {% endfor %}
@@ -25,7 +25,7 @@
25
25
  {% endif %}
26
26
 
27
27
 
28
- <nav class="ons-pagination {{ params.classes }}{% if params.hideRangeIndicator is defined and params.hideRangeIndicator %} ons-pagination--no-indicator{% endif %}" aria-label="Pagination ({{ position }})">
28
+ <nav class="ons-pagination {{ params.classes }}{% if params.hideRangeIndicator %} ons-pagination--no-indicator{% endif %}" aria-label="Pagination ({{ position }})">
29
29
  <div class="ons-pagination__position">{{ position }}</div>
30
30
  <ul class="ons-pagination__items">
31
31
  {% if currentPageIndex != 1 %}
@@ -45,7 +45,7 @@
45
45
  {% endif %}
46
46
  {% for page in params.pages %}
47
47
  {% if loop.index >= middlePagesStart and loop.index <= middlePagesEnd %}
48
- <li class="ons-pagination__item{% if page.current is defined and page.current == true %} ons-pagination__item--current{% endif %}">
48
+ <li class="ons-pagination__item{% if page.current == true %} ons-pagination__item--current{% endif %}">
49
49
  <a href="{{ page.url }}" class="ons-pagination__link"
50
50
  {%- if page.current -%}
51
51
  aria-current="true" aria-label="Current page ({{ position }})"