@ons/design-system 67.2.0 → 68.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +6 -0
  2. package/components/access-code/_macro.njk +1 -1
  3. package/components/access-code/_macro.spec.js +2 -10
  4. package/components/access-code/access-code.dom.js +1 -1
  5. package/components/access-code/access-code.spec.js +2 -2
  6. package/components/access-code/example-access-code-error.njk +9 -14
  7. package/components/access-code/example-access-code.njk +3 -5
  8. package/components/accordion/accordion.js +4 -4
  9. package/components/address-input/_macro.spec.js +3 -15
  10. package/components/address-input/autosuggest.address.dom.js +1 -1
  11. package/components/address-input/autosuggest.address.js +3 -2
  12. package/components/address-input/autosuggest.address.setter.js +3 -3
  13. package/components/address-input/autosuggest.address.spec.js +66 -69
  14. package/components/address-output/_macro.spec.js +6 -30
  15. package/components/autosuggest/_autosuggest.scss +1 -1
  16. package/components/autosuggest/autosuggest.dom.js +1 -1
  17. package/components/autosuggest/autosuggest.helpers.js +1 -1
  18. package/components/back-to-top/_back-to-top.scss +34 -0
  19. package/components/back-to-top/_macro.njk +17 -0
  20. package/components/back-to-top/_macro.spec.js +60 -0
  21. package/components/back-to-top/back-to-top.dom.js +12 -0
  22. package/components/back-to-top/back-to-top.js +58 -0
  23. package/components/back-to-top/back-to-top.spec.js +117 -0
  24. package/components/back-to-top/example-back-to-top.njk +37 -0
  25. package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
  26. package/components/browser-banner/_macro.spec.js +4 -12
  27. package/components/button/_macro.njk +6 -6
  28. package/components/button/_macro.spec.js +1 -5
  29. package/components/button/button.js +7 -8
  30. package/components/button/button.spec.js +17 -39
  31. package/components/call-to-action/_macro.spec.js +2 -6
  32. package/components/card/_macro.njk +25 -25
  33. package/components/card/_macro.spec.js +10 -34
  34. package/components/char-check-limit/_macro.njk +1 -1
  35. package/components/char-check-limit/_macro.spec.js +3 -7
  36. package/components/char-check-limit/character-check.spec.js +24 -20
  37. package/components/checkboxes/_checkbox-macro.njk +1 -1
  38. package/components/checkboxes/_checkbox.scss +0 -3
  39. package/components/checkboxes/_macro.spec.js +1 -5
  40. package/components/checkboxes/checkbox-with-autoselect.js +3 -3
  41. package/components/checkboxes/checkbox-with-fieldset.js +2 -2
  42. package/components/checkboxes/checkboxes-with-reveal.js +4 -2
  43. package/components/checkboxes/checkboxes.dom.js +2 -2
  44. package/components/checkboxes/checkboxes.spec.js +13 -13
  45. package/components/content-pagination/_macro.spec.js +2 -2
  46. package/components/cookies-banner/cookies-banner.dom.js +1 -1
  47. package/components/cookies-banner/cookies-banner.js +1 -1
  48. package/components/cookies-banner/cookies-banner.spec.js +7 -7
  49. package/components/date-input/_macro.njk +71 -69
  50. package/components/date-input/_macro.spec.js +20 -5
  51. package/components/date-input/example-date-input-double-field.njk +27 -0
  52. package/components/date-input/example-date-input-single-field.njk +18 -0
  53. package/components/details/details.spec.js +12 -12
  54. package/components/details/example-details-with-warning.njk +5 -7
  55. package/components/document-list/_macro.spec.js +9 -27
  56. package/components/document-list/document-list.scss +1 -1
  57. package/components/document-list/example-document-list-downloads.njk +3 -3
  58. package/components/document-list/example-document-list-search-result-featured.njk +1 -1
  59. package/components/document-list/example-document-list-search-results.njk +3 -3
  60. package/components/download-resources/download-resources.js +54 -54
  61. package/components/download-resources/download-resources.spec.js +3 -1
  62. package/components/duration/_macro.njk +52 -48
  63. package/components/duration/_macro.spec.js +112 -4
  64. package/components/duration/example-duration-error-for-single-field.njk +1 -1
  65. package/components/duration/example-duration-single-field.njk +24 -0
  66. package/components/error/_macro.njk +1 -1
  67. package/components/error/_macro.spec.js +2 -6
  68. package/components/feedback/_macro.njk +1 -1
  69. package/components/feedback/_macro.spec.js +4 -20
  70. package/components/field/_field-group.scss +3 -4
  71. package/components/field/_macro.spec.js +1 -3
  72. package/components/fieldset/_fieldset.scss +1 -2
  73. package/components/fieldset/_macro.spec.js +3 -9
  74. package/components/footer/_footer.scss +8 -0
  75. package/components/footer/_macro.njk +8 -7
  76. package/components/footer/_macro.spec.js +14 -2
  77. package/components/header/_macro.njk +1 -1
  78. package/components/header/_macro.spec.js +1 -1
  79. package/components/helpers/grid.njk +15 -15
  80. package/components/icon/_macro.njk +17 -13
  81. package/components/icon/_macro.spec.js +8 -16
  82. package/components/image/_macro.spec.js +1 -5
  83. package/components/input/_macro.njk +22 -23
  84. package/components/input/_macro.spec.js +1 -1
  85. package/components/input/character-check.dom.js +1 -1
  86. package/components/input/input.spec.js +1 -4
  87. package/components/label/_label.scss +1 -0
  88. package/components/label/_macro.njk +3 -3
  89. package/components/label/_macro.spec.js +4 -13
  90. package/components/list/_macro.spec.js +4 -12
  91. package/components/message/_macro.njk +17 -17
  92. package/components/message/_macro.spec.js +9 -33
  93. package/components/message-list/_macro.spec.js +7 -39
  94. package/components/metadata/_macro.njk +10 -10
  95. package/components/modal/_macro.spec.js +3 -9
  96. package/components/modal/modal.dom.js +1 -1
  97. package/components/modal/modal.spec.js +5 -5
  98. package/components/multiple-input-fields/_macro.njk +49 -0
  99. package/components/mutually-exclusive/_macro.spec.js +2 -10
  100. package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
  101. package/components/mutually-exclusive/mutually-exclusive.date.spec.js +128 -14
  102. package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
  103. package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +129 -8
  104. package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
  105. package/components/mutually-exclusive/mutually-exclusive.js +13 -13
  106. package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
  107. package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
  108. package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
  109. package/components/navigation/navigation.spec.js +0 -2
  110. package/components/pagination/_macro.spec.js +11 -53
  111. package/components/panel/_macro.njk +17 -17
  112. package/components/panel/_macro.spec.js +25 -25
  113. package/components/panel/_panel.scss +10 -9
  114. package/components/panel/example-panel-bare.njk +3 -4
  115. package/components/panel/example-panel-with-announcement.njk +6 -10
  116. package/components/panel/example-panel-with-error-summary.njk +2 -2
  117. package/components/panel/example-panel-with-information.njk +0 -1
  118. package/components/panel/example-panel-with-success-message.njk +1 -1
  119. package/components/panel/example-panel-with-warning.njk +2 -3
  120. package/components/password/password.dom.js +1 -1
  121. package/components/phase-banner/_macro.spec.js +3 -9
  122. package/components/question/_macro.njk +1 -1
  123. package/components/question/_macro.spec.js +5 -19
  124. package/components/question/_question.scss +1 -4
  125. package/components/question/example-question-interviewer-note.njk +1 -1
  126. package/components/quote/_macro.spec.js +2 -10
  127. package/components/radios/clear-radios.js +3 -3
  128. package/components/radios/radio-with-fieldset.js +4 -4
  129. package/components/radios/radios.dom.js +1 -1
  130. package/components/radios/radios.spec.js +26 -26
  131. package/components/related-content/_macro.spec.js +2 -4
  132. package/components/related-content/_section-macro.spec.js +2 -8
  133. package/components/relationships/example-relationships-error.njk +16 -18
  134. package/components/relationships/relationships.dom.js +1 -1
  135. package/components/relationships/relationships.js +2 -2
  136. package/components/reply/_macro.spec.js +3 -3
  137. package/components/reply/reply.dom.js +1 -1
  138. package/components/reply/reply.spec.js +3 -3
  139. package/components/section-navigation/_macro.njk +12 -12
  140. package/components/section-navigation/_macro.spec.js +13 -21
  141. package/components/select/_macro.spec.js +6 -6
  142. package/components/share-page/_macro.spec.js +6 -14
  143. package/components/skip-to-content/_macro.spec.js +3 -11
  144. package/components/skip-to-content/skip-to-content.dom.js +1 -1
  145. package/components/skip-to-content/skip-to-content.js +1 -1
  146. package/components/skip-to-content/skip-to-content.spec.js +2 -2
  147. package/components/status/_macro.njk +2 -2
  148. package/components/status/_macro.spec.js +5 -9
  149. package/components/status/example-status-dead.njk +1 -1
  150. package/components/status/example-status-error.njk +1 -1
  151. package/components/status/example-status-pending.njk +1 -1
  152. package/components/status/example-status-small.njk +1 -1
  153. package/components/status/example-status-success.njk +1 -1
  154. package/components/summary/_macro.njk +7 -8
  155. package/components/summary/_macro.spec.js +27 -9
  156. package/components/table/_macro.spec.js +6 -10
  157. package/components/table/scrollable-table.dom.js +1 -1
  158. package/components/table/scrollable-table.js +1 -1
  159. package/components/table/sortable-table.js +4 -4
  160. package/components/table/table.spec.js +21 -17
  161. package/components/table-of-contents/_macro.njk +31 -31
  162. package/components/table-of-contents/_macro.spec.js +3 -11
  163. package/components/table-of-contents/toc.dom.js +1 -1
  164. package/components/table-of-contents/toc.spec.js +36 -32
  165. package/components/tabs/example-tabs-details.njk +1 -1
  166. package/components/tabs/tabs.dom.js +1 -1
  167. package/components/tabs/tabs.js +8 -8
  168. package/components/text-indent/_macro.spec.js +2 -6
  169. package/components/textarea/textarea.dom.js +1 -1
  170. package/components/textarea/textarea.spec.js +8 -8
  171. package/components/timeout-modal/_macro.spec.js +1 -3
  172. package/components/timeout-modal/timeout-modal.dom.js +1 -1
  173. package/components/timeout-modal/timeout-modal.spec.js +10 -10
  174. package/components/timeout-panel/_macro.njk +16 -17
  175. package/components/timeout-panel/_macro.spec.js +1 -1
  176. package/components/timeout-panel/timeout-panel.dom.js +1 -1
  177. package/components/timeout-panel/timeout-panel.spec.js +8 -8
  178. package/components/video/_macro.spec.js +1 -5
  179. package/components/video/video.dom.js +1 -1
  180. package/components/video/video.spec.js +16 -12
  181. package/css/main.css +1 -1
  182. package/favicons/safari-pinned-tab.svg +23 -23
  183. package/js/analytics.js +15 -14
  184. package/js/cookies-settings.dom.js +1 -1
  185. package/js/cookies-settings.spec.js +19 -19
  186. package/js/domready.js +1 -1
  187. package/js/fetch.js +1 -1
  188. package/js/inpagelink.js +3 -3
  189. package/js/main.js +1 -0
  190. package/js/print-button.js +1 -1
  191. package/js/timeout.js +1 -1
  192. package/package.json +2 -1
  193. package/scripts/main.es5.js +1 -1
  194. package/scripts/main.js +1 -1
  195. package/scss/base/_typography.scss +8 -2
  196. package/scss/main.scss +1 -0
  197. package/scss/overrides/hcm.scss +8 -1
  198. package/scss/vars/_colors.scss +2 -1
  199. package/components/date-field-input/_macro.njk +0 -86
@@ -2,7 +2,7 @@ import { renderComponent, setTestPage } from '../../tests/helpers/rendering';
2
2
 
3
3
  const EXAMPLE_INPUT_WITH_CHARACTER_CHECK = {
4
4
  id: 'search-field',
5
- type: 'number',
5
+ variant: 'number',
6
6
  width: '6',
7
7
  label: {
8
8
  text: 'Filter results',
@@ -24,7 +24,7 @@ const EXAMPLE_CHARACTER_CHECK_WITH_MUTUALLY_EXCLUSIVE = {
24
24
  id: 'feedback',
25
25
  name: 'feedback',
26
26
  width: '30',
27
- legend: 'Feeback legend',
27
+ legend: 'Feedback legend',
28
28
  label: {
29
29
  text: 'Enter your feedback',
30
30
  },
@@ -59,12 +59,12 @@ describe('script: character-check', () => {
59
59
 
60
60
  describe('Given that the char check helper has initialised correctly', () => {
61
61
  it('the char check readout should be invisible', async () => {
62
- const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
62
+ const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
63
63
  expect(hasClass).toBe(true);
64
64
  });
65
65
 
66
66
  it('then the character limit readout should reflect the number of characters remaining', async () => {
67
- const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
67
+ const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
68
68
  expect(innerHtml.trim()).toBe('You have 11 characters remaining');
69
69
  });
70
70
  });
@@ -76,17 +76,17 @@ describe('script: character-check', () => {
76
76
  });
77
77
 
78
78
  it('then the characters remaining readout reflect the number of characters remaining', async () => {
79
- const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
79
+ const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
80
80
  expect(innerHtml.trim()).toBe('You have 10 characters remaining');
81
81
  });
82
82
 
83
83
  it('the char check readout should be visible', async () => {
84
- const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
84
+ const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
85
85
  expect(hasClass).toBe(false);
86
86
  });
87
87
 
88
88
  it('then aria-live should be set to polite', async () => {
89
- const ariaLiveAttribute = await page.$eval('#search-field-check', element => element.getAttribute('aria-live'));
89
+ const ariaLiveAttribute = await page.$eval('#search-field-check', (element) => element.getAttribute('aria-live'));
90
90
  expect(ariaLiveAttribute).toBe('polite');
91
91
  });
92
92
  });
@@ -97,7 +97,7 @@ describe('script: character-check', () => {
97
97
  });
98
98
 
99
99
  it('the char check readout should be invisible', async () => {
100
- const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
100
+ const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
101
101
  expect(hasClass).toBe(true);
102
102
  });
103
103
  });
@@ -108,7 +108,7 @@ describe('script: character-check', () => {
108
108
  });
109
109
 
110
110
  it('then the characters remaining readout reflect the number of characters remaining', async () => {
111
- const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
111
+ const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
112
112
  expect(innerHtml.trim()).toBe('You have 1 character remaining');
113
113
  });
114
114
  });
@@ -120,24 +120,26 @@ describe('script: character-check', () => {
120
120
  });
121
121
 
122
122
  it('the char check readout should be visible', async () => {
123
- const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
123
+ const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
124
124
  expect(hasClass).toBe(false);
125
125
  });
126
126
 
127
127
  it('then the characters remaining readout reflect the number of characters exceeded', async () => {
128
- const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
128
+ const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
129
129
  expect(innerHtml.trim()).toBe('1 number too many');
130
130
  });
131
131
 
132
132
  it('then aria-live should be set to assertive', async () => {
133
- const ariaLiveAttribute = await page.$eval('#search-field-check', element => element.getAttribute('aria-live'));
133
+ const ariaLiveAttribute = await page.$eval('#search-field-check', (element) => element.getAttribute('aria-live'));
134
134
  expect(ariaLiveAttribute).toBe('assertive');
135
135
  });
136
136
 
137
137
  it('then the input and readout should be given limit reached classes', async () => {
138
- const hasClassOnSearchInput = await page.$eval('#search-field', element => element.classList.contains('ons-input--limit-reached'));
138
+ const hasClassOnSearchInput = await page.$eval('#search-field', (element) =>
139
+ element.classList.contains('ons-input--limit-reached'),
140
+ );
139
141
  expect(hasClassOnSearchInput).toBe(true);
140
- const hasClassOnLimitReadout = await page.$eval('#search-field-check', element =>
142
+ const hasClassOnLimitReadout = await page.$eval('#search-field-check', (element) =>
141
143
  element.classList.contains('ons-input__limit--reached'),
142
144
  );
143
145
  expect(hasClassOnLimitReadout).toBe(true);
@@ -150,24 +152,26 @@ describe('script: character-check', () => {
150
152
  });
151
153
 
152
154
  it('the char check readout should be visible', async () => {
153
- const hasClass = await page.$eval('#search-field-check', element => element.classList.contains('ons-u-d-no'));
155
+ const hasClass = await page.$eval('#search-field-check', (element) => element.classList.contains('ons-u-d-no'));
154
156
  expect(hasClass).toBe(false);
155
157
  });
156
158
 
157
159
  it('then the characters remaining readout reflect the number of characters exceeded', async () => {
158
- const innerHtml = await page.$eval('#search-field-check', element => element.innerHTML);
160
+ const innerHtml = await page.$eval('#search-field-check', (element) => element.innerHTML);
159
161
  expect(innerHtml.trim()).toBe('2 numbers too many');
160
162
  });
161
163
 
162
164
  it('then aria-live should be set to assertive', async () => {
163
- const ariaLiveAttribute = await page.$eval('#search-field-check', element => element.getAttribute('aria-live'));
165
+ const ariaLiveAttribute = await page.$eval('#search-field-check', (element) => element.getAttribute('aria-live'));
164
166
  expect(ariaLiveAttribute).toBe('assertive');
165
167
  });
166
168
 
167
169
  it('then the input and readout should be given limit reached classes', async () => {
168
- const hasClassOnSearchInput = await page.$eval('#search-field', element => element.classList.contains('ons-input--limit-reached'));
170
+ const hasClassOnSearchInput = await page.$eval('#search-field', (element) =>
171
+ element.classList.contains('ons-input--limit-reached'),
172
+ );
169
173
  expect(hasClassOnSearchInput).toBe(true);
170
- const hasClassOnLimitReadout = await page.$eval('#search-field-check', element =>
174
+ const hasClassOnLimitReadout = await page.$eval('#search-field-check', (element) =>
171
175
  element.classList.contains('ons-input__limit--reached'),
172
176
  );
173
177
  expect(hasClassOnLimitReadout).toBe(true);
@@ -188,7 +192,7 @@ describe('script: character-check', () => {
188
192
  });
189
193
 
190
194
  it('then aria-live attribute should removed', async () => {
191
- const hasAriaLiveAttribute = await page.$eval('#feedback-lim', element => element.hasAttribute('aria-live'));
195
+ const hasAriaLiveAttribute = await page.$eval('#feedback-lim', (element) => element.hasAttribute('aria-live'));
192
196
  expect(hasAriaLiveAttribute).toBe(false);
193
197
  });
194
198
  });
@@ -7,7 +7,7 @@
7
7
  id="{{ params.id }}"
8
8
  class="ons-checkbox__input ons-js-checkbox{{ ' ' + params.inputClasses if params.inputClasses else '' }}"
9
9
  value="{{ params.value }}"
10
- {% if params.disabled == true %}disabled aria-disabled="true"{%endif %}
10
+ {% if params.disabled == true %}disabled aria-disabled="true"{% endif %}
11
11
  {% if params.name %} name="{{ params.name }}"{% endif %}
12
12
  {% if params.checked %} checked{% endif %}
13
13
  {% if params.other and not params.other.open %} aria-controls="{{ params.id }}-other-wrap" aria-haspopup="true"{% endif %}
@@ -24,7 +24,6 @@ $checkbox-padding: 11px;
24
24
  // Check icon
25
25
  &::after {
26
26
  border: solid var(--ons-color-input-border);
27
- border-radius: 1px;
28
27
  border-top-color: var(--ons-color-input-bg);
29
28
  border-width: 0 0 3px 3px;
30
29
  box-sizing: border-box;
@@ -94,7 +93,6 @@ $checkbox-padding: 11px;
94
93
 
95
94
  &:checked,
96
95
  &:focus {
97
-
98
96
  & + .ons-checkbox__label::before {
99
97
  background: none;
100
98
  border: none;
@@ -122,7 +120,6 @@ $checkbox-padding: 11px;
122
120
 
123
121
  &:checked,
124
122
  &:focus {
125
-
126
123
  & + .ons-checkbox__label::before {
127
124
  background: none;
128
125
  border: none;
@@ -125,11 +125,7 @@ describe('macro: checkboxes', () => {
125
125
  it('has the expected text', () => {
126
126
  const $ = cheerio.load(renderComponent('checkboxes', EXAMPLE_CHECKBOXES));
127
127
 
128
- expect(
129
- $('.ons-checkboxes__label')
130
- .text()
131
- .trim(),
132
- ).toBe('Select all that apply');
128
+ expect($('.ons-checkboxes__label').text().trim()).toBe('Select all that apply');
133
129
  });
134
130
 
135
131
  it('has additionally provided `checkboxesLabelClasses`', () => {
@@ -6,7 +6,7 @@ export default class CheckboxWithAutoSelect {
6
6
  this.insideReveal = insideReveal;
7
7
  // Event listeners
8
8
  this.button.addEventListener('click', this.handleButtonEvent.bind(this));
9
- this.checkboxes.forEach(checkbox => checkbox.addEventListener('change', this.handleCheckboxEvent.bind(this)));
9
+ this.checkboxes.forEach((checkbox) => checkbox.addEventListener('change', this.handleCheckboxEvent.bind(this)));
10
10
  if (this.insideReveal) {
11
11
  this.insideReveal.addEventListener('change', this.handleCheckboxEvent.bind(this));
12
12
  }
@@ -23,7 +23,7 @@ export default class CheckboxWithAutoSelect {
23
23
 
24
24
  handleButtonEvent(event) {
25
25
  event.preventDefault();
26
- this.checkboxes.forEach(checkbox => {
26
+ this.checkboxes.forEach((checkbox) => {
27
27
  checkbox.checked = this.allChecked === false ? true : false;
28
28
  });
29
29
  this.buttonText.innerHTML = this.allChecked === false ? this.unselectAllText : this.selectAllText;
@@ -31,7 +31,7 @@ export default class CheckboxWithAutoSelect {
31
31
  }
32
32
 
33
33
  handleCheckboxEvent() {
34
- const totalChecked = this.checkboxes.filter(checkbox => checkbox.checked).length;
34
+ const totalChecked = this.checkboxes.filter((checkbox) => checkbox.checked).length;
35
35
  this.buttonText.innerHTML = totalChecked === this.numberOfCheckboxes ? this.unselectAllText : this.selectAllText;
36
36
  this.allChecked = totalChecked === this.numberOfCheckboxes ? true : false;
37
37
  }
@@ -13,14 +13,14 @@ export default class CheckboxWithFieldset {
13
13
  }
14
14
 
15
15
  checkChildInputsOnSelect() {
16
- this.childInputs.forEach(input => {
16
+ this.childInputs.forEach((input) => {
17
17
  input.checked = this.selectAllChildrenInput.checked === true ? true : false;
18
18
  });
19
19
  }
20
20
 
21
21
  uncheckChildInputsOnDeselect() {
22
22
  if (this.checkbox.checked === false) {
23
- this.childInputs.forEach(input => {
23
+ this.childInputs.forEach((input) => {
24
24
  input.checked = false;
25
25
  });
26
26
  }
@@ -1,11 +1,13 @@
1
1
  export default class Checkboxes {
2
2
  constructor(inputs) {
3
3
  this.inputs = inputs;
4
- this.inputs.forEach(input => input.addEventListener('change', this.setExpandedAttributes.bind(this)));
4
+ this.inputs.forEach((input) => input.addEventListener('change', this.setExpandedAttributes.bind(this)));
5
5
  this.setExpandedAttributes();
6
6
  }
7
7
 
8
8
  setExpandedAttributes() {
9
- this.inputs.filter(input => input.hasAttribute('aria-haspopup')).forEach(input => input.setAttribute('aria-expanded', input.checked));
9
+ this.inputs
10
+ .filter((input) => input.hasAttribute('aria-haspopup'))
11
+ .forEach((input) => input.setAttribute('aria-expanded', input.checked));
10
12
  }
11
13
  }
@@ -18,7 +18,7 @@ domready(async () => {
18
18
  const otherFieldsets = [...document.querySelectorAll('.ons-js-other-fieldset-checkbox')];
19
19
  if (otherFieldsets) {
20
20
  const CheckboxWithInnerFieldset = (await import('./checkbox-with-fieldset')).default;
21
- otherFieldsets.forEach(otherFieldset => {
21
+ otherFieldsets.forEach((otherFieldset) => {
22
22
  const context = otherFieldset.closest('.ons-checkbox');
23
23
  new CheckboxWithInnerFieldset(context);
24
24
  });
@@ -27,7 +27,7 @@ domready(async () => {
27
27
  const autoSelectButtons = [...document.querySelectorAll('.ons-js-auto-selector')];
28
28
  if (autoSelectButtons) {
29
29
  const CheckboxWithAutoSelect = (await import('./checkbox-with-autoselect')).default;
30
- autoSelectButtons.forEach(button => {
30
+ autoSelectButtons.forEach((button) => {
31
31
  const context = button.parentNode;
32
32
  const insideReveal = context.parentNode.parentNode.querySelector('.ons-js-other');
33
33
  new CheckboxWithAutoSelect(context, button, insideReveal);
@@ -47,12 +47,12 @@ describe('script: checkboxes', () => {
47
47
  });
48
48
 
49
49
  it('all checkboxes should be checked', async () => {
50
- const checkedStates = await page.$$eval('.ons-js-checkbox', nodes => nodes.map(node => node.checked));
50
+ const checkedStates = await page.$$eval('.ons-js-checkbox', (nodes) => nodes.map((node) => node.checked));
51
51
  expect(checkedStates).toEqual([true, true, true]);
52
52
  });
53
53
 
54
54
  it('the button text should have changed', async () => {
55
- const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
55
+ const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
56
56
  expect(buttonText).toBe('Unselect all');
57
57
  });
58
58
  });
@@ -64,23 +64,23 @@ describe('script: checkboxes', () => {
64
64
  });
65
65
 
66
66
  it('all checkboxes should be unchecked', async () => {
67
- const checkedStates = await page.$$eval('.ons-js-checkbox', nodes => nodes.map(node => node.checked));
67
+ const checkedStates = await page.$$eval('.ons-js-checkbox', (nodes) => nodes.map((node) => node.checked));
68
68
  expect(checkedStates).toEqual([false, false, false]);
69
69
  });
70
70
 
71
71
  it('the button text should have changed', async () => {
72
- const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
72
+ const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
73
73
  expect(buttonText).toBe('Select all');
74
74
  });
75
75
  });
76
76
 
77
77
  describe('when all except one checkbox is checked', () => {
78
78
  beforeEach(async () => {
79
- await page.$eval('#olives-other', node => (node.checked = true));
79
+ await page.$eval('#olives-other', (node) => (node.checked = true));
80
80
  });
81
81
 
82
82
  it('the button text should be select all', async () => {
83
- const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
83
+ const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
84
84
  expect(buttonText).toBe('Select all');
85
85
  });
86
86
  });
@@ -93,13 +93,13 @@ describe('script: checkboxes', () => {
93
93
  });
94
94
 
95
95
  it('the button text should be unselect all', async () => {
96
- const buttonText = await page.$eval('.ons-js-button-text', node => node.textContent);
96
+ const buttonText = await page.$eval('.ons-js-button-text', (node) => node.textContent);
97
97
  expect(buttonText).toBe('Unselect all');
98
98
  });
99
99
  });
100
100
  });
101
101
 
102
- describe('reveal and fieldset', function() {
102
+ describe('reveal and fieldset', function () {
103
103
  const params = {
104
104
  legend: 'What are your favourite pizza toppings?',
105
105
  checkboxesLabel: 'Select all that apply',
@@ -157,7 +157,7 @@ describe('script: checkboxes', () => {
157
157
  });
158
158
 
159
159
  it('checkboxes with other options should be given aria-expanded attributes', async () => {
160
- const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
160
+ const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
161
161
  expect(ariaExpanded).toBe('false');
162
162
  });
163
163
 
@@ -167,7 +167,7 @@ describe('script: checkboxes', () => {
167
167
  });
168
168
 
169
169
  it('has aria-expanded attribute should be set to true', async () => {
170
- const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
170
+ const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
171
171
  expect(ariaExpanded).toBe('true');
172
172
  });
173
173
 
@@ -177,7 +177,7 @@ describe('script: checkboxes', () => {
177
177
  });
178
178
 
179
179
  it('the checkbox with an other input aria-expanded attribute not change', async () => {
180
- const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
180
+ const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
181
181
  expect(ariaExpanded).toBe('true');
182
182
  });
183
183
  });
@@ -193,12 +193,12 @@ describe('script: checkboxes', () => {
193
193
  });
194
194
 
195
195
  it('its aria-expanded attribute should be set to false', async () => {
196
- const ariaExpanded = await page.$eval('#other-checkbox', node => node.getAttribute('aria-expanded'));
196
+ const ariaExpanded = await page.$eval('#other-checkbox', (node) => node.getAttribute('aria-expanded'));
197
197
  expect(ariaExpanded).toBe('false');
198
198
  });
199
199
 
200
200
  it('the child of other checkbox should be unchecked', async () => {
201
- const innerInputChecked = await page.$eval('#inner-bacon-other', node => node.checked);
201
+ const innerInputChecked = await page.$eval('#inner-bacon-other', (node) => node.checked);
202
202
  expect(innerInputChecked).toBe(false);
203
203
  });
204
204
  });
@@ -128,7 +128,7 @@ describe('macro: content-pagination', () => {
128
128
  it('renders the provided `bridgingText`', () => {
129
129
  const $ = cheerio.load(
130
130
  renderComponent('content-pagination', {
131
- contentPaginationItems: params.contentPaginationItems.map(item => ({
131
+ contentPaginationItems: params.contentPaginationItems.map((item) => ({
132
132
  ...item,
133
133
  bridgingText: 'custom bridging text:',
134
134
  })),
@@ -177,7 +177,7 @@ describe('macro: content-pagination', () => {
177
177
  it('renders the provided `bridgingText`', () => {
178
178
  const $ = cheerio.load(
179
179
  renderComponent('content-pagination', {
180
- contentPaginationItems: params.contentPaginationItems.map(item => ({
180
+ contentPaginationItems: params.contentPaginationItems.map((item) => ({
181
181
  ...item,
182
182
  bridgingText: 'custom bridging text:',
183
183
  })),
@@ -5,7 +5,7 @@ async function cookiesBanner() {
5
5
 
6
6
  if (cookiesBanner.length) {
7
7
  const CookiesBanner = (await import('./cookies-banner')).default;
8
- cookiesBanner.forEach(banner => {
8
+ cookiesBanner.forEach((banner) => {
9
9
  new CookiesBanner(banner);
10
10
  });
11
11
  }
@@ -70,7 +70,7 @@ export default class CookiesBanner {
70
70
 
71
71
  updateRadios(action) {
72
72
  const radios = [...document.querySelectorAll('.ons-js-radio')];
73
- radios.forEach(radio => {
73
+ radios.forEach((radio) => {
74
74
  if (action == 'reject') {
75
75
  radio.value == 'off' ? (radio.checked = true) : (radio.checked = false);
76
76
  } else if (action == 'accept') {
@@ -11,7 +11,7 @@ describe('script: cookies-banner', () => {
11
11
  it('should show the cookie banner', async () => {
12
12
  await setTestPage('/test', EXAMPLE_COOKIES_BANNER_PAGE);
13
13
 
14
- const displayStyle = await page.$eval('.ons-cookies-banner', node => window.getComputedStyle(node).getPropertyValue('display'));
14
+ const displayStyle = await page.$eval('.ons-cookies-banner', (node) => window.getComputedStyle(node).getPropertyValue('display'));
15
15
  expect(displayStyle).toBe('block');
16
16
  });
17
17
  describe.each([
@@ -24,7 +24,7 @@ describe('script: cookies-banner', () => {
24
24
  await page.click(`.ons-js-${action}-cookies`);
25
25
 
26
26
  const cookies = await page.cookies();
27
- const ons_cookie_policy = cookies.find(cookie => cookie.name === 'ons_cookie_policy');
27
+ const ons_cookie_policy = cookies.find((cookie) => cookie.name === 'ons_cookie_policy');
28
28
  const policy = JSON.parse(ons_cookie_policy.value.replace(/'/g, '"'));
29
29
 
30
30
  expect(policy).toEqual({
@@ -41,7 +41,7 @@ describe('script: cookies-banner', () => {
41
41
  await page.click(`.ons-js-${action}-cookies`);
42
42
 
43
43
  const cookies = await page.cookies();
44
- const ons_cookie_message_displayed = cookies.find(cookie => cookie.name === 'ons_cookie_message_displayed');
44
+ const ons_cookie_message_displayed = cookies.find((cookie) => cookie.name === 'ons_cookie_message_displayed');
45
45
 
46
46
  expect(ons_cookie_message_displayed.value).toBe('true');
47
47
  });
@@ -51,7 +51,7 @@ describe('script: cookies-banner', () => {
51
51
 
52
52
  await page.click(`.ons-js-${action}-cookies`);
53
53
 
54
- const displayStyle = await page.$eval('.ons-cookies-banner__primary', node =>
54
+ const displayStyle = await page.$eval('.ons-cookies-banner__primary', (node) =>
55
55
  window.getComputedStyle(node).getPropertyValue('display'),
56
56
  );
57
57
  expect(displayStyle).toBe('none');
@@ -62,7 +62,7 @@ describe('script: cookies-banner', () => {
62
62
 
63
63
  await page.click(`.ons-js-${action}-cookies`);
64
64
 
65
- const displayStyle = await page.$eval('.ons-cookies-banner__confirmation', node =>
65
+ const displayStyle = await page.$eval('.ons-cookies-banner__confirmation', (node) =>
66
66
  window.getComputedStyle(node).getPropertyValue('display'),
67
67
  );
68
68
  expect(displayStyle).not.toBe('none');
@@ -76,7 +76,7 @@ describe('script: cookies-banner', () => {
76
76
  await page.click('.ons-js-accept-cookies');
77
77
  await page.click('.ons-js-hide-button');
78
78
 
79
- const displayStyle = await page.$eval('.ons-cookies-banner', node => window.getComputedStyle(node).getPropertyValue('display'));
79
+ const displayStyle = await page.$eval('.ons-cookies-banner', (node) => window.getComputedStyle(node).getPropertyValue('display'));
80
80
  expect(displayStyle).toBe('none');
81
81
  });
82
82
  });
@@ -87,7 +87,7 @@ describe('script: cookies-banner', () => {
87
87
 
88
88
  await setTestPage('/test', EXAMPLE_COOKIES_BANNER_PAGE);
89
89
 
90
- const displayStyle = await page.$eval('.ons-cookies-banner', node => window.getComputedStyle(node).getPropertyValue('display'));
90
+ const displayStyle = await page.$eval('.ons-cookies-banner', (node) => window.getComputedStyle(node).getPropertyValue('display'));
91
91
  expect(displayStyle).toBe('none');
92
92
  });
93
93
  });
@@ -1,8 +1,9 @@
1
- {% from "components/date-field-input/_macro.njk" import onsDateFieldInput %}
1
+ {% from "components/multiple-input-fields/_macro.njk" import onsMultipleInputFields %}
2
+ {% from "components/input/_macro.njk" import onsInput %}
2
3
 
3
4
  {% macro onsDateInput(params) %}
4
5
  {% set exclusiveClass = " ons-js-exclusive-group-item" if params.mutuallyExclusive else "" %}
5
- {%- set numberOfFields = 0 -%}
6
+ {%- set numberOfFields = 0 -%}
6
7
 
7
8
  {%- if params.day -%}
8
9
  {%- set numberOfFields = numberOfFields + 1 -%}
@@ -16,82 +17,83 @@
16
17
  {%- set numberOfFields = numberOfFields + 1 -%}
17
18
  {%- endif -%}
18
19
 
19
- {% set fields = [] %}
20
- {% if params.day %}
21
- {% set dayField = {
22
- "id": params.id + "-day",
23
- "label": {
24
- "text": params.day.label.text if numberOfFields > 1 else params.legendOrLabel,
25
- "description": params.day.label.description if numberOfFields > 1 else params.description,
26
- "id": params.id + "-day-label"
27
- },
28
- "name": params.day.name,
29
- "width": "2",
30
- "min": 1,
31
- "max": 31,
32
- "maxLength": 2,
33
- "attributes": params.day.attributes,
34
- "value": params.day.value,
35
- "classes": (" ons-input--error" if (params.error and params.day.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
36
- } %}
37
- {% set fields = (fields.push(dayField), fields) %}
38
- {% endif %}
39
- {% if params.month %}
40
- {% set monthField = {
41
- "id": params.id + "-month",
42
- "label": {
43
- "text": params.month.label.text if numberOfFields > 1 else params.legendOrLabel,
44
- "description": params.month.label.description if numberOfFields > 1 else params.description,
45
- "id": params.id + "-month-label"
46
- },
47
- "name": params.month.name,
48
- "width": "2",
49
- "min": 1,
50
- "max": 12,
51
- "maxLength": 2,
52
- "attributes": params.month.attributes,
53
- "value": params.month.value,
54
- "classes": (" ons-input--error" if (params.error and params.month.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
55
- } %}
56
- {% set fields = (fields.push(monthField), fields) %}
57
- {% endif %}
58
- {% if params.year %}
59
- {% set yearField = {
60
- "id": params.id + "-year",
61
- "label": {
62
- "text": params.year.label.text if numberOfFields > 1 else params.legendOrLabel,
63
- "description": params.year.label.description if numberOfFields > 1 else params.description,
64
- "id": params.id + "-year-label"
65
- },
66
- "name": params.year.name,
67
- "width": "4",
68
- "min": 1000,
69
- "max": 3000,
70
- "maxLength": 4,
71
- "attributes": params.year.attributes,
72
- "value": params.year.value,
73
- "classes": (" ons-input--error" if (params.error and params.year.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default("")
74
- } %}
75
- {% set fields = (fields.push(yearField), fields) %}
76
- {% endif %}
20
+ {% set fields %}
21
+ {% if params.day %}
22
+ {{ onsInput({
23
+ "id": params.id + "-day",
24
+ "type": "number",
25
+ "name": params.day.name,
26
+ "classes": (" ons-input--error" if (params.error and params.day.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
27
+ "width": "2",
28
+ "min": 1,
29
+ "max": 31,
30
+ "maxLength": 2,
31
+ "attributes": params.day.attributes,
32
+ "label": {
33
+ "text": params.day.label.text if numberOfFields > 1 else params.legendOrLabel,
34
+ "description": params.day.label.description if numberOfFields > 1 else params.description,
35
+ "id": params.id + "-day-label"
36
+ },
37
+ "value": params.day.value,
38
+ "error": params.error if numberOfFields < 2
39
+ }) }}
40
+ {% endif %}
77
41
 
78
- {{ onsDateFieldInput({
42
+ {% if params.month %}
43
+ {{ onsInput({
44
+ "id": params.id + "-month",
45
+ "type": "number",
46
+ "name": params.month.name,
47
+ "classes": (" ons-input--error" if (params.error and params.month.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
48
+ "width": "2",
49
+ "min": 1,
50
+ "max": 12,
51
+ "maxLength": 2,
52
+ "attributes": params.month.attributes,
53
+ "label": {
54
+ "text": params.month.label.text if numberOfFields > 1 else params.legendOrLabel,
55
+ "description": params.month.label.description if numberOfFields > 1 else params.description,
56
+ "id": params.id + "-month-label"
57
+ },
58
+ "value": params.month.value,
59
+ "error": params.error if numberOfFields < 2
60
+ }) }}
61
+ {% endif %}
62
+
63
+ {% if params.year %}
64
+ {{ onsInput({
65
+ "id": params.id + "-year",
66
+ "type": "number",
67
+ "name": params.year.name,
68
+ "classes": (" ons-input--error" if (params.error and params.year.error) or (params.error and not params.day.error and not params.month.error and not params.year.error) else "") + exclusiveClass | default(""),
69
+ "width": "4",
70
+ "min": 1000,
71
+ "max": 3000,
72
+ "maxLength": 4,
73
+ "attributes": params.year.attributes,
74
+ "label": {
75
+ "text": params.year.label.text if numberOfFields > 1 else params.legendOrLabel,
76
+ "description": params.year.label.description if numberOfFields > 1 else params.description,
77
+ "id": params.id + "-year-label"
78
+ },
79
+ "value": params.year.value,
80
+ "error": params.error if numberOfFields < 2
81
+ }) }}
82
+ {% endif %}
83
+ {% endset %}
84
+
85
+ {{ onsMultipleInputFields({
79
86
  "id": params.id,
80
87
  "legendOrLabel": params.legendOrLabel,
81
88
  "description": params.description,
82
89
  "mutuallyExclusive": params.mutuallyExclusive,
83
- "fields": fields,
84
90
  "numberOfFields": numberOfFields,
91
+ "fields": fields,
85
92
  "error": params.error,
86
93
  "legend": params.legendOrLabel,
87
94
  "dontWrap": params.dontWrap,
88
- "legendClasses": params.legendClasses,
89
- "legendIsQuestionTitle": params.legendIsQuestionTitle,
90
95
  "classes": params.classes,
91
- "exclusiveOptions": params.mutuallyExclusive.exclusiveOptions,
92
- "or": params.mutuallyExclusive.or,
93
- "deselectMessage": params.mutuallyExclusive.deselectMessage,
94
- "deselectGroupAdjective": params.mutuallyExclusive.deselectGroupAdjective,
95
- "deselectExclusiveOptionAdjective": params.mutuallyExclusive.deselectExclusiveOptionAdjective
96
+ "legendClasses": params.legendClasses,
97
+ "legendIsQuestionTitle": params.legendIsQuestionTitle
96
98
  }) }}
97
99
  {% endmacro %}