@ons/design-system 65.1.0 → 65.2.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 (97) hide show
  1. package/README.md +1 -0
  2. package/components/access-code/access-code.scss +3 -3
  3. package/components/access-code/example-access-code-error.njk +1 -1
  4. package/components/access-code/example-access-code.njk +1 -1
  5. package/components/accordion/example-accordion-open.njk +10 -10
  6. package/components/accordion/example-accordion.njk +1 -1
  7. package/components/address-input/example-address-input-editable.njk +2 -2
  8. package/components/address-input/example-address-input-manual.njk +3 -3
  9. package/components/address-input/example-address-input.njk +2 -2
  10. package/components/autosuggest/_autosuggest.scss +3 -8
  11. package/components/autosuggest/_macro.njk +2 -3
  12. package/components/autosuggest/autosuggest.js +2 -1
  13. package/components/autosuggest/autosuggest.spec.js +89 -55
  14. package/components/autosuggest/autosuggest.ui.js +8 -12
  15. package/components/autosuggest/example-autosuggest-country-multiple.njk +4 -3
  16. package/components/autosuggest/example-autosuggest-country.njk +1 -1
  17. package/components/back-link/example-back-link.njk +1 -1
  18. package/components/button/_button.scss +11 -14
  19. package/components/card/example-card-set-with-images.njk +3 -3
  20. package/components/card/example-card-set-with-lists.njk +3 -3
  21. package/components/card/example-card-set.njk +3 -3
  22. package/components/card/example-card.njk +1 -1
  23. package/components/checkboxes/_checkbox.scss +1 -4
  24. package/components/checkboxes/example-checkboxes-disabled.njk +3 -3
  25. package/components/checkboxes/example-checkboxes-error.njk +7 -7
  26. package/components/checkboxes/example-checkboxes-with-descriptions.njk +7 -7
  27. package/components/checkboxes/example-checkboxes-with-hidden-label.njk +9 -9
  28. package/components/checkboxes/example-checkboxes-with-revealed-checkboxes-expanded.njk +8 -8
  29. package/components/checkboxes/example-checkboxes-with-revealed-checkboxes.njk +8 -8
  30. package/components/checkboxes/example-checkboxes-with-revealed-radios-expanded.njk +8 -8
  31. package/components/checkboxes/example-checkboxes-with-revealed-radios.njk +8 -8
  32. package/components/checkboxes/example-checkboxes-with-revealed-select-expanded.njk +4 -4
  33. package/components/checkboxes/example-checkboxes-with-revealed-select.njk +4 -4
  34. package/components/checkboxes/example-checkboxes-with-revealed-text-input-expanded.njk +6 -6
  35. package/components/checkboxes/example-checkboxes-with-revealed-text-input.njk +6 -6
  36. package/components/checkboxes/example-checkboxes-with-select-all-button.njk +4 -4
  37. package/components/checkboxes/example-checkboxes-with-visible-text-input.njk +6 -6
  38. package/components/checkboxes/example-checkboxes-without-border.njk +3 -3
  39. package/components/checkboxes/example-checkboxes.njk +4 -4
  40. package/components/date-input/example-date-input-error.njk +2 -2
  41. package/components/date-input/example-date-input.njk +1 -1
  42. package/components/details/example-details-with-warning.njk +1 -1
  43. package/components/details/example-details.njk +1 -1
  44. package/components/download-resources/_download-resources.scss +3 -5
  45. package/components/duration/example-duration-error.njk +6 -6
  46. package/components/duration/example-duration.njk +5 -5
  47. package/components/external-link/example-external-link.njk +1 -1
  48. package/components/header/example-header-external-with-service-links.njk +1 -1
  49. package/components/header/example-header-internal.njk +1 -1
  50. package/components/helpers/_grid.scss +6 -0
  51. package/components/helpers/grid.njk +19 -0
  52. package/components/input/_input-type.scss +2 -8
  53. package/components/input/_input.scss +4 -3
  54. package/components/input/example-input-email.njk +1 -1
  55. package/components/input/example-input-number.njk +1 -1
  56. package/components/input/example-input-numeric-values.njk +7 -7
  57. package/components/input/example-input-text-with-character-limit-checker.njk +1 -1
  58. package/components/input/example-input-text-with-description.njk +1 -1
  59. package/components/input/example-input-text.njk +1 -1
  60. package/components/modal/_modal.scss +3 -6
  61. package/components/mutually-exclusive/example-mutually-exclusive-checkboxes.njk +6 -6
  62. package/components/mutually-exclusive/example-mutually-exclusive-date-with-error.njk +2 -2
  63. package/components/mutually-exclusive/example-mutually-exclusive-email.njk +2 -2
  64. package/components/mutually-exclusive/example-mutually-exclusive-multiple-options.njk +5 -5
  65. package/components/navigation/navigation.js +6 -2
  66. package/components/phase-banner/example-phase-banner-alpha.njk +13 -2
  67. package/components/phase-banner/example-phase-banner-beta.njk +13 -2
  68. package/components/radios/example-radios-with-clear-button-expanded.njk +9 -9
  69. package/components/radios/example-radios-with-clear-button.njk +9 -9
  70. package/components/radios/example-radios-with-descriptions.njk +5 -5
  71. package/components/radios/example-radios-with-error.njk +4 -4
  72. package/components/radios/example-radios-with-revealed-checkboxes-expanded.njk +8 -8
  73. package/components/radios/example-radios-with-revealed-checkboxes.njk +8 -8
  74. package/components/radios/example-radios-with-revealed-radios-expanded.njk +9 -9
  75. package/components/radios/example-radios-with-revealed-radios.njk +8 -8
  76. package/components/radios/example-radios-with-revealed-select-expanded.njk +5 -5
  77. package/components/radios/example-radios-with-revealed-select.njk +4 -4
  78. package/components/radios/example-radios-with-revealed-text-input-expanded.njk +9 -9
  79. package/components/radios/example-radios-with-revealed-text-input.njk +9 -9
  80. package/components/radios/example-radios-with-visible-text-input.njk +3 -3
  81. package/components/relationships/example-relationships-error.njk +13 -13
  82. package/components/relationships/example-relationships-you.njk +13 -13
  83. package/components/relationships/example-relationships.njk +13 -13
  84. package/components/select/example-select-with-error.njk +1 -1
  85. package/components/select/example-select-with-inline-label.njk +1 -1
  86. package/components/select/example-select.njk +1 -1
  87. package/components/table/_table.scss +7 -3
  88. package/components/textarea/example-textarea-error.njk +1 -1
  89. package/components/upload/example-upload-error.njk +1 -1
  90. package/components/upload/example-upload.njk +1 -1
  91. package/css/main.css +3 -3
  92. package/package.json +8 -10
  93. package/scripts/main.es5.js +1 -1
  94. package/scripts/main.js +1 -1
  95. package/scss/base/_global.scss +3 -2
  96. package/scss/main.scss +1 -0
  97. package/scss/overrides/hcm.scss +10 -10
@@ -25,6 +25,31 @@ const EXAMPLE_AUTOSUGGEST = {
25
25
  typeMore: 'Continue entering to get suggestions',
26
26
  autosuggestData: '/test/fake/api/countries',
27
27
  };
28
+ const EXAMPLE_AUTOSUGGEST_WITH_LANGUAGE = {
29
+ id: 'country-of-birth',
30
+ label: {
31
+ text: 'Current name of country',
32
+ description: 'Enter your own answer or select from suggestions',
33
+ id: 'country-of-birth-label',
34
+ classes: 'extra-label-class',
35
+ },
36
+ autocomplete: 'off',
37
+ instructions: 'Use up and down keys to navigate.',
38
+ ariaYouHaveSelected: 'You have selected',
39
+ ariaMinChars: 'Enter 3 or more characters for suggestions.',
40
+ minChars: 3,
41
+ ariaResultsLabel: 'Country suggestions',
42
+ ariaOneResult: 'There is one suggestion available.',
43
+ ariaNResults: 'There are {n} suggestions available.',
44
+ ariaLimitedResults: 'Type more characters to improve your search',
45
+ moreResults: 'Continue entering to improve suggestions',
46
+ resultsTitle: 'Suggestions',
47
+ resultsTitleId: 'country-of-birth-suggestions',
48
+ noResults: 'No suggestions found.',
49
+ typeMore: 'Continue entering to get suggestions',
50
+ autosuggestData: '/test/fake/api/countries',
51
+ language: 'en-gb',
52
+ };
28
53
 
29
54
  describe('script: autosuggest', () => {
30
55
  const apiFaker = new PuppeteerEndpointFaker('/test/fake/api');
@@ -72,11 +97,11 @@ describe('script: autosuggest', () => {
72
97
  it('the instructions, listbox, and status should become visible', async () => {
73
98
  await setTestPage('/test', renderComponent('autosuggest', EXAMPLE_AUTOSUGGEST));
74
99
 
75
- const instructionsDisplayStyle = await page.$eval('.ons-js-autosuggest-instructions', node => getComputedStyle(node).display);
100
+ const instructionsDisplayStyle = await page.$eval('.ons-js-autosuggest-instructions', (node) => getComputedStyle(node).display);
76
101
  expect(instructionsDisplayStyle).toBe('block');
77
- const listboxDisplayStyle = await page.$eval('.ons-js-autosuggest-listbox', node => getComputedStyle(node).display);
102
+ const listboxDisplayStyle = await page.$eval('.ons-js-autosuggest-listbox', (node) => getComputedStyle(node).display);
78
103
  expect(listboxDisplayStyle).toBe('block');
79
- const statusDisplayStyle = await page.$eval('.ons-js-autosuggest-aria-status', node => getComputedStyle(node).display);
104
+ const statusDisplayStyle = await page.$eval('.ons-js-autosuggest-aria-status', (node) => getComputedStyle(node).display);
80
105
  expect(statusDisplayStyle).toBe('block');
81
106
  });
82
107
  });
@@ -88,7 +113,7 @@ describe('script: autosuggest', () => {
88
113
  await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
89
114
  await page.keyboard.press('ArrowDown');
90
115
 
91
- const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
116
+ const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
92
117
  expect(selectedOption.trim()).toBe('United States of America');
93
118
  });
94
119
 
@@ -99,7 +124,7 @@ describe('script: autosuggest', () => {
99
124
  await page.keyboard.press('ArrowDown');
100
125
  await page.keyboard.press('ArrowDown');
101
126
 
102
- const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
127
+ const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
103
128
  expect(selectedOption.trim()).toBe('United States Virgin Islands');
104
129
  });
105
130
 
@@ -110,11 +135,11 @@ describe('script: autosuggest', () => {
110
135
  await page.keyboard.press('ArrowDown');
111
136
  await page.keyboard.press('ArrowDown');
112
137
 
113
- const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('aria-selected'));
138
+ const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('aria-selected'));
114
139
  expect(ariaSelectedValue).toBe('true');
115
140
 
116
- const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('id'));
117
- const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-activedescendant'));
141
+ const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('id'));
142
+ const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-activedescendant'));
118
143
  expect(ariaActiveDescendant).toBe(selectedOptionId);
119
144
  });
120
145
 
@@ -124,7 +149,7 @@ describe('script: autosuggest', () => {
124
149
  await page.type('.ons-js-autosuggest-input', 'Eng', { delay: 20 });
125
150
  await page.keyboard.press('ArrowDown');
126
151
 
127
- const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
152
+ const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
128
153
  expect(statusMessage.trim()).toBe('England');
129
154
  });
130
155
 
@@ -135,7 +160,7 @@ describe('script: autosuggest', () => {
135
160
  await page.keyboard.press('ArrowDown');
136
161
  await page.keyboard.press('ArrowDown');
137
162
 
138
- const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', nodes => nodes.length);
163
+ const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', (nodes) => nodes.length);
139
164
  expect(selectedSuggestionCount).toBe(1);
140
165
  });
141
166
 
@@ -147,7 +172,7 @@ describe('script: autosuggest', () => {
147
172
  await page.keyboard.press('ArrowDown');
148
173
  await page.keyboard.press('ArrowDown');
149
174
 
150
- const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
175
+ const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
151
176
  expect(selectedOption.trim()).toBe('United States Virgin Islands');
152
177
  });
153
178
 
@@ -162,7 +187,7 @@ describe('script: autosuggest', () => {
162
187
  await page.keyboard.press('ArrowDown');
163
188
  await page.keyboard.press('U');
164
189
 
165
- const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
190
+ const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
166
191
  expect(inputValue).toBe('United');
167
192
  });
168
193
  });
@@ -174,7 +199,7 @@ describe('script: autosuggest', () => {
174
199
  await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
175
200
  await page.keyboard.press('ArrowUp');
176
201
 
177
- const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
202
+ const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
178
203
  expect(selectedOption.trim()).toBe('United States of America');
179
204
  });
180
205
 
@@ -186,7 +211,7 @@ describe('script: autosuggest', () => {
186
211
  await page.keyboard.press('ArrowDown');
187
212
  await page.keyboard.press('ArrowUp');
188
213
 
189
- const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
214
+ const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
190
215
  expect(selectedOption.trim()).toBe('United States of America');
191
216
  });
192
217
 
@@ -198,11 +223,11 @@ describe('script: autosuggest', () => {
198
223
  await page.keyboard.press('ArrowDown');
199
224
  await page.keyboard.press('ArrowUp');
200
225
 
201
- const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('aria-selected'));
226
+ const ariaSelectedValue = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('aria-selected'));
202
227
  expect(ariaSelectedValue).toBe('true');
203
228
 
204
- const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', node => node.getAttribute('id'));
205
- const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-activedescendant'));
229
+ const selectedOptionId = await page.$eval('.ons-autosuggest__option--focused', (node) => node.getAttribute('id'));
230
+ const ariaActiveDescendant = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-activedescendant'));
206
231
  expect(ariaActiveDescendant).toBe(selectedOptionId);
207
232
  });
208
233
 
@@ -214,7 +239,7 @@ describe('script: autosuggest', () => {
214
239
  await page.keyboard.press('ArrowDown');
215
240
  await page.keyboard.press('ArrowUp');
216
241
 
217
- const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', nodes => nodes.length);
242
+ const selectedSuggestionCount = await page.$$eval('.ons-autosuggest__option[aria-selected=true]', (nodes) => nodes.length);
218
243
  expect(selectedSuggestionCount).toBe(1);
219
244
  });
220
245
 
@@ -225,7 +250,7 @@ describe('script: autosuggest', () => {
225
250
  await page.keyboard.press('ArrowUp');
226
251
  await page.keyboard.press('ArrowUp');
227
252
 
228
- const selectedOption = await page.$eval('.ons-autosuggest__option--focused', node => node.textContent);
253
+ const selectedOption = await page.$eval('.ons-autosuggest__option--focused', (node) => node.textContent);
229
254
  expect(selectedOption.trim()).toBe('United States of America');
230
255
  });
231
256
 
@@ -238,7 +263,7 @@ describe('script: autosuggest', () => {
238
263
  await page.keyboard.press('ArrowUp');
239
264
  await page.keyboard.press('d');
240
265
 
241
- const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
266
+ const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
242
267
  expect(inputValue).toBe('United');
243
268
  });
244
269
  });
@@ -252,7 +277,7 @@ describe('script: autosuggest', () => {
252
277
  await page.keyboard.press('ArrowDown');
253
278
  await page.keyboard.press('Enter');
254
279
 
255
- const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
280
+ const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
256
281
  expect(inputValue).toBe('United States Virgin Islands');
257
282
  });
258
283
  });
@@ -264,15 +289,15 @@ describe('script: autosuggest', () => {
264
289
  await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
265
290
  await page.keyboard.press('Tab');
266
291
 
267
- const suggestionCountSample1 = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
292
+ const suggestionCountSample1 = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
268
293
  expect(suggestionCountSample1).toBe(2);
269
294
 
270
295
  await page.waitForTimeout(200);
271
- const suggestionCountSample2 = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
296
+ const suggestionCountSample2 = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
272
297
  expect(suggestionCountSample2).toBe(2);
273
298
 
274
299
  await page.waitForTimeout(320);
275
- const suggestionCountSample3 = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
300
+ const suggestionCountSample3 = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
276
301
  expect(suggestionCountSample3).toBe(0);
277
302
  });
278
303
 
@@ -283,7 +308,7 @@ describe('script: autosuggest', () => {
283
308
  await page.keyboard.press('Tab');
284
309
  await page.waitForTimeout(320);
285
310
 
286
- const listboxInnerHTML = await page.$eval('.ons-js-autosuggest-listbox', node => node.innerHTML);
311
+ const listboxInnerHTML = await page.$eval('.ons-js-autosuggest-listbox', (node) => node.innerHTML);
287
312
  expect(listboxInnerHTML).toBe('');
288
313
  });
289
314
 
@@ -294,7 +319,7 @@ describe('script: autosuggest', () => {
294
319
  await page.keyboard.press('Tab');
295
320
  await page.waitForTimeout(320);
296
321
 
297
- const hasClass = await page.$eval('.ons-autosuggest', node => node.classList.contains('ons-autosuggest--has-results'));
322
+ const hasClass = await page.$eval('.ons-autosuggest', (node) => node.classList.contains('ons-autosuggest--has-results'));
298
323
  expect(hasClass).toBe(false);
299
324
  });
300
325
 
@@ -318,7 +343,7 @@ describe('script: autosuggest', () => {
318
343
  await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
319
344
  await page.click('.ons-autosuggest__option:nth-child(2)');
320
345
 
321
- const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
346
+ const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
322
347
  expect(inputValue).toBe('United States Virgin Islands');
323
348
  });
324
349
  });
@@ -329,7 +354,7 @@ describe('script: autosuggest', () => {
329
354
 
330
355
  await page.type('.ons-js-autosuggest-input', 'En', { delay: 20 });
331
356
 
332
- const suggestionCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
357
+ const suggestionCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
333
358
  expect(suggestionCount).toBe(0);
334
359
  });
335
360
 
@@ -338,9 +363,18 @@ describe('script: autosuggest', () => {
338
363
 
339
364
  await page.type('.ons-js-autosuggest-input', 'Eng', { delay: 20 });
340
365
 
341
- const suggestionCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
366
+ const suggestionCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
342
367
  expect(suggestionCount).toBe(1);
343
368
  });
369
+
370
+ it('gets the language if set', async () => {
371
+ await setTestPage('/test', renderComponent('autosuggest', EXAMPLE_AUTOSUGGEST_WITH_LANGUAGE));
372
+
373
+ await page.type('.ons-js-autosuggest-input', 'Eng', { delay: 20 });
374
+
375
+ const attributes = await getNodeAttributes(page, '.ons-js-autosuggest');
376
+ expect(attributes['data-lang']).toBe('en-gb');
377
+ });
344
378
  });
345
379
 
346
380
  describe('when the mouse moves over a result and a suggestion is focused', () => {
@@ -351,7 +385,7 @@ describe('script: autosuggest', () => {
351
385
  await page.keyboard.press('ArrowDown');
352
386
  await page.hover('.ons-autosuggest__option:nth-child(2)');
353
387
 
354
- const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', nodes => nodes.length);
388
+ const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', (nodes) => nodes.length);
355
389
  expect(focusedClassCount).toBe(0);
356
390
  });
357
391
  });
@@ -371,7 +405,7 @@ describe('script: autosuggest', () => {
371
405
  await page.hover('.ons-autosuggest__option:nth-child(2)');
372
406
  await page.hover('#dummy');
373
407
 
374
- const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', nodes => nodes.length);
408
+ const focusedClassCount = await page.$$eval('.ons-autosuggest__option--focused', (nodes) => nodes.length);
375
409
  expect(focusedClassCount).toBe(1);
376
410
  });
377
411
  });
@@ -384,7 +418,7 @@ describe('script: autosuggest', () => {
384
418
  await page.keyboard.press('ArrowDown');
385
419
  await page.type('.ons-js-autosuggest-input', 'd', { delay: 20 });
386
420
 
387
- const focusedNodeCount = await page.$$eval('.ons-autosuggest__option--focused', nodes => nodes.length);
421
+ const focusedNodeCount = await page.$$eval('.ons-autosuggest__option--focused', (nodes) => nodes.length);
388
422
  expect(focusedNodeCount).toBe(0);
389
423
  });
390
424
 
@@ -393,7 +427,7 @@ describe('script: autosuggest', () => {
393
427
 
394
428
  await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
395
429
 
396
- const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-expanded'));
430
+ const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-expanded'));
397
431
  expect(ariaExpandedValue).toBe('true');
398
432
  });
399
433
 
@@ -402,7 +436,7 @@ describe('script: autosuggest', () => {
402
436
 
403
437
  await page.type('.ons-js-autosuggest-input', 'Unite', { delay: 20 });
404
438
 
405
- const emboldened = await page.$$eval('.ons-autosuggest__option strong', nodes => nodes.map(node => node.textContent));
439
+ const emboldened = await page.$$eval('.ons-autosuggest__option strong', (nodes) => nodes.map((node) => node.textContent));
406
440
  expect(emboldened).toEqual(['Unite', 'Unite']);
407
441
  });
408
442
 
@@ -411,9 +445,9 @@ describe('script: autosuggest', () => {
411
445
 
412
446
  await page.type('.ons-js-autosuggest-input', 'tland', { delay: 20 });
413
447
 
414
- const matchCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
448
+ const matchCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
415
449
  expect(matchCount).toBe(2);
416
- const emboldened = await page.$$eval('.ons-autosuggest__option strong', nodes => nodes.map(node => node.textContent));
450
+ const emboldened = await page.$$eval('.ons-autosuggest__option strong', (nodes) => nodes.map((node) => node.textContent));
417
451
  expect(emboldened).toEqual(['tland']);
418
452
  });
419
453
 
@@ -422,7 +456,7 @@ describe('script: autosuggest', () => {
422
456
 
423
457
  await page.type('.ons-js-autosuggest-input', 'st', { delay: 20 });
424
458
 
425
- const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
459
+ const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
426
460
  expect(statusMessage.trim()).toBe('Enter 3 or more characters for suggestions.');
427
461
  });
428
462
 
@@ -431,7 +465,7 @@ describe('script: autosuggest', () => {
431
465
 
432
466
  await page.type('.ons-js-autosuggest-input', 'Engla', { delay: 20 });
433
467
 
434
- const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
468
+ const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
435
469
  expect(statusMessage.trim()).toBe('There is one suggestion available.');
436
470
  });
437
471
 
@@ -440,7 +474,7 @@ describe('script: autosuggest', () => {
440
474
 
441
475
  await page.type('.ons-js-autosuggest-input', 'sta', { delay: 20 });
442
476
 
443
- const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
477
+ const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
444
478
  expect(statusMessage.trim()).toBe('There are 2 suggestions available.');
445
479
  });
446
480
  });
@@ -452,7 +486,7 @@ describe('script: autosuggest', () => {
452
486
 
453
487
  await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
454
488
 
455
- const noResultsContent = await page.$eval('.ons-autosuggest__option--no-results', node => node.textContent);
489
+ const noResultsContent = await page.$eval('.ons-autosuggest__option--no-results', (node) => node.textContent);
456
490
  expect(noResultsContent).toBe('No suggestions found.');
457
491
  });
458
492
 
@@ -461,7 +495,7 @@ describe('script: autosuggest', () => {
461
495
 
462
496
  await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
463
497
 
464
- const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-expanded'));
498
+ const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-expanded'));
465
499
  expect(ariaExpandedValue).toBe('true');
466
500
  });
467
501
 
@@ -470,7 +504,7 @@ describe('script: autosuggest', () => {
470
504
 
471
505
  await page.type('.ons-js-autosuggest-input', 'ab', { delay: 20 });
472
506
 
473
- const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
507
+ const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
474
508
  expect(statusMessage.trim()).toBe('Enter 3 or more characters for suggestions.');
475
509
  });
476
510
 
@@ -479,7 +513,7 @@ describe('script: autosuggest', () => {
479
513
 
480
514
  await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
481
515
 
482
- const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
516
+ const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
483
517
  expect(statusMessage.trim()).toBe('No suggestions found.: "abc"');
484
518
  });
485
519
  });
@@ -496,7 +530,7 @@ describe('script: autosuggest', () => {
496
530
 
497
531
  await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
498
532
 
499
- const matchCount = await page.$$eval('.ons-autosuggest__option', nodes => nodes.length);
533
+ const matchCount = await page.$$eval('.ons-autosuggest__option', (nodes) => nodes.length);
500
534
  expect(matchCount).toBe(0);
501
535
  });
502
536
 
@@ -511,7 +545,7 @@ describe('script: autosuggest', () => {
511
545
 
512
546
  await page.type('.ons-js-autosuggest-input', 'abc', { delay: 20 });
513
547
 
514
- const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', node => node.getAttribute('aria-expanded'));
548
+ const ariaExpandedValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.getAttribute('aria-expanded'));
515
549
  expect(ariaExpandedValue).toBe('false');
516
550
  });
517
551
  });
@@ -532,9 +566,9 @@ describe('script: autosuggest', () => {
532
566
  });
533
567
 
534
568
  it('shows the type more message', async () => {
535
- const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', nodes => nodes.length);
569
+ const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', (nodes) => nodes.length);
536
570
  expect(listItemCount).toBe(1);
537
- const noResultsText = await page.$eval('.ons-autosuggest__option--no-results', node => node.innerText);
571
+ const noResultsText = await page.$eval('.ons-autosuggest__option--no-results', (node) => node.innerText);
538
572
  expect(noResultsText.trim()).toBe('Continue entering to get suggestions');
539
573
  });
540
574
  });
@@ -563,29 +597,29 @@ describe('script: autosuggest', () => {
563
597
  });
564
598
 
565
599
  it('shows the API error message', async () => {
566
- const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', nodes => nodes.length);
600
+ const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', (nodes) => nodes.length);
567
601
  expect(listItemCount).toBe(1);
568
- const warningText = await page.$eval('.ons-autosuggest__warning', node => node.textContent);
602
+ const warningText = await page.$eval('.ons-autosuggest__warning', (node) => node.textContent);
569
603
  expect(warningText.trim()).toBe('!Sorry, there is a problem.');
570
604
  });
571
605
 
572
606
  it('the input should be disabled', async () => {
573
- const hasDisabledAttribute = await page.$eval('.ons-js-autosuggest-input', node => node.hasAttribute('disabled'));
607
+ const hasDisabledAttribute = await page.$eval('.ons-js-autosuggest-input', (node) => node.hasAttribute('disabled'));
574
608
  expect(hasDisabledAttribute).toBe(true);
575
609
  });
576
610
 
577
611
  it('the input value should be empty', async () => {
578
- const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
612
+ const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
579
613
  expect(inputValue).toBe('');
580
614
  });
581
615
 
582
616
  it('the label class should be added', async () => {
583
- const hasClass = await page.$eval('.ons-label', node => node.classList.contains('ons-u-lighter'));
617
+ const hasClass = await page.$eval('.ons-label', (node) => node.classList.contains('ons-u-lighter'));
584
618
  expect(hasClass).toBe(true);
585
619
  });
586
620
 
587
621
  it('the aria status should be set', async () => {
588
- const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', node => node.textContent);
622
+ const statusMessage = await page.$eval('.ons-js-autosuggest-aria-status', (node) => node.textContent);
589
623
  expect(statusMessage.trim()).toBe('Sorry, there is a problem.');
590
624
  });
591
625
  });
@@ -609,7 +643,7 @@ describe('script: autosuggest', () => {
609
643
  await page.keyboard.press('Tab');
610
644
  await page.focus('.ons-js-autosuggest-input');
611
645
 
612
- const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
646
+ const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
613
647
  expect(inputValue).toBe('England, ');
614
648
  });
615
649
  });
@@ -627,7 +661,7 @@ describe('script: autosuggest', () => {
627
661
  await page.type('.ons-js-autosuggest-input', 'England, ', { delay: 20 });
628
662
  await page.keyboard.press('Tab');
629
663
 
630
- const inputValue = await page.$eval('.ons-js-autosuggest-input', node => node.value);
664
+ const inputValue = await page.$eval('.ons-js-autosuggest-input', (node) => node.value);
631
665
  expect(inputValue).toBe('England');
632
666
  });
633
667
  });
@@ -64,6 +64,7 @@ export default class AutosuggestUI {
64
64
  this.errorAPI = errorAPI || context.getAttribute('data-error-api');
65
65
  this.errorAPILinkText = errorAPILinkText || context.getAttribute('data-error-api-link-text');
66
66
  this.typeMore = typeMore || context.getAttribute('data-type-more');
67
+ this.language = context.getAttribute('data-lang');
67
68
  this.allowMultiple = context.getAttribute('data-allow-multiple') || false;
68
69
  this.listboxId = this.listbox.getAttribute('id');
69
70
  this.resultLimit = resultLimit || 10;
@@ -104,7 +105,7 @@ export default class AutosuggestUI {
104
105
  }
105
106
 
106
107
  get lang() {
107
- return document.documentElement.getAttribute('lang').toLowerCase();
108
+ return !this.language ? document.documentElement.getAttribute('lang').toLowerCase() : this.language.toLowerCase();
108
109
  }
109
110
 
110
111
  initialiseUI() {
@@ -261,7 +262,7 @@ export default class AutosuggestUI {
261
262
  getSuggestions(force, groupResults) {
262
263
  if (!this.settingResult) {
263
264
  if (this.allowMultiple === 'true' && this.allSelections.length) {
264
- const newQuery = this.input.value.split(', ').find(item => !this.allSelections.includes(item));
265
+ const newQuery = this.input.value.split(', ').find((item) => !this.allSelections.includes(item));
265
266
  this.query = newQuery ? newQuery : this.input.value;
266
267
  } else {
267
268
  this.query = this.input.value;
@@ -276,7 +277,7 @@ export default class AutosuggestUI {
276
277
  if (this.sanitisedQuery.length >= this.minChars) {
277
278
  this.fetchSuggestions(this.sanitisedQuery, this.data, groupResults)
278
279
  .then(this.handleResults.bind(this))
279
- .catch(error => {
280
+ .catch((error) => {
280
281
  if (error.name !== 'AbortError') {
281
282
  console.log('error:', error);
282
283
  this.handleNoResults(500);
@@ -292,7 +293,7 @@ export default class AutosuggestUI {
292
293
  async fetchSuggestions(sanitisedQuery, data) {
293
294
  this.abortFetch();
294
295
  const results = await runFuse(sanitisedQuery, data, this.lang, this.resultLimit);
295
- results.forEach(result => {
296
+ results.forEach((result) => {
296
297
  result.sanitisedText = sanitiseAutosuggestText(result[this.lang], this.sanitisedQueryReplaceChars);
297
298
  });
298
299
  return {
@@ -520,14 +521,14 @@ export default class AutosuggestUI {
520
521
  }
521
522
 
522
523
  storeExistingSelections(value) {
523
- this.currentSelections = this.input.value.split(', ').filter(items => this.allSelections.includes(items));
524
+ this.currentSelections = this.input.value.split(', ').filter((items) => this.allSelections.includes(items));
524
525
  this.allSelections = [];
525
526
  if (this.currentSelections.length) {
526
527
  this.allSelections = this.currentSelections;
527
528
  }
528
529
  this.allSelections.push(value);
529
530
 
530
- this.allSelections = this.allSelections.filter(function(value, index, array) {
531
+ this.allSelections = this.allSelections.filter(function (value, index, array) {
531
532
  return array.indexOf(value) == index;
532
533
  });
533
534
 
@@ -535,12 +536,7 @@ export default class AutosuggestUI {
535
536
  }
536
537
 
537
538
  emboldenMatch(string, query) {
538
- let reg = new RegExp(
539
- this.escapeRegExp(query)
540
- .split(' ')
541
- .join('[\\s,]*'),
542
- 'gi',
543
- );
539
+ let reg = new RegExp(this.escapeRegExp(query).split(' ').join('[\\s,]*'), 'gi');
544
540
 
545
541
  return string.replace(reg, '<strong>$&</strong>');
546
542
  }
@@ -4,10 +4,10 @@
4
4
  <div class="ons-grid__col ons-col-8@m">
5
5
 
6
6
  {{ onsAutosuggest({
7
- "id": "country-of-birth",
7
+ "id": "country-of-birth-autosuggest-multiple",
8
8
  "label": {
9
9
  "text": "Passport",
10
- "id": "country-of-birth-label",
10
+ "id": "country-of-birth-label-multiple",
11
11
  "description": "Enter your own answer or select from suggestions. You can enter multiple countries if you have a passport for more than one."
12
12
  },
13
13
  "autocomplete": "off",
@@ -23,7 +23,8 @@
23
23
  "allowMultiple": true,
24
24
  "autosuggestData": "/examples/data/country-of-birth.json",
25
25
  "noResults": "No suggestions found. You can enter your own answer",
26
- "typeMore": "Continue entering to get suggestions"
26
+ "typeMore": "Continue entering to get suggestions",
27
+ "language": "en"
27
28
  }) }}
28
29
 
29
30
  </div>
@@ -4,7 +4,7 @@
4
4
  <div class="ons-grid__col ons-col-8@m">
5
5
 
6
6
  {{ onsAutosuggest({
7
- "id": "country-of-birth",
7
+ "id": "country-of-birth-autosuggest",
8
8
  "label": {
9
9
  "text": "Current name of country",
10
10
  "description": "Enter your own answer or select from suggestions",
@@ -6,7 +6,7 @@
6
6
  "itemsList": [
7
7
  {
8
8
  "url": '/',
9
- "id": "back",
9
+ "id": "backlink",
10
10
  "text": 'Back',
11
11
  "attributes": {
12
12
  "data-attribute": "Example attribute"
@@ -15,19 +15,16 @@ $button-shadow-size: 3px;
15
15
  position: relative;
16
16
  text-align: center;
17
17
  text-decoration: none;
18
- text-rendering: optimizeLegibility;
18
+ text-rendering: optimizelegibility;
19
19
  vertical-align: top;
20
20
  white-space: nowrap;
21
21
 
22
22
  // Transparent border for IE11 High Contrast mode support due to 'border: 0' on buttons
23
23
  &::after {
24
24
  border: ems($button-shadow-size) solid transparent;
25
- bottom: -(ems($button-shadow-size)); // makes sure button shadow is selectable
25
+ inset: 0 0 - (ems($button-shadow-size)) 0; // makes sure button shadow is selectable
26
26
  content: '';
27
- left: 0;
28
27
  position: absolute;
29
- right: 0;
30
- top: 0;
31
28
  }
32
29
 
33
30
  &--search {
@@ -172,8 +169,8 @@ $button-shadow-size: 3px;
172
169
  text-decoration: none;
173
170
  }
174
171
 
175
- &--link:focus:not(:active):not(&--secondary) &,
176
- &--link:focus:hover:not(:active):not(&--secondary) & {
172
+ &--link:focus:not(:active, &--secondary) &,
173
+ &--link:focus:hover:not(:active, &--secondary) & {
177
174
  outline: inherit;
178
175
 
179
176
  &__inner {
@@ -245,7 +242,8 @@ $button-shadow-size: 3px;
245
242
  &--text-link:active:focus & {
246
243
  &__inner {
247
244
  background-color: var(--ons-color-focus);
248
- box-shadow: 0 -2px var(--ons-color-focus), 0 4px var(--ons-color-text-link-focus) !important;
245
+ box-shadow: 0 -2px var(--ons-color-focus),
246
+ 0 4px var(--ons-color-text-link-focus) !important;
249
247
  color: var(--ons-color-text-link-focus);
250
248
  .ons-icon {
251
249
  fill: var(--ons-color-text-link-focus);
@@ -256,7 +254,7 @@ $button-shadow-size: 3px;
256
254
  &--ghost & {
257
255
  &__inner {
258
256
  background: transparent;
259
- border: 2px solid rgba(255, 255, 255, 0.6);
257
+ border: 2px solid rgb(255 255 255 / 60%);
260
258
  box-shadow: none;
261
259
  color: var(--ons-color-text-inverse);
262
260
  .ons-icon {
@@ -314,7 +312,7 @@ $button-shadow-size: 3px;
314
312
 
315
313
  &--ghost:hover & {
316
314
  &__inner {
317
- background: rgba(0, 0, 0, 0.1);
315
+ background: rgb(0 0 0 / 10%);
318
316
  border-color: var(--ons-color-white);
319
317
  }
320
318
  }
@@ -323,8 +321,8 @@ $button-shadow-size: 3px;
323
321
  &--ghost:active:focus &,
324
322
  &--ghost.active & {
325
323
  &__inner {
326
- background: rgba(0, 0, 0, 0.2);
327
- border-color: rgba(255, 255, 255, 0.6);
324
+ background: rgb(0 0 0 / 20%);
325
+ border-color: rgb(255 255 255 / 60%);
328
326
  color: var(--ons-color-text-inverse);
329
327
  .ons-icon {
330
328
  fill: var(--ons-color-text-inverse);
@@ -514,8 +512,7 @@ $button-shadow-size: 3px;
514
512
 
515
513
  align-items: baseline;
516
514
  display: flex;
517
- flex-direction: row;
518
- flex-wrap: wrap;
515
+ flex-flow: row wrap;
519
516
 
520
517
  & .ons-btn,
521
518
  & a {