@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
@@ -26,9 +26,9 @@
26
26
  }) }}
27
27
  {% endset %}
28
28
 
29
- {% if params.error is not defined %}
29
+ {% if not params.error %}
30
30
  {% call onsPanel({
31
- "classes": "ons-u-mb-s" + (' ' + params.classes if params.classes is defined and params.classes)
31
+ "classes": "ons-u-mb-s" + (' ' + params.classes if params.classes)
32
32
  })
33
33
  %}
34
34
  {{ content | safe }}
@@ -37,7 +37,7 @@
37
37
  {{ content | safe }}
38
38
  {% endif %}
39
39
 
40
- {% if params.securityMessage is defined and params.securityMessage %}
40
+ {% if params.securityMessage %}
41
41
  {% call onsPanel({
42
42
  "type": "bare",
43
43
  "iconType": "lock",
@@ -2,7 +2,7 @@
2
2
  {% from "components/collapsible/_macro.njk" import onsCollapsible %}
3
3
 
4
4
  <div id="{{params.id}}" class="ons-accordion{{ ' ' + params.classes if params.classes }}">
5
- {% if params.allButton is defined and params.allButton %}
5
+ {% if params.allButton %}
6
6
  {% from "components/button/_macro.njk" import onsButton %}
7
7
  {% set attributes = params.allButton.attributes | default({}) %}
8
8
 
@@ -7,7 +7,7 @@
7
7
  <div id="address" class="ons-field ons-address-input {% if not params.manualEntry %}ons-address-input--search ons-js-address-autosuggest{% endif %}">
8
8
  {% if params.isEditable == true or params.manualEntry %}
9
9
  {% if not params.manualEntry %}<div class="ons-js-address-input__manual ons-u-db-no-js_enabled">{% endif %}
10
- {% if params.organisation is defined and params.organisation %}
10
+ {% if params.organisation %}
11
11
  {{
12
12
  onsInput({
13
13
  "id": params.id + "-organisation",
@@ -22,7 +22,7 @@
22
22
  })
23
23
  }}
24
24
  {% endif %}
25
- {% if params.line1 is defined and params.line1 %}
25
+ {% if params.line1 %}
26
26
  {{
27
27
  onsInput({
28
28
  "id": params.id + "-line1",
@@ -37,7 +37,7 @@
37
37
  })
38
38
  }}
39
39
  {% endif %}
40
- {% if params.line2 is defined and params.line2 %}
40
+ {% if params.line2 %}
41
41
  {{
42
42
  onsInput({
43
43
  "id": params.id + "-line2",
@@ -52,7 +52,7 @@
52
52
  })
53
53
  }}
54
54
  {% endif %}
55
- {% if params.town is defined and params.town %}
55
+ {% if params.town %}
56
56
  {{
57
57
  onsInput({
58
58
  "id": params.id + "-town",
@@ -66,7 +66,7 @@
66
66
  })
67
67
  }}
68
68
  {% endif %}
69
- {% if params.postcode is defined and params.postcode %}
69
+ {% if params.postcode %}
70
70
  {{
71
71
  onsInput({
72
72
  "id": params.id + "-postcode",
@@ -89,7 +89,7 @@
89
89
  {% endif %}
90
90
  {% endif %}
91
91
 
92
- {% if params.uprn is defined and params.uprn and params.uprn.value is defined and params.uprn.value %}
92
+ {% if params.uprn and params.uprn.value %}
93
93
  {% set uprnValue = params.uprn.value %}
94
94
  {% else %}
95
95
  {% set uprnValue = '' %}
@@ -162,7 +162,7 @@
162
162
  </div>
163
163
  {% endset %}
164
164
 
165
- {% if params.dontWrap is defined and params.dontWrap %}
165
+ {% if params.dontWrap %}
166
166
  {{ fields | safe }}
167
167
  {% else %}
168
168
  {% call onsFieldset({
@@ -1,22 +1,22 @@
1
1
  {% macro onsAddressOutput(params) %}
2
- <div class="ons-address-output{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}">
2
+ <div class="ons-address-output{% if params.classes %} {{ params.classes }}{% endif %}">
3
3
  <p class="ons-address-output__lines">
4
- {% if params.unit is defined and params.unit %}
4
+ {% if params.unit %}
5
5
  <span class="ons-address-output__unit">{{ params.unit }}</span><br>
6
6
  {% endif %}
7
- {% if params.organisation is defined and params.organisation %}
7
+ {% if params.organisation %}
8
8
  <span class="ons-address-output__organisation">{{ params.organisation }}</span><br>
9
9
  {% endif %}
10
- {% if params.line1 is defined and params.line1 %}
10
+ {% if params.line1 %}
11
11
  <span class="ons-address-output__line1">{{ params.line1 }}</span><br>
12
12
  {% endif %}
13
- {% if params.line2 is defined and params.line2 %}
13
+ {% if params.line2 %}
14
14
  <span class="ons-address-output__line2">{{ params.line2 }}</span><br>
15
15
  {% endif %}
16
- {% if params.town is defined and params.town %}
16
+ {% if params.town %}
17
17
  <span class="ons-address-output__town">{{ params.town }}</span><br>
18
18
  {% endif %}
19
- {% if params.postcode is defined and params.postcode %}
19
+ {% if params.postcode %}
20
20
  <span class="ons-address-output__postcode">{{ params.postcode }}</span>
21
21
  {% endif %}
22
22
  </p>
@@ -3,7 +3,7 @@
3
3
  {% macro onsAutosuggest(params) %}
4
4
  <div
5
5
  id="{{ params.id }}-container"
6
- class="{% if not params.externalInitialiser %}ons-js-autosuggest {% endif %}{% if params.isEditable == false %}ons-js-address-not-editable{% endif %}{% if params.mandatory is defined and params.mandatory == true %} ons-js-address-mandatory{% endif %} {% if params.containerClasses is defined and params.containerClasses %} {{ params.containerClasses }}{% endif %} ons-autosuggest-input"
6
+ class="{% if not params.externalInitialiser %}ons-js-autosuggest {% endif %}{% if params.isEditable == false %}ons-js-address-not-editable{% endif %}{% if params.mandatory == true %} ons-js-address-mandatory{% endif %} {% if params.containerClasses %} {{ params.containerClasses }}{% endif %} ons-autosuggest-input"
7
7
  data-instructions="{{ params.instructions }}"
8
8
  data-aria-you-have-selected="{{ params.ariaYouHaveSelected }}"
9
9
  data-min-chars="{{ params.minChars }}"
@@ -15,23 +15,23 @@
15
15
  data-results-title="{{ params.resultsTitle }}"
16
16
  data-no-results="{{ params.noResults }}"
17
17
  data-type-more="{{ params.typeMore }}"
18
- {% if params.APIDomain is defined and params.APIDomain %}data-api-domain="{{ params.APIDomain }}"{% endif %}
19
- {% if params.APIDomainBearerToken is defined and params.APIDomainBearerToken %}data-authorization-token="{{ params.APIDomainBearerToken }}"{% endif %}
20
- {% if params.APIManualQueryParams is defined and params.APIManualQueryParams == true %}data-query-params=""{% endif %}
21
- {% if params.allowMultiple is defined and params.allowMultiple == true %}data-allow-multiple="true"{% endif %}
22
- {% if params.autosuggestData is defined and params.autosuggestData %}data-autosuggest-data="{{ params.autosuggestData }}"{% endif %}
23
- {% if params.errorTitle is defined and params.errorTitle %}data-error-title="{{ params.errorTitle }}"{% endif %}
24
- {% if params.errorMessageEnter is defined and params.errorMessageEnter %}data-error-enter="{{ params.errorMessageEnter }}"{% endif %}
25
- {% if params.errorMessageSelect is defined and params.errorMessageSelect %}data-error-select="{{ params.errorMessageSelect }}"{% endif %}
26
- {% if params.ariaGroupedResults is defined and params.ariaGroupedResults %}data-aria-grouped-results="{{ params.ariaGroupedResults }}"{% endif %}
27
- {% if params.groupCount is defined and params.groupCount %}data-group-count="{{ params.groupCount }}"{% endif %}
28
- {% if params.tooManyResults is defined and params.tooManyResults %}data-too-many-results="{{ params.tooManyResults }}"{% endif %}
29
- {% if params.errorMessageAPI is defined and params.errorMessageAPI %}data-error-api="{{ params.errorMessageAPI }}"{% endif %}
30
- {% if params.errorMessageAPILinkText is defined and params.errorMessageAPILinkText %}data-error-api-link-text="{{ params.errorMessageAPILinkText }}"{% endif %}
31
- {% if params.options is defined and params.options %}
32
- {% if params.options.oneYearAgo is defined and params.options.oneYearAgo %}data-options-one-year-ago="true"{% endif %}
33
- {% if params.options.regionCode is defined and params.options.regionCode %}data-options-region-code="{{ params.options.regionCode }}"{% endif %}
34
- {% if params.options.addressType is defined and params.options.addressType %}data-options-address-type="{{ params.options.addressType }}"{% endif %}
18
+ {% if params.APIDomain %}data-api-domain="{{ params.APIDomain }}"{% endif %}
19
+ {% if params.APIDomainBearerToken %}data-authorization-token="{{ params.APIDomainBearerToken }}"{% endif %}
20
+ {% if params.APIManualQueryParams == true %}data-query-params=""{% endif %}
21
+ {% if params.allowMultiple == true %}data-allow-multiple="true"{% endif %}
22
+ {% if params.autosuggestData %}data-autosuggest-data="{{ params.autosuggestData }}"{% endif %}
23
+ {% if params.errorTitle %}data-error-title="{{ params.errorTitle }}"{% endif %}
24
+ {% if params.errorMessageEnter %}data-error-enter="{{ params.errorMessageEnter }}"{% endif %}
25
+ {% if params.errorMessageSelect %}data-error-select="{{ params.errorMessageSelect }}"{% endif %}
26
+ {% if params.ariaGroupedResults %}data-aria-grouped-results="{{ params.ariaGroupedResults }}"{% endif %}
27
+ {% if params.groupCount %}data-group-count="{{ params.groupCount }}"{% endif %}
28
+ {% if params.tooManyResults %}data-too-many-results="{{ params.tooManyResults }}"{% endif %}
29
+ {% if params.errorMessageAPI %}data-error-api="{{ params.errorMessageAPI }}"{% endif %}
30
+ {% if params.errorMessageAPILinkText %}data-error-api-link-text="{{ params.errorMessageAPILinkText }}"{% endif %}
31
+ {% if params.options %}
32
+ {% if params.options.oneYearAgo %}data-options-one-year-ago="true"{% endif %}
33
+ {% if params.options.regionCode %}data-options-region-code="{{ params.options.regionCode }}"{% endif %}
34
+ {% if params.options.addressType %}data-options-address-type="{{ params.options.addressType }}"{% endif %}
35
35
  {% endif %}
36
36
  >
37
37
 
@@ -66,7 +66,7 @@
66
66
  "autosuggestResults": autosuggestResults
67
67
  }) }}
68
68
 
69
- {% if params.mutuallyExclusive is not defined %}
69
+ {% if not params.mutuallyExclusive %}
70
70
  {{ autosuggestResults | safe }}
71
71
  {% endif %}
72
72
  </div>
@@ -1,12 +1,12 @@
1
1
  {% from "components/icons/_macro.njk" import onsIcon %}
2
2
 
3
3
  {% macro onsBreadcrumbs(params) %}
4
- <nav class="ons-breadcrumb{{ ' ' + params.classes if params.classes else '' }}" aria-label="{{ params.ariaLabel | default("Breadcrumbs") }}" {% if params.id is defined and params.id %} id="{{ params.id }}"{% endif %}>
4
+ <nav class="ons-breadcrumb{{ ' ' + params.classes if params.classes else '' }}" aria-label="{{ params.ariaLabel | default("Breadcrumbs") }}" {% if params.id %} id="{{ params.id }}"{% endif %}>
5
5
  <ol class="ons-breadcrumb__items ons-u-fs-s">
6
6
  {% for item in (params.itemsList if params.itemsList is iterable else params.itemsList.items()) %}
7
7
  <li class="ons-breadcrumb__item{{ ' ' + item.itemClasses if item.itemClasses else '' }}" id="breadcrumb-{{ loop.index }}">
8
- <a class="ons-breadcrumb__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}" href="{{ item.url }}"{% if item.id is defined and item.id %} id="{{ item.id }}"{% endif %}
9
- {% 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}}="{{value}}" {% endfor %}{% endif %}
8
+ <a class="ons-breadcrumb__link{{ ' ' + item.linkClasses if item.linkClasses else '' }}" href="{{ item.url }}"{% if item.id %} id="{{ item.id }}"{% endif %}
9
+ {% if item.attributes %}{% for attribute, value in (item.attributes.items() if item.attributes is mapping and item.attributes.items else item.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}
10
10
  >{{ item.text }}</a>
11
11
  {{
12
12
  onsIcon({
@@ -39,7 +39,7 @@ $button-shadow-size: 3px;
39
39
 
40
40
  &--search {
41
41
  .ons-svg-icon {
42
- @include mq(s, m) {
42
+ @include mq(s, l) {
43
43
  margin-right: 0.5rem;
44
44
  }
45
45
  }
@@ -3,9 +3,9 @@
3
3
  {% macro onsButton(params) %}
4
4
 
5
5
  {# Customisable button icon #}
6
- {% if params.iconType is defined and params.iconType %}
6
+ {% if params.iconType %}
7
7
  {% set iconType = params.iconType %}
8
- {% if params.iconPosition is defined and params.iconPosition %}
8
+ {% if params.iconPosition %}
9
9
  {% set iconPosition = params.iconPosition %}
10
10
  {% else %}
11
11
  {# Default icon position before label #}
@@ -13,49 +13,49 @@
13
13
  {% endif %}
14
14
  {% elif params.iconType is not defined and params.noIcon is not defined %}
15
15
  {# Opens in new tab #}
16
- {% if params.url is defined and params.url and params.newWindow is defined and params.newWindow %}
16
+ {% if params.url and params.newWindow %}
17
17
  {% set iconType = "external-link" %}
18
18
  {% set iconPosition = "after" %}
19
19
  {# Download #}
20
- {% elif params.buttonStyle is defined and params.buttonStyle == "download" %}
20
+ {% elif params.buttonStyle == "download" %}
21
21
  {% set iconType = "download" %}
22
22
  {% set iconPosition = "before" %}
23
23
  {# Print #}
24
- {% elif params.buttonStyle is defined and params.buttonStyle == "print" %}
24
+ {% elif params.buttonStyle == "print" %}
25
25
  {% set iconType = "print" %}
26
26
  {% set iconPosition = "before" %}
27
27
  {# Loader #}
28
- {% elif params.submitType is defined and params.submitType == "loader" %}
28
+ {% elif params.submitType == "loader" %}
29
29
  {% set iconType = "loader" %}
30
30
  {% set iconPosition = "after" %}
31
31
  {# CTA or mobile menu toggle #}
32
- {% elif params.buttonStyle is defined and params.buttonStyle == "mobile" %}
32
+ {% elif params.buttonStyle == "mobile" %}
33
33
  {% set iconType = "chevron" %}
34
34
  {% set iconPosition = "after" %}
35
- {% elif params.url is defined and params.url %}
35
+ {% elif params.url %}
36
36
  {% set iconType = "arrow-next" %}
37
37
  {% set iconPosition = "after" %}
38
38
  {% endif %}
39
39
  {% endif %}
40
40
 
41
- {% set tag = "a" if params.url or params.dsExample is defined and params.dsExample else "button" %}
41
+ {% set tag = "a" if params.url or params.dsExample else "button" %}
42
42
 
43
43
  <{{ tag }}
44
- {% if params.url is defined and params.url %}
44
+ {% if params.url %}
45
45
  href="{{ params.url }}"
46
46
  role="button"
47
47
  {% else %}
48
- type="{{ params.type if params.type is defined and params.type else ('button' if params.buttonStyle == "print" else 'submit') }}"
48
+ type="{{ params.type if params.type else ('button' if params.buttonStyle == "print" else 'submit') }}"
49
49
  {% endif %}
50
- class="ons-btn{% 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-btn--{{ variant }}{% endfor %}{% else %} ons-btn--{{ params.variants }}{% endif %}{% endif %}{% if params.url is defined and params.url %} ons-btn--link ons-js-submit-btn{% endif %}{% if params.buttonStyle == "download" %} ons-btn--download{% endif %}{% if params.buttonStyle == "print" %} ons-btn--print ons-u-d-no ons-js-print-btn{% endif %}{% if params.submitType == "loader" %} ons-btn--loader ons-js-loader ons-js-submit-btn{% endif %}{% if params.submitType == "timer" %} ons-js-timer ons-js-submit-btn{% endif %}"
51
- {% if params.id is defined and params.id %}id="{{ params.id }}"{% endif %}
52
- {% if params.value is defined and params.value and tag != "a" %}value="{{ params.value }}"{% endif %}
53
- {% if params.name is defined and params.name and tag != "a" %}name="{{ params.name }}"{% endif %}
54
- {% if params.url is defined and params.url and params.newWindow is defined and params.newWindow %}target="_blank" rel="noopener"{% endif %}
55
- {% if params.buttonStyle == "download" and (params.removeDownloadAttribute is not defined or not params.removeDownloadAttribute or params.removeDownloadAttribute != true) %} download{% endif %}
56
- {% 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 %}
50
+ class="ons-btn{% if params.classes %} {{ params.classes }}{% endif %}{% if params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-btn--{{ variant }}{% endfor %}{% else %} ons-btn--{{ params.variants }}{% endif %}{% endif %}{% if params.url %} ons-btn--link ons-js-submit-btn{% endif %}{% if params.buttonStyle == "download" %} ons-btn--download{% endif %}{% if params.buttonStyle == "print" %} ons-btn--print ons-u-d-no ons-js-print-btn{% endif %}{% if params.submitType == "loader" %} ons-btn--loader ons-js-loader ons-js-submit-btn{% endif %}{% if params.submitType == "timer" %} ons-js-timer ons-js-submit-btn{% endif %}"
51
+ {% if params.id %}id="{{ params.id }}"{% endif %}
52
+ {% if params.value and tag != "a" %}value="{{ params.value }}"{% endif %}
53
+ {% if params.name and tag != "a" %}name="{{ params.name }}"{% endif %}
54
+ {% if params.url and params.newWindow %}target="_blank" rel="noopener"{% endif %}
55
+ {% if params.buttonStyle == "download" and not params.removeDownloadAttribute %} download{% endif %}
56
+ {% 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 %}
57
57
  >
58
- <span class="ons-btn__inner{% if params.innerClasses is defined and params.innerClasses %} {{ params.innerClasses }}{% endif %}">
58
+ <span class="ons-btn__inner{% if params.innerClasses %} {{ params.innerClasses }}{% endif %}">
59
59
  {%- if iconPosition == "before" or iconPosition == "after" %}
60
60
  {%- if iconPosition == "before" %}
61
61
  {{
@@ -65,7 +65,7 @@
65
65
  })
66
66
  }}
67
67
  {% endif -%}
68
- <span class="ons-btn__text">{{- params.html | safe if params.html is defined and params.html else params.text -}}</span>
68
+ <span class="ons-btn__text">{{- params.html | safe if params.html else params.text -}}</span>
69
69
  {%- if iconPosition == "after" %}
70
70
  {{
71
71
  onsIcon({
@@ -80,15 +80,15 @@
80
80
  "iconType": iconType
81
81
  })
82
82
  }}
83
- <span class="ons-btn__text ons-u-vh@xxs@s">{{- params.html | safe if params.html is defined and params.html else params.text -}}</span>
83
+ <span class="ons-btn__text ons-u-vh@xxs@s">{{- params.html | safe if params.html else params.text -}}</span>
84
84
  {% else -%}
85
- <span class="ons-btn__text">{{- params.html | safe if params.html is defined and params.html else params.text -}}</span>
85
+ <span class="ons-btn__text">{{- params.html | safe if params.html else params.text -}}</span>
86
86
  {% endif -%}
87
87
  </span>
88
- {% if params.url is defined and params.url and params.newWindow is defined and params.newWindow %}
88
+ {% if params.url and params.newWindow %}
89
89
  <span class="ons-btn__new-window-description ons-u-vh"> ({{ params.newWindowDescription | default("opens in a new tab") }})</span>
90
90
  {% endif %}
91
- {% if params.buttonContext is defined and params.buttonContext %}
91
+ {% if params.buttonContext %}
92
92
  <span class="ons-btn__context ons-u-vh">{{ params.buttonContext }}</span>
93
93
  {% endif %}
94
94
  {% if params.listeners %}
@@ -5,7 +5,7 @@
5
5
  <div class="ons-grid ons-grid--flex ons-grid--vertical-center ons-grid--no-wrap@s">
6
6
  <div class="ons-grid__col ons-col-auto ons-u-flex-shrink@s">
7
7
  <h2 class="ons-call-to-action__heading ons-u-fs-r--b ons-u-di">{{ params.headingText }}</h2>
8
- {% if params.paragraphText is defined and params.paragraphText %}
8
+ {% if params.paragraphText %}
9
9
  <p class="ons-call-to-action__text ons-u-di">{{ params.paragraphText }}</p>
10
10
  {% endif %}
11
11
  </div>
@@ -6,31 +6,31 @@
6
6
 
7
7
  <div class="ons-card" aria-describedBy="{{ params.textId }}">
8
8
 
9
- {%- if params.image is defined and params.image -%}
10
- {%- if params.url is defined and params.url -%}
9
+ {%- if params.image -%}
10
+ {%- if params.url -%}
11
11
  <a href="{{ params.url }}" class="ons-card__link ons-u-db">
12
12
  {%- endif -%}
13
- {% if params.image.smallSrc is defined and params.image.smallSrc %}
14
- <img class="ons-card__image ons-u-mb-s" height="200" width="303"{% if params.image.largeSrc is defined and params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
15
- {% elif params.image == true or params.image.placeholderURL is defined %}
16
- <img class="ons-card__image ons-u-mb-s" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL is defined and params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL is defined and params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL is defined and params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
13
+ {% if params.image.smallSrc %}
14
+ <img class="ons-card__image ons-u-mb-s" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
15
+ {% elif params.image == true or params.image.placeholderURL %}
16
+ <img class="ons-card__image ons-u-mb-s" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
17
17
  {% endif %}
18
18
 
19
19
  <h{{ titleSize }} class="ons-card__title {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
20
20
  {{ params.title }}
21
21
  </h{{ titleSize }}>
22
- {%- if params.url is defined and params.url -%}
22
+ {%- if params.url -%}
23
23
  </a>
24
24
  {%- endif -%}
25
25
 
26
26
  {%- else -%}
27
27
 
28
28
  <h{{ titleSize }} class="ons-card__title {{ params.titleClasses | default('ons-u-fs-m') }}" id="{{ params.id }}">
29
- {%- if params.url is defined and params.url -%}
29
+ {%- if params.url -%}
30
30
  <a class="ons-card__link" href="{{ params.url }}">
31
31
  {%- endif -%}
32
32
  {{ params.title }}
33
- {%- if params.url is defined and params.url -%}
33
+ {%- if params.url -%}
34
34
  </a>
35
35
  {%- endif -%}
36
36
  </h{{ titleSize }}>
@@ -39,7 +39,7 @@
39
39
 
40
40
  <p id="{{ params.textId }}">{{ params.text }}</p>
41
41
 
42
- {% if params.itemsList is defined and params.itemsList -%}
42
+ {% if params.itemsList -%}
43
43
  {{
44
44
  onsList({
45
45
  "variants": 'dashed',
@@ -1,18 +1,18 @@
1
1
  {% macro onsCheckbox(params) %}
2
2
  {% from "components/label/_macro.njk" import onsLabel %}
3
3
 
4
- <span class="ons-checkbox{% if params.hideLabel is defined and params.hideLabel == true %} ons-checkbox--no-label{% endif %}{{ ' ' + params.classes if params.classes and params.classes is defined else '' }}">
4
+ <span class="ons-checkbox{% if params.hideLabel == true %} ons-checkbox--no-label{% endif %}{{ ' ' + params.classes if params.classes else '' }}">
5
5
  <input
6
6
  type="checkbox"
7
7
  id="{{ params.id }}"
8
- class="ons-checkbox__input ons-js-checkbox{{ ' ' + params.inputClasses if params.inputClasses and params.inputClasses is defined else '' }}"
8
+ class="ons-checkbox__input ons-js-checkbox{{ ' ' + params.inputClasses if params.inputClasses else '' }}"
9
9
  value="{{ params.value }}"
10
- {% if params.disabled is defined and params.disabled == true %}disabled aria-disabled="true"{%endif %}
11
- {% if params.name is defined and params.name %} name="{{ params.name }}"{% endif %}
12
- {% if params.checked is defined and params.checked %} checked{% endif %}
13
- {% if params.other is defined and params.other and not params.other.open %} aria-controls="{{ params.id }}-other-wrap" aria-haspopup="true"{% endif %}
14
- {% 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 %}
15
- {% if params.deselectMessage is defined and params.deselectMessage %} data-deselect-message="{{ params.deselectMessage }}"{% endif %}
10
+ {% if params.disabled == true %}disabled aria-disabled="true"{%endif %}
11
+ {% if params.name %} name="{{ params.name }}"{% endif %}
12
+ {% if params.checked %} checked{% endif %}
13
+ {% if params.other and not params.other.open %} aria-controls="{{ params.id }}-other-wrap" aria-haspopup="true"{% endif %}
14
+ {% 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 %}
15
+ {% if params.deselectMessage %} data-deselect-message="{{ params.deselectMessage }}"{% endif %}
16
16
  >
17
17
 
18
18
  {{ onsLabel({
@@ -24,7 +24,7 @@
24
24
  "description": params.label.description
25
25
  }) }}
26
26
 
27
- {% if params.other is defined and params.other %}
27
+ {% if params.other %}
28
28
  {% set otherType = params.other.otherType | default('input') %}
29
29
  <span class="ons-checkbox__other{{ ' ons-checkbox__other--open' if params.other.open }}" id="{{ params.id }}-other-wrap">
30
30
  {% if otherType == "input" %}
@@ -8,13 +8,13 @@
8
8
  <p class="ons-checkboxes__label{{ " " + params.checkboxesLabelClasses if params.checkboxesLabelClasses }}">{{ params.checkboxesLabel }}</p>
9
9
  {% set hasOther = false %}
10
10
  {% for checkbox in params.checkboxes %}
11
- {% if checkbox.other is defined and checkbox.other %}
11
+ {% if checkbox.other %}
12
12
  {% set hasOther = true %}
13
13
  {% endif %}
14
14
  {% endfor %}
15
- {% if hasOther == false and params.autoSelect is defined and params.autoSelect and params.autoSelect.selectAllText is defined %}
15
+ {% if hasOther == false and params.autoSelect and params.autoSelect.selectAllText %}
16
16
  {% set btnClasses = ['small', 'secondary'] %}
17
- {% if params.borderlessParent is defined and params.borderlessParent == false %}
17
+ {% if params.borderlessParent == false %}
18
18
  {% set btnClasses = ['small', 'secondary', 'ghost-dark'] %}
19
19
  {% endif %}
20
20
  {{
@@ -33,19 +33,19 @@
33
33
  {% for checkbox in params.checkboxes %}
34
34
  {% set childIsChecked = false %}
35
35
  {% set labelHTML = checkbox.label.text %}
36
- {% if params.mutuallyExclusive is defined and params.mutuallyExclusive %}
36
+ {% if params.mutuallyExclusive %}
37
37
  {% set exclusiveClass = ' ons-js-exclusive-group-item' %}
38
38
  {% endif %}
39
- {% if params.borderless is defined and params.borderless %}
39
+ {% if params.borderless %}
40
40
  {% set borderless = " ons-checkbox--no-border" %}
41
41
  {% endif %}
42
- {% if checkbox.other is defined and checkbox.other %}
42
+ {% if checkbox.other %}
43
43
  {% set otherClass = " ons-js-other" %}
44
- {% if checkbox.other.selectAllChildren is defined and checkbox.other.selectAllChildren == true %}
44
+ {% if checkbox.other.selectAllChildren == true %}
45
45
  {% set otherClass = otherClass + " ons-js-select-all-children" %}
46
46
  {% endif %}
47
47
  {% for otherCheckbox in checkbox.other.checkboxes %}
48
- {% if otherCheckbox.checked is defined and otherCheckbox.checked %}
48
+ {% if otherCheckbox.checked %}
49
49
  {% set childIsChecked = true %}
50
50
  {% endif %}
51
51
  {% endfor %}
@@ -69,7 +69,7 @@
69
69
  "attributes": checkbox.attributes
70
70
  } %}
71
71
 
72
- {% if checkbox.other is defined and checkbox.other %}
72
+ {% if checkbox.other %}
73
73
  {% set config = config | setAttributes({
74
74
  "other": {
75
75
  "open": checkbox.other.open | default(false),
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
  {% endset %}
105
105
 
106
- {% if params.mutuallyExclusive is defined and params.mutuallyExclusive %}
106
+ {% if params.mutuallyExclusive %}
107
107
  {% call onsMutuallyExclusive({
108
108
  "id": params.id,
109
109
  "classes": params.classes,
@@ -1,14 +1,15 @@
1
1
  export default class CheckboxWithFieldset {
2
- constructor(fieldset, inputs) {
2
+ constructor(fieldset, checkboxes) {
3
3
  this.fieldset = fieldset;
4
- this.inputs = inputs;
4
+ this.checkboxes = checkboxes;
5
+ this.fieldsetParent = fieldset.closest('.ons-checkbox');
6
+ this.selectAllChildrenInput = this.fieldsetParent.querySelector('.ons-js-select-all-children');
5
7
  this.childInputs = [...this.fieldset.querySelectorAll('input')];
6
- this.selectAllChildrenInput = this.inputs.find(input => input.classList.contains('ons-js-select-all-children'));
7
8
 
8
9
  if (this.selectAllChildrenInput) {
9
10
  this.selectAllChildrenInput.addEventListener('change', this.checkChildInputsOnSelect.bind(this));
10
11
  } else {
11
- this.inputs.forEach(input => input.addEventListener('change', this.uncheckChildInputsOnDeselect.bind(this)));
12
+ this.checkboxes.forEach(checkbox => checkbox.addEventListener('change', this.uncheckChildInputsOnDeselect.bind(this)));
12
13
  }
13
14
  }
14
15
 
@@ -19,7 +20,7 @@ export default class CheckboxWithFieldset {
19
20
  }
20
21
 
21
22
  uncheckChildInputsOnDeselect() {
22
- const isOther = this.inputs.find(input => input.classList.contains('ons-js-other'));
23
+ const isOther = this.checkboxes.find(checkbox => checkbox.classList.contains('ons-js-other'));
23
24
  if (isOther && isOther.checked === false) {
24
25
  this.childInputs.forEach(input => {
25
26
  input.checked = false;
@@ -15,16 +15,13 @@ domready(async () => {
15
15
  new CheckCheckbox(checkboxInput, openOther);
16
16
  }
17
17
 
18
- const other = document.querySelector('.ons-js-other');
19
- if (other) {
20
- const selectAllChildrenInput = other.classList.contains('ons-js-select-all-children');
21
- const otherFieldset = other.parentNode.querySelector('.ons-js-other-fieldset');
18
+ const otherFieldsets = [...document.querySelectorAll('.ons-js-other-fieldset')];
19
+ if (otherFieldsets) {
20
+ const CheckboxWithInnerFieldset = (await import('./checkbox-with-fieldset')).default;
22
21
 
23
- if (otherFieldset) {
24
- const CheckboxWithInnerFieldset = (await import('./checkbox-with-fieldset')).default;
25
-
26
- new CheckboxWithInnerFieldset(otherFieldset, checkboxes, selectAllChildrenInput);
27
- }
22
+ otherFieldsets.forEach(otherFieldset => {
23
+ new CheckboxWithInnerFieldset(otherFieldset, checkboxes);
24
+ });
28
25
  }
29
26
 
30
27
  const autoSelectButtons = [...document.querySelectorAll('.ons-js-auto-selector')];
@@ -1,5 +1,5 @@
1
1
  {% macro onsCodeHighlight(params) %}
2
2
  <pre class="ons-patternlib-example__pre">{#
3
- #}<code class="ons-patternlib-example__code ons-language-{{ params.language if params.language and params.language is defined else 'markup' }}">{{ params.code }}</code>{#
3
+ #}<code class="ons-patternlib-example__code ons-language-{{ params.language if params.language else 'markup' }}">{{ params.code }}</code>{#
4
4
  #}</pre>
5
5
  {% endmacro %}
@@ -1,15 +1,15 @@
1
1
  {% macro onsCollapsible(params) %}
2
2
  <details
3
3
  id="{{ params.id }}"
4
- class="ons-collapsible ons-js-collapsible{% if params.isAccordion is defined and params.isAccordion %} ons-collapsible--accordion{% endif %}{% if params.classes is defined and params.classes %} {{ params.classes }}{% endif %}"
5
- {% if params.group is defined and params.group %} data-group="{{ params.group }}"{% endif %}
6
- {% 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 %}
7
- {% if params.saveState is defined and params.saveState %} data-save-state="true"{% endif %}
8
- {% if params.open is defined and params.open %} data-open="true"{% endif %}
4
+ class="ons-collapsible ons-js-collapsible{% if params.isAccordion %} ons-collapsible--accordion{% endif %}{% if params.classes %} {{ params.classes }}{% endif %}"
5
+ {% if params.group %} data-group="{{ params.group }}"{% endif %}
6
+ {% 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 %}
7
+ {% if params.saveState %} data-save-state="true"{% endif %}
8
+ {% if params.open %} data-open="true"{% endif %}
9
9
  >
10
10
  <summary
11
11
  class="ons-collapsible__heading ons-js-collapsible-heading"
12
- {% if params.headingAttributes is defined and params.headingAttributes %}{% for attribute, value in (params.headingAttributes.items() if params.headingAttributes is mapping and params.headingAttributes.items else params.headingAttributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
12
+ {% if params.headingAttributes %}{% for attribute, value in (params.headingAttributes.items() if params.headingAttributes is mapping and params.headingAttributes.items else params.headingAttributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
13
13
  >
14
14
  {% set titleTag = params.titleTag | default("h2") %}
15
15
  <{{ titleTag }} class="ons-collapsible__title">{{ params.title }}</{{ titleTag }}>
@@ -22,7 +22,7 @@
22
22
  }}</span>
23
23
  </summary>
24
24
  <div id="{{ params.id }}-content" class="ons-collapsible__content ons-js-collapsible-content"
25
- {% if params.contentAttributes is defined and params.contentAttributes %}{% for attribute, value in (params.contentAttributes.items() if params.contentAttributes is mapping and params.contentAttributes.items else params.contentAttributes) %}{{ attribute }}{% if value is defined and value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
25
+ {% if params.contentAttributes %}{% for attribute, value in (params.contentAttributes.items() if params.contentAttributes is mapping and params.contentAttributes.items else params.contentAttributes) %}{{ attribute }}{% if value %}="{{ value }}"{% endif %} {% endfor %}{% endif %}
26
26
  >
27
27
  {{ params.content | safe }}{{ caller() if caller }}
28
28
  </div>
@@ -21,7 +21,7 @@
21
21
  {%- endif -%}
22
22
 
23
23
  {% set fields %}
24
- {% if params.day is defined and params.day %}
24
+ {% if params.day %}
25
25
  {{ onsInput({
26
26
  "id": params.id + "-day",
27
27
  "type": "number",
@@ -41,7 +41,7 @@
41
41
  }) }}
42
42
  {% endif %}
43
43
 
44
- {% if params.month is defined and params.month %}
44
+ {% if params.month %}
45
45
  {{ onsInput({
46
46
  "id": params.id + "-month",
47
47
  "type": "number",
@@ -61,7 +61,7 @@
61
61
  }) }}
62
62
  {% endif %}
63
63
 
64
- {% if params.year is defined and params.year %}
64
+ {% if params.year %}
65
65
  {{ onsInput({
66
66
  "id": params.id + "-year",
67
67
  "type": "number",
@@ -90,7 +90,7 @@
90
90
  {% endset %}
91
91
  {% endif %}
92
92
 
93
- {% if params.mutuallyExclusive is defined and params.mutuallyExclusive %}
93
+ {% if params.mutuallyExclusive %}
94
94
  {% call onsMutuallyExclusive({
95
95
  "id": params.id,
96
96
  "legend": params.legendOrLabel,
@@ -109,7 +109,7 @@
109
109
  {{ fields | safe }}
110
110
  {% endcall %}
111
111
  {% elif numberOfFields == 1 %}
112
- {% if params.error is defined and params.error %}
112
+ {% if params.error %}
113
113
  {% call onsError(params.error) %}
114
114
  {{ fields | safe }}
115
115
  {% endcall %}