govuk_publishing_components 32.1.0 → 33.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/component_guide/accessibility-test.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +175 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +5 -13
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +80 -309
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +2 -2
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +140 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +3 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +12 -1
- data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +24 -8
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +22 -1
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +140 -191
- data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +2 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +3 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +10 -30
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -7
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +14 -1
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +27 -26
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +11 -13
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +15 -3
- data/app/views/govuk_publishing_components/components/docs/button.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +59 -30
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +10 -1
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +34 -0
- data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +3 -3
- data/lib/govuk_publishing_components/presenters/button_helper.rb +9 -2
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +25 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/axe.js +4559 -4673
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/package.json +2 -2
- data/node_modules/axe-core/sri-history.json +4 -0
- data/node_modules/govuk-frontend/README.md +1 -2
- data/node_modules/govuk-frontend/govuk/all.js +1398 -273
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +70 -0
- data/node_modules/govuk-frontend/govuk/common/index.js +172 -0
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +373 -0
- data/node_modules/govuk-frontend/govuk/common.js +138 -3
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +753 -25
- data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +54 -22
- data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +36 -0
- data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +7 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +22 -22
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +23 -5
- data/node_modules/govuk-frontend/govuk/components/button/button.js +365 -107
- data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +85 -66
- data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1033 -121
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +112 -36
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +42 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +27 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +30 -2
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +96 -93
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +50 -50
- data/node_modules/govuk-frontend/govuk/components/details/details.js +43 -13
- data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +268 -6
- data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +44 -35
- data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -21
- data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +51 -39
- data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +26 -26
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +93 -38
- data/node_modules/govuk-frontend/govuk/components/header/header.js +6 -0
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +8 -2
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -2
- data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +80 -80
- data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +56 -46
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +252 -2
- data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +10 -7
- data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +33 -26
- data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +18 -18
- data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +94 -91
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +30 -2
- data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +32 -32
- data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +22 -20
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +10 -4
- data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +50 -50
- data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +40 -40
- data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +29 -29
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +28 -0
- data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +28 -28
- data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -6
- data/node_modules/govuk-frontend/govuk/i18n.js +390 -0
- data/node_modules/govuk-frontend/govuk/macros/i18n.njk +15 -0
- data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
- data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
- data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
- data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +21 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +300 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +21 -0
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +50 -27
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +15 -0
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +159 -0
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +58 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +6 -28
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +113 -43
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +67 -30
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +325 -123
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +9 -3
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +22 -8
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +48 -6
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +6 -0
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +32 -2
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +9 -3
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +10 -4
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +8 -2
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +380 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +68 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +138 -7
- data/node_modules/govuk-frontend/package.json +1 -1
- metadata +22 -3
@@ -7,8 +7,8 @@
|
|
7
7
|
"summaryText": "Help with nationality",
|
8
8
|
"text": "We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post."
|
9
9
|
},
|
10
|
-
"
|
11
|
-
"
|
10
|
+
"hidden": false,
|
11
|
+
"html": "<details class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Help with nationality\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.\n </div>\n</details>"
|
12
12
|
},
|
13
13
|
{
|
14
14
|
"name": "expanded",
|
@@ -18,8 +18,8 @@
|
|
18
18
|
"text": "We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.",
|
19
19
|
"open": true
|
20
20
|
},
|
21
|
-
"
|
22
|
-
"
|
21
|
+
"hidden": false,
|
22
|
+
"html": "<details id=\"help-with-nationality\" class=\"govuk-details\" data-module=\"govuk-details\" open>\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Help with nationality\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.\n </div>\n</details>"
|
23
23
|
},
|
24
24
|
{
|
25
25
|
"name": "with html",
|
@@ -27,8 +27,8 @@
|
|
27
27
|
"summaryText": "Where to find your National Insurance Number",
|
28
28
|
"html": "Your National Insurance number can be found on\n<ul>\n <li>your National Insurance card</li>\n <li>your payslip</li>\n <li>P60</li>\n <li>benefits information</li>\n <li>tax return</li>\n</ul>\n"
|
29
29
|
},
|
30
|
-
"
|
31
|
-
"
|
30
|
+
"hidden": false,
|
31
|
+
"html": "<details class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Where to find your National Insurance Number\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n Your National Insurance number can be found on\n<ul>\n <li>your National Insurance card</li>\n <li>your payslip</li>\n <li>P60</li>\n <li>benefits information</li>\n <li>tax return</li>\n</ul>\n\n </div>\n</details>"
|
32
32
|
},
|
33
33
|
{
|
34
34
|
"name": "id",
|
@@ -37,8 +37,8 @@
|
|
37
37
|
"summaryText": "Expand this section",
|
38
38
|
"text": "Here are some more details"
|
39
39
|
},
|
40
|
-
"
|
41
|
-
"
|
40
|
+
"hidden": true,
|
41
|
+
"html": "<details id=\"my-details-element\" class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Expand this section\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n Here are some more details\n </div>\n</details>"
|
42
42
|
},
|
43
43
|
{
|
44
44
|
"name": "html as text",
|
@@ -46,8 +46,8 @@
|
|
46
46
|
"summaryText": "Expand this section",
|
47
47
|
"text": "More about the greater than symbol (>)"
|
48
48
|
},
|
49
|
-
"
|
50
|
-
"
|
49
|
+
"hidden": true,
|
50
|
+
"html": "<details class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Expand this section\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n More about the greater than symbol (>)\n </div>\n</details>"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"name": "html",
|
@@ -55,8 +55,8 @@
|
|
55
55
|
"summaryText": "Expand this section",
|
56
56
|
"html": "More about <b>bold text</b>"
|
57
57
|
},
|
58
|
-
"
|
59
|
-
"
|
58
|
+
"hidden": true,
|
59
|
+
"html": "<details class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Expand this section\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n More about <b>bold text</b>\n </div>\n</details>"
|
60
60
|
},
|
61
61
|
{
|
62
62
|
"name": "summary html as text",
|
@@ -64,8 +64,8 @@
|
|
64
64
|
"summaryText": "The greater than symbol (>) is the best",
|
65
65
|
"text": "Here are some more details"
|
66
66
|
},
|
67
|
-
"
|
68
|
-
"
|
67
|
+
"hidden": true,
|
68
|
+
"html": "<details class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n The greater than symbol (>) is the best\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n Here are some more details\n </div>\n</details>"
|
69
69
|
},
|
70
70
|
{
|
71
71
|
"name": "summary html",
|
@@ -73,8 +73,8 @@
|
|
73
73
|
"summaryHtml": "Use <b>bold text</b> sparingly",
|
74
74
|
"text": "Here are some more details"
|
75
75
|
},
|
76
|
-
"
|
77
|
-
"
|
76
|
+
"hidden": true,
|
77
|
+
"html": "<details class=\"govuk-details\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Use <b>bold text</b> sparingly\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n Here are some more details\n </div>\n</details>"
|
78
78
|
},
|
79
79
|
{
|
80
80
|
"name": "classes",
|
@@ -83,8 +83,8 @@
|
|
83
83
|
"text": "Here are some more details",
|
84
84
|
"summaryText": "Expand me"
|
85
85
|
},
|
86
|
-
"
|
87
|
-
"
|
86
|
+
"hidden": true,
|
87
|
+
"html": "<details class=\"govuk-details some-additional-class\" data-module=\"govuk-details\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Expand me\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n Here are some more details\n </div>\n</details>"
|
88
88
|
},
|
89
89
|
{
|
90
90
|
"name": "attributes",
|
@@ -96,8 +96,8 @@
|
|
96
96
|
"another-attribute": "foo"
|
97
97
|
}
|
98
98
|
},
|
99
|
-
"
|
100
|
-
"
|
99
|
+
"hidden": true,
|
100
|
+
"html": "<details class=\"govuk-details\" data-module=\"govuk-details\" data-some-data-attribute=\"i-love-data\" another-attribute=\"foo\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">\n Expand me\n </span>\n </summary>\n <div class=\"govuk-details__text\">\n Here are some more details\n </div>\n</details>"
|
101
101
|
}
|
102
102
|
]
|
103
103
|
}
|
@@ -6,17 +6,17 @@
|
|
6
6
|
"options": {
|
7
7
|
"text": "Error message about full name goes here"
|
8
8
|
},
|
9
|
-
"
|
10
|
-
"
|
9
|
+
"hidden": false,
|
10
|
+
"html": "<p class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> Error message about full name goes here\n</p>"
|
11
11
|
},
|
12
12
|
{
|
13
13
|
"name": "translated",
|
14
14
|
"options": {
|
15
|
-
"visuallyHiddenText":
|
15
|
+
"visuallyHiddenText": "",
|
16
16
|
"html": "<span class=\"govuk-visually-hidden\">Gwall:</span> Neges gwall am yr enw llawn yn mynd yma"
|
17
17
|
},
|
18
|
-
"
|
19
|
-
"
|
18
|
+
"hidden": false,
|
19
|
+
"html": "<p class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Gwall:</span> Neges gwall am yr enw llawn yn mynd yma\n</p>"
|
20
20
|
},
|
21
21
|
{
|
22
22
|
"name": "id",
|
@@ -24,8 +24,8 @@
|
|
24
24
|
"id": "my-error-message-id",
|
25
25
|
"text": "This is an error message"
|
26
26
|
},
|
27
|
-
"
|
28
|
-
"
|
27
|
+
"hidden": true,
|
28
|
+
"html": "<p id=\"my-error-message-id\" class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> This is an error message\n</p>"
|
29
29
|
},
|
30
30
|
{
|
31
31
|
"name": "classes",
|
@@ -33,24 +33,24 @@
|
|
33
33
|
"classes": "custom-class",
|
34
34
|
"text": "This is an error message"
|
35
35
|
},
|
36
|
-
"
|
37
|
-
"
|
36
|
+
"hidden": true,
|
37
|
+
"html": "<p class=\"govuk-error-message custom-class\">\n <span class=\"govuk-visually-hidden\">Error:</span> This is an error message\n</p>"
|
38
38
|
},
|
39
39
|
{
|
40
40
|
"name": "html as text",
|
41
41
|
"options": {
|
42
42
|
"text": "Unexpected > in body"
|
43
43
|
},
|
44
|
-
"
|
45
|
-
"
|
44
|
+
"hidden": true,
|
45
|
+
"html": "<p class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> Unexpected > in body\n</p>"
|
46
46
|
},
|
47
47
|
{
|
48
48
|
"name": "html",
|
49
49
|
"options": {
|
50
50
|
"html": "Unexpected <b>bold text</b> in body copy"
|
51
51
|
},
|
52
|
-
"
|
53
|
-
"
|
52
|
+
"hidden": true,
|
53
|
+
"html": "<p class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> Unexpected <b>bold text</b> in body copy\n</p>"
|
54
54
|
},
|
55
55
|
{
|
56
56
|
"name": "attributes",
|
@@ -61,8 +61,8 @@
|
|
61
61
|
"id": "my-error-message"
|
62
62
|
}
|
63
63
|
},
|
64
|
-
"
|
65
|
-
"
|
64
|
+
"hidden": true,
|
65
|
+
"html": "<p class=\"govuk-error-message\" data-test=\"attribute\" id=\"my-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> This is an error message\n</p>"
|
66
66
|
},
|
67
67
|
{
|
68
68
|
"name": "with visually hidden text",
|
@@ -70,17 +70,17 @@
|
|
70
70
|
"text": "Rhowch eich enw llawn",
|
71
71
|
"visuallyHiddenText": "Gwall"
|
72
72
|
},
|
73
|
-
"
|
74
|
-
"
|
73
|
+
"hidden": true,
|
74
|
+
"html": "<p class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Gwall:</span> Rhowch eich enw llawn\n</p>"
|
75
75
|
},
|
76
76
|
{
|
77
77
|
"name": "visually hidden text removed",
|
78
78
|
"options": {
|
79
79
|
"text": "There is an error on line 42",
|
80
|
-
"visuallyHiddenText":
|
80
|
+
"visuallyHiddenText": ""
|
81
81
|
},
|
82
|
-
"
|
83
|
-
"
|
82
|
+
"hidden": true,
|
83
|
+
"html": "<p class=\"govuk-error-message\">\n There is an error on line 42\n</p>"
|
84
84
|
}
|
85
85
|
]
|
86
86
|
}
|
@@ -706,8 +706,262 @@ if (detect) return
|
|
706
706
|
|
707
707
|
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
708
708
|
|
709
|
-
|
709
|
+
/**
|
710
|
+
* Common helpers which do not require polyfill.
|
711
|
+
*
|
712
|
+
* IMPORTANT: If a helper require a polyfill, please isolate it in its own module
|
713
|
+
* so that the polyfill can be properly tree-shaken and does not burden
|
714
|
+
* the components that do not need that helper
|
715
|
+
*
|
716
|
+
* @module common/index
|
717
|
+
*/
|
718
|
+
|
719
|
+
/**
|
720
|
+
* Config flattening function
|
721
|
+
*
|
722
|
+
* Takes any number of objects, flattens them into namespaced key-value pairs,
|
723
|
+
* (e.g. {'i18n.showSection': 'Show section'}) and combines them together, with
|
724
|
+
* greatest priority on the LAST item passed in.
|
725
|
+
*
|
726
|
+
* @returns {object} A flattened object of key-value pairs.
|
727
|
+
*/
|
728
|
+
function mergeConfigs (/* configObject1, configObject2, ...configObjects */) {
|
729
|
+
/**
|
730
|
+
* Function to take nested objects and flatten them to a dot-separated keyed
|
731
|
+
* object. Doing this means we don't need to do any deep/recursive merging of
|
732
|
+
* each of our objects, nor transform our dataset from a flat list into a
|
733
|
+
* nested object.
|
734
|
+
*
|
735
|
+
* @param {object} configObject - Deeply nested object
|
736
|
+
* @returns {object} Flattened object with dot-separated keys
|
737
|
+
*/
|
738
|
+
var flattenObject = function (configObject) {
|
739
|
+
// Prepare an empty return object
|
740
|
+
var flattenedObject = {};
|
741
|
+
|
742
|
+
// Our flattening function, this is called recursively for each level of
|
743
|
+
// depth in the object. At each level we prepend the previous level names to
|
744
|
+
// the key using `prefix`.
|
745
|
+
var flattenLoop = function (obj, prefix) {
|
746
|
+
// Loop through keys...
|
747
|
+
for (var key in obj) {
|
748
|
+
// Check to see if this is a prototypical key/value,
|
749
|
+
// if it is, skip it.
|
750
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
751
|
+
continue
|
752
|
+
}
|
753
|
+
var value = obj[key];
|
754
|
+
var prefixedKey = prefix ? prefix + '.' + key : key;
|
755
|
+
if (typeof value === 'object') {
|
756
|
+
// If the value is a nested object, recurse over that too
|
757
|
+
flattenLoop(value, prefixedKey);
|
758
|
+
} else {
|
759
|
+
// Otherwise, add this value to our return object
|
760
|
+
flattenedObject[prefixedKey] = value;
|
761
|
+
}
|
762
|
+
}
|
763
|
+
};
|
764
|
+
|
765
|
+
// Kick off the recursive loop
|
766
|
+
flattenLoop(configObject);
|
767
|
+
return flattenedObject
|
768
|
+
};
|
769
|
+
|
770
|
+
// Start with an empty object as our base
|
771
|
+
var formattedConfigObject = {};
|
772
|
+
|
773
|
+
// Loop through each of the remaining passed objects and push their keys
|
774
|
+
// one-by-one into configObject. Any duplicate keys will override the existing
|
775
|
+
// key with the new value.
|
776
|
+
for (var i = 0; i < arguments.length; i++) {
|
777
|
+
var obj = flattenObject(arguments[i]);
|
778
|
+
for (var key in obj) {
|
779
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
780
|
+
formattedConfigObject[key] = obj[key];
|
781
|
+
}
|
782
|
+
}
|
783
|
+
}
|
784
|
+
|
785
|
+
return formattedConfigObject
|
786
|
+
}
|
787
|
+
|
788
|
+
/**
|
789
|
+
* @callback nodeListIterator
|
790
|
+
* @param {Element} value - The current node being iterated on
|
791
|
+
* @param {number} index - The current index in the iteration
|
792
|
+
* @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
|
793
|
+
* @returns {undefined}
|
794
|
+
*/
|
795
|
+
|
796
|
+
(function(undefined) {
|
797
|
+
|
798
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/detect.js
|
799
|
+
var detect = (function(){
|
800
|
+
if (!document.documentElement.dataset) {
|
801
|
+
return false;
|
802
|
+
}
|
803
|
+
var el = document.createElement('div');
|
804
|
+
el.setAttribute("data-a-b", "c");
|
805
|
+
return el.dataset && el.dataset.aB == "c";
|
806
|
+
}());
|
807
|
+
|
808
|
+
if (detect) return
|
809
|
+
|
810
|
+
// Polyfill derived from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/polyfill.js
|
811
|
+
Object.defineProperty(Element.prototype, 'dataset', {
|
812
|
+
get: function() {
|
813
|
+
var element = this;
|
814
|
+
var attributes = this.attributes;
|
815
|
+
var map = {};
|
816
|
+
|
817
|
+
for (var i = 0; i < attributes.length; i++) {
|
818
|
+
var attribute = attributes[i];
|
819
|
+
|
820
|
+
// This regex has been edited from the original polyfill, to add
|
821
|
+
// support for period (.) separators in data-* attribute names. These
|
822
|
+
// are allowed in the HTML spec, but were not covered by the original
|
823
|
+
// polyfill's regex. We use periods in our i18n implementation.
|
824
|
+
if (attribute && attribute.name && (/^data-\w[.\w-]*$/).test(attribute.name)) {
|
825
|
+
var name = attribute.name;
|
826
|
+
var value = attribute.value;
|
827
|
+
|
828
|
+
var propName = name.substr(5).replace(/-./g, function (prop) {
|
829
|
+
return prop.charAt(1).toUpperCase();
|
830
|
+
});
|
831
|
+
|
832
|
+
// If this browser supports __defineGetter__ and __defineSetter__,
|
833
|
+
// continue using defineProperty. If not (like IE 8 and below), we use
|
834
|
+
// a hacky fallback which at least gives an object in the right format
|
835
|
+
if ('__defineGetter__' in Object.prototype && '__defineSetter__' in Object.prototype) {
|
836
|
+
Object.defineProperty(map, propName, {
|
837
|
+
enumerable: true,
|
838
|
+
get: function() {
|
839
|
+
return this.value;
|
840
|
+
}.bind({value: value || ''}),
|
841
|
+
set: function setter(name, value) {
|
842
|
+
if (typeof value !== 'undefined') {
|
843
|
+
this.setAttribute(name, value);
|
844
|
+
} else {
|
845
|
+
this.removeAttribute(name);
|
846
|
+
}
|
847
|
+
}.bind(element, name)
|
848
|
+
});
|
849
|
+
} else {
|
850
|
+
map[propName] = value;
|
851
|
+
}
|
852
|
+
|
853
|
+
}
|
854
|
+
}
|
855
|
+
|
856
|
+
return map;
|
857
|
+
}
|
858
|
+
});
|
859
|
+
|
860
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
861
|
+
|
862
|
+
(function(undefined) {
|
863
|
+
|
864
|
+
// Detection from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
865
|
+
var detect = ('trim' in String.prototype);
|
866
|
+
|
867
|
+
if (detect) return
|
868
|
+
|
869
|
+
// Polyfill from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
870
|
+
String.prototype.trim = function () {
|
871
|
+
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
872
|
+
};
|
873
|
+
|
874
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
875
|
+
|
876
|
+
/**
|
877
|
+
* Normalise string
|
878
|
+
*
|
879
|
+
* 'If it looks like a duck, and it quacks like a duck…' 🦆
|
880
|
+
*
|
881
|
+
* If the passed value looks like a boolean or a number, convert it to a boolean
|
882
|
+
* or number.
|
883
|
+
*
|
884
|
+
* Designed to be used to convert config passed via data attributes (which are
|
885
|
+
* always strings) into something sensible.
|
886
|
+
*
|
887
|
+
* @param {string} value - The value to normalise
|
888
|
+
* @returns {string | boolean | number | undefined} Normalised data
|
889
|
+
*/
|
890
|
+
function normaliseString (value) {
|
891
|
+
if (typeof value !== 'string') {
|
892
|
+
return value
|
893
|
+
}
|
894
|
+
|
895
|
+
var trimmedValue = value.trim();
|
896
|
+
|
897
|
+
if (trimmedValue === 'true') {
|
898
|
+
return true
|
899
|
+
}
|
900
|
+
|
901
|
+
if (trimmedValue === 'false') {
|
902
|
+
return false
|
903
|
+
}
|
904
|
+
|
905
|
+
// Empty / whitespace-only strings are considered finite so we need to check
|
906
|
+
// the length of the trimmed string as well
|
907
|
+
if (trimmedValue.length > 0 && isFinite(trimmedValue)) {
|
908
|
+
return Number(trimmedValue)
|
909
|
+
}
|
910
|
+
|
911
|
+
return value
|
912
|
+
}
|
913
|
+
|
914
|
+
/**
|
915
|
+
* Normalise dataset
|
916
|
+
*
|
917
|
+
* Loop over an object and normalise each value using normaliseData function
|
918
|
+
*
|
919
|
+
* @param {DOMStringMap} dataset - HTML element dataset
|
920
|
+
* @returns {Object<string, string | boolean | number | undefined>} Normalised dataset
|
921
|
+
*/
|
922
|
+
function normaliseDataset (dataset) {
|
923
|
+
var out = {};
|
924
|
+
|
925
|
+
for (var key in dataset) {
|
926
|
+
out[key] = normaliseString(dataset[key]);
|
927
|
+
}
|
928
|
+
|
929
|
+
return out
|
930
|
+
}
|
931
|
+
|
932
|
+
/**
|
933
|
+
* JavaScript enhancements for the ErrorSummary
|
934
|
+
*
|
935
|
+
* Takes focus on initialisation for accessible announcement, unless disabled in configuration.
|
936
|
+
*
|
937
|
+
* @class
|
938
|
+
* @param {HTMLElement} $module - The element this component controls
|
939
|
+
* @param {ErrorSummaryConfig} config - Error summary config
|
940
|
+
*/
|
941
|
+
function ErrorSummary ($module, config) {
|
942
|
+
// Some consuming code may not be passing a module,
|
943
|
+
// for example if they initialise the component
|
944
|
+
// on their own by directly passing the result
|
945
|
+
// of `document.querySelector`.
|
946
|
+
// To avoid breaking further JavaScript initialisation
|
947
|
+
// we need to safeguard against this so things keep
|
948
|
+
// working the same now we read the elements data attributes
|
949
|
+
if (!$module) {
|
950
|
+
// Little safety in case code gets ported as-is
|
951
|
+
// into and ES6 class constructor, where the return value matters
|
952
|
+
return this
|
953
|
+
}
|
954
|
+
|
710
955
|
this.$module = $module;
|
956
|
+
|
957
|
+
var defaultConfig = {
|
958
|
+
disableAutoFocus: false
|
959
|
+
};
|
960
|
+
this.config = mergeConfigs(
|
961
|
+
defaultConfig,
|
962
|
+
config || {},
|
963
|
+
normaliseDataset($module.dataset)
|
964
|
+
);
|
711
965
|
}
|
712
966
|
|
713
967
|
ErrorSummary.prototype.init = function () {
|
@@ -726,7 +980,7 @@ ErrorSummary.prototype.init = function () {
|
|
726
980
|
ErrorSummary.prototype.setFocus = function () {
|
727
981
|
var $module = this.$module;
|
728
982
|
|
729
|
-
if (
|
983
|
+
if (this.config.disableAutoFocus) {
|
730
984
|
return
|
731
985
|
}
|
732
986
|
|
@@ -742,10 +996,10 @@ ErrorSummary.prototype.setFocus = function () {
|
|
742
996
|
};
|
743
997
|
|
744
998
|
/**
|
745
|
-
* Click event handler
|
746
|
-
*
|
747
|
-
* @param {MouseEvent} event - Click event
|
748
|
-
*/
|
999
|
+
* Click event handler
|
1000
|
+
*
|
1001
|
+
* @param {MouseEvent} event - Click event
|
1002
|
+
*/
|
749
1003
|
ErrorSummary.prototype.handleClick = function (event) {
|
750
1004
|
var target = event.target;
|
751
1005
|
if (this.focusTarget(target)) {
|
@@ -869,6 +1123,14 @@ ErrorSummary.prototype.getAssociatedLegendOrLabel = function ($input) {
|
|
869
1123
|
$input.closest('label')
|
870
1124
|
};
|
871
1125
|
|
1126
|
+
/**
|
1127
|
+
* Error summary config
|
1128
|
+
*
|
1129
|
+
* @typedef {object} ErrorSummaryConfig
|
1130
|
+
* @property {boolean} [disableAutoFocus = false] -
|
1131
|
+
* If set to `true` the error summary will not be focussed when the page loads.
|
1132
|
+
*/
|
1133
|
+
|
872
1134
|
return ErrorSummary;
|
873
1135
|
|
874
1136
|
})));
|