@ons/design-system 73.10.0 → 73.12.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.
- package/components/address-input/autosuggest.address.spec.js +23 -0
- package/components/autosuggest/autosuggest.ui.js +3 -0
- package/components/header/_macro.njk +1 -1
- package/components/header/_macro.spec.js +21 -0
- package/package.json +14 -11
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -411,6 +411,29 @@ describe('script: address-input', () => {
|
|
|
411
411
|
});
|
|
412
412
|
});
|
|
413
413
|
});
|
|
414
|
+
|
|
415
|
+
describe('when a grouped suggestion is selected with the mouse', () => {
|
|
416
|
+
beforeEach(async () => {
|
|
417
|
+
const options = await page.$$('.ons-autosuggest__option');
|
|
418
|
+
await options[0].click();
|
|
419
|
+
await setTimeout(400);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('makes expected bucket request', async () => {
|
|
423
|
+
expect(
|
|
424
|
+
await apiFaker.getRequestCount(
|
|
425
|
+
'/addresses/eq/bucket?postcode=CF14%202AA&streetname=Penlline%20Road&townname=Whitchurch&groupfullpostcodes=combo',
|
|
426
|
+
),
|
|
427
|
+
).toBe(1);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it('keeps nested suggestion entries after blur timeout', async () => {
|
|
431
|
+
const suggestions = await page.$$eval('.ons-autosuggest__option', (nodes) =>
|
|
432
|
+
nodes.map((node) => node.textContent.trim()),
|
|
433
|
+
);
|
|
434
|
+
expect(suggestions).toEqual(['197 College Road, Whitchurch, Cardiff, CF14 2AB']);
|
|
435
|
+
});
|
|
436
|
+
});
|
|
414
437
|
});
|
|
415
438
|
|
|
416
439
|
describe('when there is an error retrieving the address', () => {
|
|
@@ -201,6 +201,8 @@ export default class AutosuggestUI {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
handleFocus() {
|
|
204
|
+
this.blurring = false;
|
|
205
|
+
|
|
204
206
|
if (this.allowMultiple === 'true' && this.allSelections.length && this.input.value.slice(-1) !== ' ' && this.input.value !== '') {
|
|
205
207
|
this.input.value = `${this.input.value}, `;
|
|
206
208
|
}
|
|
@@ -513,6 +515,7 @@ export default class AutosuggestUI {
|
|
|
513
515
|
|
|
514
516
|
selectResult(index) {
|
|
515
517
|
if (this.results.length) {
|
|
518
|
+
clearTimeout(this.blurTimeout);
|
|
516
519
|
this.settingResult = true;
|
|
517
520
|
const result = this.results[index || this.highlightedResultIndex || 0];
|
|
518
521
|
const resultItem = result.item ?? result;
|
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
"name": params.search.form.inputName | default('q'),
|
|
369
369
|
"width": 'full',
|
|
370
370
|
"label": {
|
|
371
|
-
"text": (params.search.form.inputLabel if params.search.form else params.searchLinks.searchNavigationInputLabel) | default('Chwilio’r SYG' if
|
|
371
|
+
"text": (params.search.form.inputLabel if params.search.form else params.searchLinks.searchNavigationInputLabel) | default('Chwilio’r SYG' if currentLanguageIsoCode == 'cy' else 'Search the ONS'),
|
|
372
372
|
"id": "header-search-input-label"
|
|
373
373
|
},
|
|
374
374
|
"searchButton": {
|
|
@@ -1104,6 +1104,27 @@ describe('FOR: Macro: Header', () => {
|
|
|
1104
1104
|
expect($('#header-search-input-label').text().trim()).toBe('Search the ONS');
|
|
1105
1105
|
});
|
|
1106
1106
|
});
|
|
1107
|
+
describe('WHEN: inputLabel is not provided and Welsh is the current language', () => {
|
|
1108
|
+
const $ = cheerio.load(
|
|
1109
|
+
renderComponent('header', {
|
|
1110
|
+
...EXAMPLE_HEADER_SEARCH,
|
|
1111
|
+
variants: 'basic',
|
|
1112
|
+
language: {
|
|
1113
|
+
languages: [
|
|
1114
|
+
{ url: '#0', isoCode: 'en', text: 'English', current: false },
|
|
1115
|
+
{ url: '#0', isoCode: 'cy', text: 'Cymraeg', current: true },
|
|
1116
|
+
],
|
|
1117
|
+
},
|
|
1118
|
+
search: {
|
|
1119
|
+
...EXAMPLE_HEADER_SEARCH.search,
|
|
1120
|
+
form: { ...EXAMPLE_HEADER_SEARCH.search.form, inputLabel: undefined },
|
|
1121
|
+
},
|
|
1122
|
+
}),
|
|
1123
|
+
);
|
|
1124
|
+
test('THEN: renders search input with Welsh default label', () => {
|
|
1125
|
+
expect($('#header-search-input-label').text().trim()).toBe('Chwilio’r SYG');
|
|
1126
|
+
});
|
|
1127
|
+
});
|
|
1107
1128
|
describe('WHEN: buttonText is provided', () => {
|
|
1108
1129
|
const $ = cheerio.load(renderComponent('header', { ...EXAMPLE_HEADER_SEARCH, variants: 'basic' }));
|
|
1109
1130
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ons/design-system",
|
|
3
3
|
"description": "ONS Design System built CSS, JS, and Nunjucks templates",
|
|
4
|
-
"version": "73.
|
|
4
|
+
"version": "73.12.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "ONS Digital"
|
|
9
9
|
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/ONSdigital/design-system"
|
|
13
|
+
},
|
|
10
14
|
"scripts": {
|
|
11
15
|
"start": "gulp start",
|
|
12
16
|
"watch": "gulp watch",
|
|
@@ -27,27 +31,26 @@
|
|
|
27
31
|
"tidy-clean": "rm -rf build css favicons fonts img components layout scripts coverage scss js",
|
|
28
32
|
"check-unused": "npx npm-check-unused",
|
|
29
33
|
"dedupe-deps": "npx yarn-deduplicate yarn.lock",
|
|
30
|
-
"lint
|
|
31
|
-
"
|
|
32
|
-
"stylelint-fix": "stylelint '**/*.scss' --fix",
|
|
34
|
+
"lint": "prettier --check . && eslint '**/*.{js,mjs}' && stylelint '**/*.scss' && remark . --ext md --ignore-path .remarkignore --frail",
|
|
35
|
+
"lint:fix": "prettier --write . && eslint --fix '**/*.{js,mjs}' && stylelint '**/*.scss' --fix && remark . --ext md --ignore-path .remarkignore --output",
|
|
33
36
|
"prepack": "pinst --disable",
|
|
34
37
|
"postpack": "pinst --enable"
|
|
35
38
|
},
|
|
36
39
|
"lint-staged": {
|
|
37
40
|
"*.{js,mjs}": [
|
|
38
|
-
"prettier --
|
|
39
|
-
"eslint
|
|
41
|
+
"prettier --check",
|
|
42
|
+
"eslint"
|
|
40
43
|
],
|
|
41
44
|
"*.md": [
|
|
42
|
-
"prettier --
|
|
43
|
-
"remark"
|
|
45
|
+
"prettier --check",
|
|
46
|
+
"remark --ext md --ignore-path .remarkignore --frail"
|
|
44
47
|
],
|
|
45
48
|
"*.scss": [
|
|
46
|
-
"prettier --
|
|
47
|
-
"stylelint
|
|
49
|
+
"prettier --check",
|
|
50
|
+
"stylelint"
|
|
48
51
|
],
|
|
49
52
|
"*.{yml,yaml,njk,html}": [
|
|
50
|
-
"prettier --
|
|
53
|
+
"prettier --check"
|
|
51
54
|
]
|
|
52
55
|
},
|
|
53
56
|
"browserslist": [
|