@ons/design-system 55.1.0 → 55.2.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 (70) 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 +1 -1
  8. package/components/button/_macro.njk +24 -24
  9. package/components/call-to-action/_macro.njk +1 -1
  10. package/components/card/_macro.njk +10 -10
  11. package/components/checkboxes/_checkbox-macro.njk +9 -9
  12. package/components/checkboxes/_macro.njk +10 -10
  13. package/components/checkboxes/checkbox-with-fieldset.js +6 -5
  14. package/components/checkboxes/checkboxes.dom.js +6 -9
  15. package/components/code-highlight/_macro.njk +1 -1
  16. package/components/collapsible/_macro.njk +7 -7
  17. package/components/date-input/_macro.njk +5 -5
  18. package/components/document-list/_macro.njk +29 -29
  19. package/components/duration/_macro.njk +9 -9
  20. package/components/duration/_macro.spec.js +0 -3
  21. package/components/error/_macro.njk +1 -1
  22. package/components/external-link/_macro.njk +1 -1
  23. package/components/feedback/_macro.njk +2 -2
  24. package/components/field/_macro.njk +5 -5
  25. package/components/fieldset/_macro.njk +8 -8
  26. package/components/footer/_macro.njk +17 -17
  27. package/components/header/_macro.njk +33 -33
  28. package/components/hero/_macro.njk +15 -15
  29. package/components/icons/_macro.njk +2 -2
  30. package/components/images/_macro.njk +3 -3
  31. package/components/input/_input-type.scss +4 -0
  32. package/components/input/_macro.njk +40 -34
  33. package/components/input/_macro.spec.js +64 -59
  34. package/components/label/_macro.njk +1 -1
  35. package/components/language-selector/_macro.njk +1 -1
  36. package/components/lists/_macro.njk +22 -22
  37. package/components/message/_macro.njk +6 -6
  38. package/components/message-list/_macro.njk +1 -1
  39. package/components/metadata/_macro.njk +2 -2
  40. package/components/modal/_macro.njk +4 -4
  41. package/components/mutually-exclusive/_macro.njk +1 -1
  42. package/components/mutually-exclusive/mutually-exclusive.js +3 -1
  43. package/components/navigation/_macro.njk +8 -8
  44. package/components/pagination/_macro.njk +3 -3
  45. package/components/panel/_macro.njk +37 -39
  46. package/components/panel/_macro.spec.js +1 -13
  47. package/components/promotional-banner/_macro.njk +2 -2
  48. package/components/question/_macro.njk +18 -18
  49. package/components/quote/_macro.njk +2 -2
  50. package/components/radios/_macro.njk +8 -8
  51. package/components/radios/check-radios.js +5 -1
  52. package/components/related-content/_macro.njk +2 -2
  53. package/components/relationships/_macro.njk +2 -2
  54. package/components/section-navigation/_macro.njk +2 -2
  55. package/components/select/_macro.njk +8 -8
  56. package/components/share-page/_macro.njk +2 -2
  57. package/components/status/_macro.njk +2 -2
  58. package/components/summary/_macro.njk +25 -25
  59. package/components/table/_macro.njk +10 -10
  60. package/components/table-of-contents/_macro.njk +4 -4
  61. package/components/textarea/_macro.njk +8 -8
  62. package/components/timeline/_macro.njk +1 -1
  63. package/components/video/_macro.njk +1 -1
  64. package/css/census.css +1 -1
  65. package/css/ids.css +1 -1
  66. package/css/main.css +1 -1
  67. package/layout/_template.njk +35 -35
  68. package/package.json +1 -1
  69. package/scripts/main.es5.js +1 -1
  70. package/scripts/main.js +1 -1
@@ -1,6 +1,6 @@
1
1
  {% macro onsPanel(params) %}
2
2
 
3
- {% if params is defined and params and params.classes is defined and params.classes %}
3
+ {% if params.classes %}
4
4
  {% set classes = ' ' + params.classes %}
5
5
  {% endif %}
6
6
 
@@ -8,37 +8,37 @@
8
8
  {% set noTitleClass = ' ons-panel--no-title' %}
9
9
  {% endif %}
10
10
 
11
- {% if params is defined and params and params.type is defined and params.type %}
11
+ {% if params.type %}
12
12
  {% set typeClass = ' ons-panel--' + params.type %}
13
13
  {% else %}
14
14
  {% set typeClass = ' ons-panel--info' %}
15
15
  {% endif %}
16
16
 
17
- {% if params is defined and params.type == "warn-branded" %}
17
+ {% if params.type == "warn-branded" %}
18
18
  {% set containerClass = 'ons-branded-warning' %}
19
19
  {% endif %}
20
20
 
21
- {% if params is defined and params.type == "announcement" %}
21
+ {% if params.type == "announcement" %}
22
22
  {% set containerClass = 'ons-announcement' %}
23
23
  {% endif %}
24
24
 
25
- {% if params is defined and params and params.spacious is defined and params.spacious %}
25
+ {% if params.spacious %}
26
26
  {% set spaciousClass = ' ons-panel--spacious' %}
27
27
  {% endif %}
28
28
 
29
- {% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
29
+ {% if params.type == "warn-branded" or params.type == "announcement" %}
30
30
  <div class="{{containerClass}}">
31
31
  <div class="ons-container">
32
32
  {% endif %}
33
33
 
34
- <div {% if (params.type == 'error' and params.title) or params.type == 'success' %}aria-labelledby="alert" role="alert" tabindex="-1" {% if params.dsExample != true %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params is defined and params and params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params is defined and params and params.attributes is mapping and params.attributes.items is defined and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params is defined and params and params.id is defined and params.id %} id="{{params.id}}"{% endif %}>
34
+ <div {% if (params.type == 'error' and params.title) or params.type == 'success' %}aria-labelledby="alert" role="alert" tabindex="-1" {% if params.dsExample != true %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params and params.attributes %}{% for attribute, value in (params.attributes.items() if params and params.attributes is mapping and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params and params.id %} id="{{params.id}}"{% endif %}>
35
35
 
36
- {% if params is defined and params and params.type == "warn" or params.type == "warn-branded" %}
36
+ {% if params.type == "warn" or params.type == "warn-branded" %}
37
37
  <span class="ons-panel__icon" aria-hidden="true">!</span>
38
38
  <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Warning: ") }}</span>
39
39
  {% endif %}
40
40
 
41
- {% if params is defined and params and params.type == "announcement" %}
41
+ {% if params.type == "announcement" %}
42
42
  {% from "components/icons/_macro.njk" import onsIcon %}
43
43
  <span class="ons-panel__icon" aria-hidden="true">
44
44
  {{
@@ -50,45 +50,43 @@
50
50
  <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Announcement: ") }}</span>
51
51
  {% endif %}
52
52
 
53
- {% if params is defined and params %}
54
- {% if params.title is defined and params.title %}
55
- {% if params is defined and params and params.type == 'error' %}
56
- {% set defaultTitleTag = "h2" %}
57
- {% else %}
58
- {% set defaultTitleTag = "div" %}
59
- {% endif %}
60
- {% set titleTag = params.titleTag | default(defaultTitleTag) %}
61
- <div class="ons-panel__header">
62
- <{{ titleTag }} id="alert"{% if params.type %} data-qa="{{ params.type }}-header"{% endif %} class="ons-panel__title ons-u-fs-r--b">{{ params.title | safe }}</{{ titleTag }}>
63
- </div>
53
+ {% if params.title %}
54
+ {% if params.type == 'error' %}
55
+ {% set defaultTitleTag = "h2" %}
64
56
  {% else %}
65
- {% if params.type is not defined or params.type == "branded" or params.type == "info" %}
66
- <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Important information: ") }}</span>
67
- {% elif params.type == 'error' or params.type == 'success' %}
68
- {% set defaultText = "Completed" if params.type == "success" else "Error" %}
69
- <span{% if params.type == "success" %} id="alert"{% endif %} class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default(defaultText ~ ": ") }}</span>
70
- {% endif %}
57
+ {% set defaultTitleTag = "div" %}
71
58
  {% endif %}
72
-
73
- {% if params.iconType is defined and params.iconType %}
74
- {% from "components/icons/_macro.njk" import onsIcon %}
75
- <span class= "ons-panel__icon ons-u-fs-{{ params.iconSize | default('r') }}">
76
- {{
77
- onsIcon({
78
- "iconType": params.iconType,
79
- "iconSize": params.iconSize
80
- })
81
- }}
82
- </span>
59
+ {% set titleTag = params.titleTag | default(defaultTitleTag) %}
60
+ <div class="ons-panel__header">
61
+ <{{ titleTag }} id="alert"{% if params.type %} data-qa="{{ params.type }}-header"{% endif %} class="ons-panel__title ons-u-fs-r--b">{{ params.title | safe }}</{{ titleTag }}>
62
+ </div>
63
+ {% else %}
64
+ {% if not params.type or params.type == "branded" or params.type == "info" or params.type == "bare" %}
65
+ <span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Important information: ") }}</span>
66
+ {% elif params.type == 'error' or params.type == 'success' %}
67
+ {% set defaultText = "Completed" if params.type == "success" else "Error" %}
68
+ <span{% if params.type == "success" %} id="alert"{% endif %} class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default(defaultText ~ ": ") }}</span>
83
69
  {% endif %}
84
70
  {% endif %}
85
71
 
86
- <div class="ons-panel__body{% if params is defined and params and params.iconSize is defined and params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
72
+ {% if params.iconType %}
73
+ {% from "components/icons/_macro.njk" import onsIcon %}
74
+ <span class= "ons-panel__icon ons-u-fs-{{ params.iconSize | default('r') }}">
75
+ {{
76
+ onsIcon({
77
+ "iconType": params.iconType,
78
+ "iconSize": params.iconSize
79
+ })
80
+ }}
81
+ </span>
82
+ {% endif %}
83
+
84
+ <div class="ons-panel__body{% if params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
87
85
  {{ caller() if caller }}
88
86
  </div>
89
87
  </div>
90
88
 
91
- {% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
89
+ {% if params.type == "warn-branded" or params.type == "announcement" %}
92
90
  </div>
93
91
  </div>
94
92
  {% endif %}
@@ -13,6 +13,7 @@ const EXAMPLE_PANEL_BASIC = {
13
13
  describe('macro: panel', () => {
14
14
  describe.each([
15
15
  ['info', 'Important information:'],
16
+ ['bare', 'Important information:'],
16
17
  ['error', 'Error:'],
17
18
  ['warn', 'Warning:'],
18
19
  ['warn-branded', 'Warning:'],
@@ -316,19 +317,6 @@ describe('macro: panel', () => {
316
317
  });
317
318
  });
318
319
 
319
- describe('mode: bare', () => {
320
- it('has the correct class set', () => {
321
- const $ = cheerio.load(
322
- renderComponent('panel', {
323
- ...EXAMPLE_PANEL_BASIC,
324
- type: 'bare',
325
- }),
326
- );
327
-
328
- expect($('.ons-panel').hasClass('ons-panel--bare')).toBe(true);
329
- });
330
- });
331
-
332
320
  describe('mode: warn', () => {
333
321
  it('has a default "!" prefix', () => {
334
322
  const $ = cheerio.load(
@@ -6,7 +6,7 @@
6
6
 
7
7
  <div class="ons-grid ons-grid--gutterless">
8
8
 
9
- {% if params.image is defined %}
9
+ {% if params.image %}
10
10
 
11
11
  <div class="ons-grid__col ons-col-7@s">
12
12
 
@@ -19,7 +19,7 @@
19
19
  <div class="ons-grid__col ons-col-4@s ons-push-1@s ons-u-d-no@xxs@s">
20
20
 
21
21
  <div class="ons-promo-banner__image">
22
- {% if params.image.smallSrc is defined and params.image.smallSrc %}
22
+ {% if params.image.smallSrc %}
23
23
  <img srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x" src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}">
24
24
  {% else %}
25
25
  <img src="{{ params.image.src }}" alt="{{ params.image.alt }}">
@@ -1,10 +1,10 @@
1
1
  {% macro onsQuestion(params) %}
2
2
 
3
- {%- set titleHtml -%}{% if params.readDescriptionFirst is defined and params.readDescriptionFirst == true and params.description is defined and params.description %}
3
+ {%- set titleHtml -%}{% if params.readDescriptionFirst == true and params.description %}
4
4
  <div class="ons-question__description ons-u-vh">{{ params.description | safe }} </div>{% endif %}{{- params.title | safe -}}
5
5
  {%- endset -%}
6
6
 
7
- {%- set descHtml -%}{% if params.readDescriptionFirst is defined and params.readDescriptionFirst == true %}
7
+ {%- set descHtml -%}{% if params.readDescriptionFirst == true %}
8
8
  <div aria-hidden="true" {% if params.legendIsQuestionTitle is not defined %}class="ons-question__description ons-question__description--aria-hidden"{% endif %}>{{- params.description | safe -}}</div>
9
9
  {% elif params.legendIsQuestionTitle is not defined %}
10
10
  <div class="ons-question__description ons-u-mb-m">{{- params.description | safe -}}</div>
@@ -16,7 +16,7 @@
16
16
  <div class="ons-question__instruction ons-u-mb-m">{{ params.instruction | safe }}</div>
17
17
  {% endset %}
18
18
 
19
- {% if params.definition is defined and params.definition %}
19
+ {% if params.definition %}
20
20
  {% set questionDefinition %}
21
21
  {% from "components/collapsible/_macro.njk" import onsCollapsible %}
22
22
  {% call onsCollapsible({
@@ -31,21 +31,21 @@
31
31
  {% endset %}
32
32
  {% endif %}
33
33
 
34
- {% if params.guidance is defined and params.guidance %}
34
+ {% if params.guidance %}
35
35
  {% set questionGuidance %}
36
36
  {% from "components/panel/_macro.njk" import onsPanel %}
37
37
  {% call onsPanel({
38
38
  "classes": "ons-question-guidance ons-u-mb-m"
39
39
  }) %}
40
- {% if params.guidance.content is defined and params.guidance.content %}
40
+ {% if params.guidance.content %}
41
41
  {{ params.guidance.content | safe }}
42
42
  {% endif %}
43
- {% if params.guidance.lists is defined and params.guidance.lists %}
43
+ {% if params.guidance.lists %}
44
44
  {%- for item in params.guidance.lists -%}
45
- {% if item.listHeading is defined and item.listHeading %}
45
+ {% if item.listHeading %}
46
46
  <h2 class="ons-question-guidance__list-heading ons-u-fs-r--b">{{ item.listHeading }}</h2>
47
47
  {% endif %}
48
- {% if item.listLeadingLine is defined and item.listLeadingLine %}
48
+ {% if item.listLeadingLine %}
49
49
  <p class="ons-question-guidance__list-leading-line">{{ item.listLeadingLine }}</p>
50
50
  {% endif %}
51
51
  {% from "components/lists/_macro.njk" import onsList %}
@@ -61,11 +61,11 @@
61
61
  {% endif %}
62
62
 
63
63
  <div
64
- {% if params.id is defined and params.id %} id="{{ params.id }}"{% endif %}
65
- class="ons-question ons-u-mb-l{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
66
- {% 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 %}
64
+ {% if params.id %} id="{{ params.id }}"{% endif %}
65
+ class="ons-question ons-u-mb-l{% if params.classes %} {{ params.classes }}{% endif %}"
66
+ {% 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 %}
67
67
  >
68
- {% if params.legendIsQuestionTitle is defined and params.legendIsQuestionTitle %}
68
+ {% if params.legendIsQuestionTitle %}
69
69
  {% from "components/fieldset/_macro.njk" import onsFieldset %}
70
70
 
71
71
  {# Resolves caller issue in jijna: https://github.com/pallets/jinja/issues/371 #}
@@ -74,7 +74,7 @@
74
74
  {% call onsFieldset({
75
75
  "legendIsQuestionTitle": params.legendIsQuestionTitle,
76
76
  "legend": titleHtml,
77
- "description": descHtml if params.description is defined and params.description else '',
77
+ "description": descHtml if params.description else '',
78
78
  "legendClasses": params.legendClasses,
79
79
  "legendTitleClasses": params.legendTitleClasses
80
80
  }) %}
@@ -87,19 +87,19 @@
87
87
  {{- titleHtml | safe -}}
88
88
  </h1>
89
89
 
90
- {% if params.description is defined and params.description %}
90
+ {% if params.description %}
91
91
  {{- descHtml | safe -}}
92
92
  {% endif %}
93
93
 
94
- {% if params.instruction is defined and params.instruction %}
94
+ {% if params.instruction %}
95
95
  {{- instHtml | safe -}}
96
96
  {% endif %}
97
97
 
98
- {% if params.definition is defined and params.definition %}
98
+ {% if params.definition %}
99
99
  {{- questionDefinition | safe -}}
100
100
  {% endif %}
101
101
 
102
- {% if params.guidance is defined and params.guidance %}
102
+ {% if params.guidance %}
103
103
  {{- questionGuidance | safe -}}
104
104
  {% endif %}
105
105
 
@@ -108,7 +108,7 @@
108
108
  </div>
109
109
  {% endif %}
110
110
 
111
- {% if params.justification is defined and params.justification %}
111
+ {% if params.justification %}
112
112
  {% from "components/collapsible/_macro.njk" import onsCollapsible %}
113
113
  {% call onsCollapsible({
114
114
  "id": params.justification.id,
@@ -6,7 +6,7 @@
6
6
  "iconType": 'quote'
7
7
  })
8
8
  }}
9
- <span class="ons-quote__text ons-u-fs-{{ params.textFontSize if params.textFontSize is defined and params.textFontSize else 'l' }}">{{ caller() if caller else params.text | safe }}</span>
10
- {% if params.ref is defined and params.ref %}<span class="ons-quote__ref">&mdash; {{ params.ref | safe }}</span>{% endif %}
9
+ <span class="ons-quote__text ons-u-fs-{{ params.textFontSize if params.textFontSize else 'l' }}">{{ caller() if caller else params.text | safe }}</span>
10
+ {% if params.ref %}<span class="ons-quote__ref">&mdash; {{ params.ref | safe }}</span>{% endif %}
11
11
  </blockquote>
12
12
  {% endmacro %}
@@ -15,12 +15,12 @@
15
15
  }) %}
16
16
  <div class="ons-radios__items">
17
17
  {% for radio in params.radios %}
18
- {% if params.or is defined and params.or and loop.revindex0 == 0 %}
18
+ {% if params.or and loop.revindex0 == 0 %}
19
19
  <span class="ons-radios__label ons-u-mt-s ons-u-fs-r--b" aria-hidden="true">{{ params.or }}</span>
20
20
  {% endif %}
21
21
  <span class="ons-radios__item{{ " ons-radios__item--no-border" if params.borderless }}">
22
22
  <span class="ons-radio{{ " ons-radio--no-border" if params.borderless }}">
23
- {% if radio.other is defined and radio.other and radio.other.selectAllChildren is defined and radio.other.selectAllChildren == true %}
23
+ {% if radio.other and radio.other.selectAllChildren == true %}
24
24
  {% set selectAllClass = ' ons-js-select-all-children' %}
25
25
  {% else %}
26
26
  {% set selectAllClass = '' %}
@@ -28,12 +28,12 @@
28
28
  <input
29
29
  type="radio"
30
30
  id="{{ radio.id }}"
31
- class="ons-radio__input ons-js-radio{{ ' ' + params.inputClasses if params.inputClasses and params.inputClasses is defined else '' }}{{ ' ' + radio.classes if radio.classes else '' }}{{ ' ons-js-other' if radio.other else '' }}{{ selectAllClass }}"
31
+ class="ons-radio__input ons-js-radio{{ ' ' + params.inputClasses if params.inputClasses else '' }}{{ ' ' + radio.classes if radio.classes else '' }}{{ ' ons-js-other' if radio.other else '' }}{{ selectAllClass }}"
32
32
  value="{{ radio.value }}"
33
33
  name="{{ params.name }}"
34
- {% if (radio.checked is defined and radio.checked) or (params.value is defined and params.value == radio.value) %} checked {% endif %}
35
- {% if radio.other is defined and radio.other and not radio.other.open %} aria-controls="{{ radio.id }}-other-wrap" aria-haspopup="true"{% endif %}
36
- {% if radio.attributes is defined and radio.attributes %}{% for attribute, value in (radio.attributes.items() if radio.attributes is mapping and radio.attributes.items else radio.attributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
34
+ {% if radio.checked or (params.value is defined and params.value == radio.value) %} checked {% endif %}
35
+ {% if radio.other and not radio.other.open %} aria-controls="{{ radio.id }}-other-wrap" aria-haspopup="true"{% endif %}
36
+ {% if radio.attributes %}{% for attribute, value in (radio.attributes.items() if radio.attributes is mapping and radio.attributes.items else radio.attributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
37
37
  >
38
38
  {{ onsLabel({
39
39
  "id": radio.id + "-label",
@@ -43,7 +43,7 @@
43
43
  "classes": "ons-radio__label " + radio.label.classes | default(''),
44
44
  "description": radio.label.description
45
45
  }) }}
46
- {% if radio.other is defined and radio.other %}
46
+ {% if radio.other %}
47
47
  {% set otherType = radio.other.otherType | default('input') %}
48
48
  <span class="ons-radio__other{{ " " + 'ons-radio__other--open' if radio.other.open else "" }}" id="{{ radio.id }}-other-wrap">
49
49
  {% if otherType == "input" %}
@@ -124,7 +124,7 @@
124
124
  {% endif %}
125
125
  {% endfor %}
126
126
  </div>
127
- {% if params.clearRadios is defined and params.clearRadios %}
127
+ {% if params.clearRadios %}
128
128
  {{ onsButton({
129
129
  "text": params.clearRadios.text,
130
130
  "name": params.clearRadios.name,
@@ -3,11 +3,15 @@ export default class CheckRadios {
3
3
  this.radio = radio;
4
4
  this.openOther = openOther;
5
5
  this.input = this.openOther.querySelector('.ons-input');
6
+ this.input.tabIndex = -1;
6
7
 
7
8
  this.setInputBlurAttributes();
8
9
  this.input.addEventListener('focus', this.checkRadio.bind(this));
9
10
  this.radio.addEventListener('change', this.setInputFocusAttributes.bind(this));
10
- this.radio.addEventListener('blur', this.setInputBlurAttributes.bind(this));
11
+ this.radio.addEventListener('focus', this.setInputFocusAttributes.bind(this));
12
+ if (this.radio.type == 'radio') {
13
+ this.input.addEventListener('blur', this.setInputBlurAttributes.bind(this));
14
+ }
11
15
  }
12
16
 
13
17
  checkRadio() {
@@ -1,13 +1,13 @@
1
1
  {% macro onsRelatedContent(params) %}
2
2
 
3
- {% if params is defined and params and params.classes is defined and params.classes %}
3
+ {% if params.classes %}
4
4
  {% set classes = ' ' + params.classes %}
5
5
  {% endif %}
6
6
 
7
7
  <aside class="ons-related-content{{ classes }}" aria-label="{{ params.ariaLabel | default("Related content") }}">
8
8
 
9
9
  <div class="ons-related-content__body">
10
- {% if params.rows is defined and params.rows %}
10
+ {% if params.rows %}
11
11
  {% for row in params.rows %}
12
12
  {% from "components/related-content/_section-macro.njk" import onsRelatedContentSection %}
13
13
  {% call onsRelatedContentSection(
@@ -2,8 +2,8 @@
2
2
 
3
3
  {% macro onsRelationships(params) %}
4
4
  <div
5
- {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}
6
- class="ons-relationships ons-js-relationships{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
5
+ {% if params.id %}id="{{ params.id }}"{% endif %}
6
+ class="ons-relationships ons-js-relationships{% if params.classes %} {{ params.classes }}{% endif %}"
7
7
  >
8
8
  {{ onsRadios({
9
9
  "name": params.name,
@@ -1,5 +1,5 @@
1
1
  {% macro onsSectionNavigation(params) %}
2
- <nav class="ons-section-nav{% if params.variants is defined and params.variants == 'vertical' %} ons-section-nav--vertical{% endif %}" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Section menu") }}">
2
+ <nav class="ons-section-nav{% if params.variants == 'vertical' %} ons-section-nav--vertical{% endif %}" id="{{ params.id }}" aria-label="{{ params.ariaLabel | default("Section menu") }}">
3
3
  <ul class="ons-section-nav__list">
4
4
  {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
5
5
  {% if (params.currentPath and (item.url == params.currentPath or item.url in params.currentPath)) or (params.tabQuery and params.tabQuery == item.title|lower) %}
@@ -9,7 +9,7 @@
9
9
  {% endif %}
10
10
  <li class="ons-section-nav__item{% if item.classes %} ' ' + {{ item.classes }}{% endif %}{% if isCurrent == true %} ons-section-nav__item--active{% endif %}">
11
11
  <a class="ons-section-nav__link" href="{{ item.url }}"{% if isCurrent == true %} aria-current="location"{% endif %}>{{ item.title }}</a>
12
- {% if item.anchors is defined and item.anchors %}
12
+ {% if item.anchors %}
13
13
  <ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
14
14
  {% for anchor in item.anchors %}
15
15
  <li class="ons-section-nav__item ons-list__item">
@@ -8,7 +8,7 @@
8
8
  "legendClasses": params.legendClasses,
9
9
  "dontWrap": params.dontWrap,
10
10
  "error": params.error,
11
- "inline": params.label.inline if params.label is defined and params.label else ''
11
+ "inline": params.label.inline if params.label else ''
12
12
  }) %}
13
13
  {{
14
14
  onsLabel({
@@ -21,16 +21,16 @@
21
21
  <select
22
22
  id="{{ params.id }}"
23
23
  name="{{ params.name }}"
24
- class="ons-input ons-input--select{% if params.classes %} {{ params.classes }}{% endif %}{% if params.error is defined and params.error %} ons-input--error{% endif %}"
25
- {% if params.value is defined and params.value %}value="{{ params.value}}" {% endif %}
26
- {% 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 %}
24
+ class="ons-input ons-input--select{% if params.classes %} {{ params.classes }}{% endif %}{% if params.error %} ons-input--error{% endif %}"
25
+ {% if params.value %}value="{{ params.value}}" {% endif %}
26
+ {% 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 %}
27
27
  >
28
28
  {% for option in params.options %}
29
29
  <option value="{{ option.value | default(option.text) }}"
30
- {% if option.id is defined and option.id %}id="{{ option.id }}" {% endif %}
31
- {% if option.selected is defined and option.selected %}selected {% endif %}
32
- {% if option.disabled is defined and option.disabled %}disabled {% endif %}
33
- {% if params.attributes is defined and params.attributes %}{% for attribute, value in option.attributes %}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
30
+ {% if option.id %}id="{{ option.id }}" {% endif %}
31
+ {% if option.selected %}selected {% endif %}
32
+ {% if option.disabled %}disabled {% endif %}
33
+ {% if params.attributes %}{% for attribute, value in option.attributes %}{{ attribute }}="{{ value }}"{% endfor %}{% endif %}
34
34
  >
35
35
  {{- option.text -}}
36
36
  </option>
@@ -7,7 +7,7 @@
7
7
  {% endif %}
8
8
 
9
9
  {% set list = [] %}
10
- {% if params.facebook is defined and params.facebook and params.facebook == true %}
10
+ {% if params.facebook and params.facebook == true %}
11
11
  {% set facebook =
12
12
  {
13
13
  "url": 'https://www.facebook.com/sharer/sharer.php?u=' ~ params.pageURL|urlencode,
@@ -20,7 +20,7 @@
20
20
 
21
21
  {% set list = (list.push(facebook), list) %}
22
22
  {% endif %}
23
- {% if params.twitter is defined and params.twitter and params.twitter == true %}
23
+ {% if params.twitter and params.twitter == true %}
24
24
  {% set twitter =
25
25
  {
26
26
  "url": 'https://twitter.com/intent/tweet?original_referer&text=' ~ params.pageTitle|urlencode ~ '&url=' ~ params.pageURL|urlencode,
@@ -1,11 +1,11 @@
1
1
  {% macro onsStatus(params) %}
2
- {% if params.type is defined and params.type %}
2
+ {% if params.type %}
3
3
  {% set typeClass = ' ons-status--' + params.type %}
4
4
  {% else %}
5
5
  {% set typeClass = ' ons-status--info' %}
6
6
  {% endif %}
7
7
 
8
- {% if params.size is defined and params.size == 'small' %}
8
+ {% if params.size == 'small' %}
9
9
  {% set sizeClass = ' ons-status--small' %}
10
10
  {% endif %}
11
11
 
@@ -2,25 +2,25 @@
2
2
  {% set className = "ons-summary" %}
3
3
  {% set titleSize = "2" %}
4
4
 
5
- {% if params.classes is defined and params.classes %}
5
+ {% if params.classes %}
6
6
  {% set className = className + " " + params.classes %}
7
7
  {% endif %}
8
8
 
9
- {% if params.hub is defined and params.hub %}
9
+ {% if params.hub %}
10
10
  {% set className = className + " ons-summary--hub" %}
11
11
  {% endif %}
12
12
  <div class="{{ className }}">
13
13
  {% for summary in params.summaries %}
14
- {% if summary.summaryTitle is defined and summary.summaryTitle %}
14
+ {% if summary.summaryTitle %}
15
15
  <h2 class="ons-summary__title ons-u-mb-m">{{ summary.summaryTitle }}</h2>
16
16
  {% set titleSize = "3" %}
17
17
  {% endif %}
18
18
  {% for group in summary.groups %}
19
- <div {% if group.id is defined and group.id %}id="{{ group.id }}" {% endif %} class="ons-summary__group">
20
- {% if group.groupTitle is defined and group.groupTitle %}
19
+ <div {% if group.id %}id="{{ group.id }}" {% endif %} class="ons-summary__group">
20
+ {% if group.groupTitle %}
21
21
  <h{{ titleSize }} class="ons-summary__group-title">{{ group.groupTitle }}</h{{ titleSize }}>
22
22
  {% endif %}
23
- {% if group.headers is defined and group.headers and group.rows is defined and group.rows %}
23
+ {% if group.headers and group.rows %}
24
24
  <table class="ons-summary__items">
25
25
  <thead class="ons-u-vh">
26
26
  <tr>
@@ -32,23 +32,23 @@
32
32
 
33
33
  {% for row in (group.rows if group.rows is iterable else group.rows.items()) %}
34
34
  {% set itemClass = "" %}
35
- {% if row.error is defined and row.error %} {% set itemClass = " ons-summary__item--error" %}{% endif %}
36
- {% if row.total is defined and row.total %} {% set itemClass = itemClass + " ons-summary__item--total" %}{% endif %}
35
+ {% if row.error %} {% set itemClass = " ons-summary__item--error" %}{% endif %}
36
+ {% if row.total %} {% set itemClass = itemClass + " ons-summary__item--total" %}{% endif %}
37
37
 
38
- <tbody {% if row.id is defined and row.id %}id="{{ row.id }}" {% endif %}class="ons-summary__item{{ itemClass }}">
39
- {% if row.errorMessage is defined and row.errorMessage or (row.rowItems | length > 1 and row.rowTitle) %}
38
+ <tbody {% if row.id %}id="{{ row.id }}" {% endif %}class="ons-summary__item{{ itemClass }}">
39
+ {% if row.errorMessage or (row.rowItems | length > 1 and row.rowTitle) %}
40
40
  <tr class="ons-summary__row">
41
41
  <th colspan="3" class="ons-summary__row-title ons-u-fs-r">{{ row.errorMessage or row.rowTitle }}</th>
42
42
  </tr>
43
43
  {% endif %}
44
44
 
45
45
  {% for rowItem in row.rowItems %}
46
- <tr {% if rowItem.id is defined and rowItem.id %}id="{{ rowItem.id }}" {% endif %}class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}">
46
+ <tr {% if rowItem.id %}id="{{ rowItem.id }}" {% endif %}class="ons-summary__row{{ " ons-summary__row--has-values" if rowItem.valueList else "" }}">
47
47
  <td
48
48
  class="ons-summary__item-title"
49
- {% if rowItem.rowTitleAttributes is defined and 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 %}
49
+ {% 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 %}
50
50
  >
51
- {% if rowItem.iconType is defined and rowItem.iconType %}
51
+ {% if rowItem.iconType %}
52
52
  {% from "components/icons/_macro.njk" import onsIcon %}
53
53
  <span class="ons-summary__item-title-icon {% if rowItem.iconType == 'check' %} ons-summary__item-title-icon--check{% endif %}">
54
54
  {{
@@ -62,19 +62,19 @@
62
62
  <div class="ons-summary__item--text{{ ' ons-summary__item-title--text' if rowItem.iconType else "" }}">{{ rowItem.rowTitle | default(row.rowTitle) | safe }}</div>
63
63
 
64
64
  {# Render section status for mobile if is hub #}
65
- {% if params.hub is defined and params.hub and rowItem.valueList is defined and rowItem.valueList %}
65
+ {% if params.hub and rowItem.valueList %}
66
66
  <span class="ons-u-d-no@s ons-u-fs-r"> — {{ rowItem.valueList[0].text | safe }}</span>
67
67
  {% endif %}
68
68
  </td>
69
- {% if rowItem.valueList is defined and rowItem.valueList %}
69
+ {% if rowItem.valueList %}
70
70
  <td
71
71
  class="ons-summary__values"
72
72
  {% if rowItem.actions == null %} colspan="2"{% endif %}
73
- {% if rowItem.attributes is defined and rowItem.attributes %}{% for attribute, value in (rowItem.attributes.items() if rowItem.attributes is mapping and rowItem.attributes.items else rowItem.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
73
+ {% if rowItem.attributes %}{% for attribute, value in (rowItem.attributes.items() if rowItem.attributes is mapping and rowItem.attributes.items else rowItem.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
74
74
  >
75
75
  {% if rowItem.valueList | length == 1 %}
76
76
  <span class="ons-summary__text">{{ rowItem.valueList[0].text | safe }}</span>
77
- {% if rowItem.valueList[0].other is defined and rowItem.valueList[0].other or rowItem.valueList[0].other == 0 %}
77
+ {% if rowItem.valueList[0].other or rowItem.valueList[0].other == 0 %}
78
78
  <ul class="ons-u-mb-no">
79
79
  <li>{{ rowItem.valueList[0].other | safe }}</li>
80
80
  </ul>
@@ -84,7 +84,7 @@
84
84
  {% for value in (rowItem.valueList if rowItem.valueList is iterable else rowItem.valueList.items()) %}
85
85
  <li>
86
86
  <span class="ons-summary__text">{{ value.text | safe }}</span>
87
- {% if value.other is defined and value.other or value.other == 0 %}
87
+ {% if value.other or value.other == 0 %}
88
88
  <ul class="ons-u-mb-no">
89
89
  <li>{{ value.other | safe }}</li>
90
90
  </ul>
@@ -95,15 +95,15 @@
95
95
  {% endif %}
96
96
  </td>
97
97
  {% endif %}
98
- {% if rowItem.actions is defined and rowItem.actions %}
98
+ {% if rowItem.actions %}
99
99
  <td class="ons-summary__actions">
100
100
  {% for action in (rowItem.actions if rowItem.actions is iterable else rowItem.actions.items()) %}
101
101
  {% if loop.index > 1 %}<span class="ons-summary__spacer"></span>{% endif %}
102
102
  <a
103
103
  href="{{ action.url }}"
104
104
  class="ons-summary__button"
105
- {% if action.ariaLabel is defined and action.ariaLabel %} aria-label="{{ action.ariaLabel }}"{% endif %}
106
- {% if action.attributes is defined and action.attributes %}{% for attribute, value in (action.attributes.items() if action.attributes is mapping and action.attributes.items else action.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
105
+ {% if action.ariaLabel %} aria-label="{{ action.ariaLabel }}"{% endif %}
106
+ {% if action.attributes %}{% for attribute, value in (action.attributes.items() if action.attributes is mapping and action.attributes.items else action.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
107
107
  >{{ action.text }}</a>
108
108
  {% endfor %}
109
109
  </td>
@@ -113,13 +113,13 @@
113
113
  </tbody>
114
114
  {% endfor %}
115
115
  </table>
116
- {% elif group.placeholderText is defined and group.placeholderText %}
116
+ {% elif group.placeholderText %}
117
117
  <span class="ons-summary__placeholder">{{ group.placeholderText }}</span>
118
118
  {% endif %}
119
119
 
120
- {% if group.summaryLink is defined and group.summaryLink %}
121
- <div class="ons-summary__link{% if group.placeholderText is defined and group.placeholderText or group.rows is defined and group.rows %} ons-u-pt-s{% endif %}{% if group.placeholderText is not defined and group.rows is defined and group.rows | length > 1 %} ons-u-bt{% endif %}">
122
- <a {% if group.summaryLink.attributes is defined and group.summaryLink.attributes %}{% for attribute, value in (group.summaryLink.attributes.items() if group.summaryLink.attributes is mapping and group.summaryLink.attributes.items else group.summaryLink.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %} href="{{ group.summaryLink.url }}">{{ group.summaryLink.text }}</a>
120
+ {% if group.summaryLink %}
121
+ <div class="ons-summary__link{% if group.placeholderText or group.rows %} ons-u-pt-s{% endif %}{% if group.placeholderText is not defined and group.rows | length > 1 %} ons-u-bt{% endif %}">
122
+ <a {% if group.summaryLink.attributes %}{% for attribute, value in (group.summaryLink.attributes.items() if group.summaryLink.attributes is mapping and group.summaryLink.attributes.items else group.summaryLink.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %} href="{{ group.summaryLink.url }}">{{ group.summaryLink.text }}</a>
123
123
  </div>
124
124
  {% endif %}
125
125
  </div>