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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/component_guide/accessibility-test.js +0 -1
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +175 -0
  4. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +4 -4
  5. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +5 -13
  6. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +80 -309
  7. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +2 -2
  8. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +140 -0
  9. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +3 -0
  10. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
  11. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +12 -1
  12. data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +24 -8
  13. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +22 -1
  14. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +140 -191
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +2 -5
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +1 -5
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +3 -5
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +10 -30
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +0 -7
  20. data/app/views/govuk_publishing_components/components/_accordion.html.erb +14 -1
  21. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +27 -26
  22. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
  23. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_share_links.html.erb +11 -13
  25. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +1 -1
  26. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +4 -1
  27. data/app/views/govuk_publishing_components/components/docs/accordion.yml +15 -3
  28. data/app/views/govuk_publishing_components/components/docs/button.yml +10 -0
  29. data/app/views/govuk_publishing_components/components/docs/share_links.yml +59 -30
  30. data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +10 -1
  31. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +34 -0
  32. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -1
  34. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +3 -3
  35. data/lib/govuk_publishing_components/presenters/button_helper.rb +9 -2
  36. data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +25 -1
  37. data/lib/govuk_publishing_components/version.rb +1 -1
  38. data/node_modules/axe-core/axe.js +4559 -4673
  39. data/node_modules/axe-core/axe.min.js +2 -2
  40. data/node_modules/axe-core/package.json +2 -2
  41. data/node_modules/axe-core/sri-history.json +4 -0
  42. data/node_modules/govuk-frontend/README.md +1 -2
  43. data/node_modules/govuk-frontend/govuk/all.js +1398 -273
  44. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +70 -0
  45. data/node_modules/govuk-frontend/govuk/common/index.js +172 -0
  46. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +373 -0
  47. data/node_modules/govuk-frontend/govuk/common.js +138 -3
  48. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +753 -25
  49. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +54 -22
  50. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +36 -0
  51. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +7 -1
  52. data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +12 -12
  53. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +22 -22
  54. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +23 -5
  55. data/node_modules/govuk-frontend/govuk/components/button/button.js +365 -107
  56. data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +85 -66
  57. data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
  58. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
  59. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1033 -121
  60. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +112 -36
  61. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +42 -0
  62. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +27 -3
  63. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +30 -2
  64. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +96 -93
  65. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +46 -46
  66. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +50 -50
  67. data/node_modules/govuk-frontend/govuk/components/details/details.js +43 -13
  68. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +20 -20
  69. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +20 -20
  70. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +268 -6
  71. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +44 -35
  72. data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -21
  73. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +51 -39
  74. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +26 -26
  75. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +46 -46
  77. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +2 -2
  78. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +93 -38
  79. data/node_modules/govuk-frontend/govuk/components/header/header.js +6 -0
  80. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +8 -2
  81. data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -2
  82. data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +12 -12
  83. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +80 -80
  84. data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +12 -12
  85. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +34 -34
  86. data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +56 -46
  87. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +252 -2
  88. data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +1 -1
  89. data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +10 -7
  90. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +33 -26
  91. data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +18 -18
  92. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +14 -14
  93. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +94 -91
  94. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +30 -2
  95. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +32 -32
  96. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +22 -20
  97. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +10 -4
  98. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +50 -50
  99. data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
  100. data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +40 -40
  101. data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +29 -29
  102. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +28 -0
  103. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +28 -28
  104. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +34 -34
  105. data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +14 -14
  106. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
  107. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
  108. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -6
  109. data/node_modules/govuk-frontend/govuk/i18n.js +390 -0
  110. data/node_modules/govuk-frontend/govuk/macros/i18n.njk +15 -0
  111. data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
  112. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
  113. data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
  114. data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
  115. data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
  116. data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
  117. data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
  118. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +21 -0
  119. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +300 -0
  120. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +21 -0
  121. data/node_modules/govuk-frontend/govuk-esm/all.mjs +50 -27
  122. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +15 -0
  123. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +159 -0
  124. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +58 -0
  125. data/node_modules/govuk-frontend/govuk-esm/common.mjs +6 -28
  126. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +113 -43
  127. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +67 -30
  128. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +325 -123
  129. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +9 -3
  130. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +22 -8
  131. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +48 -6
  132. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +6 -0
  133. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +32 -2
  134. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +9 -3
  135. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +10 -4
  136. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +8 -2
  137. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +380 -0
  138. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +13 -0
  139. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +68 -0
  140. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +13 -0
  141. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
  142. data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
  143. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +138 -7
  144. data/node_modules/govuk-frontend/package.json +1 -1
  145. metadata +22 -3
@@ -11,8 +11,19 @@
11
11
  "text": "Can you provide more detail?"
12
12
  }
13
13
  },
14
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"more-detail\">\n Can you provide more detail?\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"more-detail\" name=\"more-detail\" rows=\"5\" aria-describedby=\"more-detail-info\"></textarea>\n</div>\n\n <div id=\"more-detail-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
15
- "hidden": false
14
+ "hidden": false,
15
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"more-detail\">\n Can you provide more detail?\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"more-detail\" name=\"more-detail\" rows=\"5\" aria-describedby=\"more-detail-info\"></textarea>\n</div>\n\n \n <div id=\"more-detail-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
16
+ },
17
+ {
18
+ "name": "with custom textarea description",
19
+ "options": {
20
+ "name": "custom-textarea-description",
21
+ "id": "custom-textarea-description",
22
+ "maxlength": 10,
23
+ "textareaDescriptionText": "Gallwch ddefnyddio hyd at %{count} nod"
24
+ },
25
+ "hidden": false,
26
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n \n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"custom-textarea-description\" name=\"custom-textarea-description\" rows=\"5\" aria-describedby=\"custom-textarea-description-info\"></textarea>\n</div>\n\n \n <div id=\"custom-textarea-description-info\" class=\"govuk-hint govuk-character-count__message\">\n Gallwch ddefnyddio hyd at 10 nod\n</div>\n\n</div>"
16
27
  },
17
28
  {
18
29
  "name": "with hint",
@@ -27,8 +38,8 @@
27
38
  "text": "Don't include personal or financial information, eg your National Insurance number or credit card details."
28
39
  }
29
40
  },
30
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-hint\">\n Can you provide more detail?\n </label>\n\n \n \n <div id=\"with-hint-hint\" class=\"govuk-hint\">\n Don&#39;t include personal or financial information, eg your National Insurance number or credit card details.\n </div>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-hint\" name=\"with-hint\" rows=\"5\" aria-describedby=\"with-hint-info with-hint-hint\"></textarea>\n</div>\n\n <div id=\"with-hint-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
31
- "hidden": false
41
+ "hidden": false,
42
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-hint\">\n Can you provide more detail?\n </label>\n\n \n \n <div id=\"with-hint-hint\" class=\"govuk-hint\">\n Don&#39;t include personal or financial information, eg your National Insurance number or credit card details.\n </div>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-hint\" name=\"with-hint\" rows=\"5\" aria-describedby=\"with-hint-info with-hint-hint\"></textarea>\n</div>\n\n \n <div id=\"with-hint-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
32
43
  },
33
44
  {
34
45
  "name": "with default value",
@@ -41,8 +52,8 @@
41
52
  },
42
53
  "value": "221B Baker Street\nLondon\nNW1 6XE\n"
43
54
  },
44
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"100\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-default-value\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-default-value\" name=\"default-value\" rows=\"5\" aria-describedby=\"with-default-value-info\">221B Baker Street\nLondon\nNW1 6XE\n</textarea>\n</div>\n\n <div id=\"with-default-value-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 100 characters\n</div>\n\n</div>",
45
- "hidden": false
55
+ "hidden": false,
56
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"100\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-default-value\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-default-value\" name=\"default-value\" rows=\"5\" aria-describedby=\"with-default-value-info\">221B Baker Street\nLondon\nNW1 6XE\n</textarea>\n</div>\n\n \n <div id=\"with-default-value-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 100 characters\n</div>\n\n</div>"
46
57
  },
47
58
  {
48
59
  "name": "with default value exceeding limit",
@@ -58,8 +69,8 @@
58
69
  "text": "Please do not exceed the maximum allowed limit"
59
70
  }
60
71
  },
61
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group govuk-form-group--error\">\n <label class=\"govuk-label\" for=\"exceeding-characters\">\n Full address\n </label>\n\n\n \n \n <p id=\"exceeding-characters-error\" class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> Please do not exceed the maximum allowed limit\n </p>\n\n <textarea class=\"govuk-textarea govuk-textarea--error govuk-js-character-count govuk-textarea--error\" id=\"exceeding-characters\" name=\"exceeding\" rows=\"5\" aria-describedby=\"exceeding-characters-info exceeding-characters-error\">221B Baker Street\nLondon\nNW1 6XE\n</textarea>\n</div>\n\n <div id=\"exceeding-characters-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
62
- "hidden": false
72
+ "hidden": false,
73
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group govuk-form-group--error\">\n <label class=\"govuk-label\" for=\"exceeding-characters\">\n Full address\n </label>\n\n\n \n \n <p id=\"exceeding-characters-error\" class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> Please do not exceed the maximum allowed limit\n </p>\n\n <textarea class=\"govuk-textarea govuk-textarea--error govuk-js-character-count\" id=\"exceeding-characters\" name=\"exceeding\" rows=\"5\" aria-describedby=\"exceeding-characters-info exceeding-characters-error\">221B Baker Street\nLondon\nNW1 6XE\n</textarea>\n</div>\n\n \n <div id=\"exceeding-characters-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
63
74
  },
64
75
  {
65
76
  "name": "with custom rows",
@@ -72,8 +83,8 @@
72
83
  },
73
84
  "rows": 8
74
85
  },
75
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"custom-rows\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"custom-rows\" name=\"custom\" rows=\"8\" aria-describedby=\"custom-rows-info\"></textarea>\n</div>\n\n <div id=\"custom-rows-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
76
- "hidden": false
86
+ "hidden": false,
87
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"custom-rows\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"custom-rows\" name=\"custom\" rows=\"8\" aria-describedby=\"custom-rows-info\"></textarea>\n</div>\n\n \n <div id=\"custom-rows-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
77
88
  },
78
89
  {
79
90
  "name": "with label as page heading",
@@ -87,8 +98,8 @@
87
98
  "isPageHeading": true
88
99
  }
89
100
  },
90
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <h1 class=\"govuk-label-wrapper\">\n <label class=\"govuk-label govuk-label--l\" for=\"textarea-with-page-heading\">\n Full address\n </label>\n </h1>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"textarea-with-page-heading\" name=\"address\" rows=\"5\" aria-describedby=\"textarea-with-page-heading-info\"></textarea>\n</div>\n\n <div id=\"textarea-with-page-heading-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
91
- "hidden": false
101
+ "hidden": false,
102
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <h1 class=\"govuk-label-wrapper\">\n <label class=\"govuk-label govuk-label--l\" for=\"textarea-with-page-heading\">\n Full address\n </label>\n </h1>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"textarea-with-page-heading\" name=\"address\" rows=\"5\" aria-describedby=\"textarea-with-page-heading-info\"></textarea>\n</div>\n\n \n <div id=\"textarea-with-page-heading-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
92
103
  },
93
104
  {
94
105
  "name": "with word count",
@@ -100,8 +111,8 @@
100
111
  "text": "Full address"
101
112
  }
102
113
  },
103
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxwords=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"word-count\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"word-count\" name=\"word-count\" rows=\"5\" aria-describedby=\"word-count-info\"></textarea>\n</div>\n\n <div id=\"word-count-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 words\n</div>\n\n</div>",
104
- "hidden": false
114
+ "hidden": false,
115
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxwords=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"word-count\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"word-count\" name=\"word-count\" rows=\"5\" aria-describedby=\"word-count-info\"></textarea>\n</div>\n\n \n <div id=\"word-count-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 words\n</div>\n\n</div>"
105
116
  },
106
117
  {
107
118
  "name": "with threshold",
@@ -114,8 +125,36 @@
114
125
  "text": "Full address"
115
126
  }
116
127
  },
117
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\" data-threshold=\"75\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-threshold\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-threshold\" name=\"with-threshold\" rows=\"5\" aria-describedby=\"with-threshold-info\"></textarea>\n</div>\n\n <div id=\"with-threshold-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
118
- "hidden": false
128
+ "hidden": false,
129
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\" data-threshold=\"75\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-threshold\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-threshold\" name=\"with-threshold\" rows=\"5\" aria-describedby=\"with-threshold-info\"></textarea>\n</div>\n\n \n <div id=\"with-threshold-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
130
+ },
131
+ {
132
+ "name": "with translations",
133
+ "options": {
134
+ "id": "with-translations",
135
+ "name": "with-translations",
136
+ "maxlength": 10,
137
+ "charactersUnderLimitText": {
138
+ "other": "%{count} characters to go",
139
+ "one": "One character to go"
140
+ },
141
+ "charactersAtLimitText": "Zero characters left",
142
+ "charactersOverLimitText": {
143
+ "other": "%{count} characters too many",
144
+ "one": "One character too many"
145
+ },
146
+ "wordsUnderLimitText": {
147
+ "other": "%{count} words to go",
148
+ "one": "One word to go"
149
+ },
150
+ "wordsAtLimitText": "Zero words left",
151
+ "wordsOverLimitText": {
152
+ "other": "%{count} words too many",
153
+ "one": "One word too many"
154
+ }
155
+ },
156
+ "hidden": false,
157
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n\n data-i18n.characters-under-limit.other=\"%{count} characters to go\" data-i18n.characters-under-limit.one=\"One character to go\"\n data-i18n.characters-at-limit=\"Zero characters left\"\n data-i18n.characters-over-limit.other=\"%{count} characters too many\" data-i18n.characters-over-limit.one=\"One character too many\"\n\n data-i18n.words-under-limit.other=\"%{count} words to go\" data-i18n.words-under-limit.one=\"One word to go\"\n data-i18n.words-at-limit=\"Zero words left\"\n data-i18n.words-over-limit.other=\"%{count} words too many\" data-i18n.words-over-limit.one=\"One word too many\"\n>\n \n\n<div class=\"govuk-form-group\">\n \n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-translations\" name=\"with-translations\" rows=\"5\" aria-describedby=\"with-translations-info\"></textarea>\n</div>\n\n \n <div id=\"with-translations-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
119
158
  },
120
159
  {
121
160
  "name": "classes",
@@ -128,8 +167,8 @@
128
167
  },
129
168
  "classes": "app-character-count--custom-modifier"
130
169
  },
131
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-classes\">\n With classes\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count app-character-count--custom-modifier\" id=\"with-classes\" name=\"with-classes\" rows=\"5\" aria-describedby=\"with-classes-info\"></textarea>\n</div>\n\n <div id=\"with-classes-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
132
- "hidden": true
170
+ "hidden": true,
171
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-classes\">\n With classes\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count app-character-count--custom-modifier\" id=\"with-classes\" name=\"with-classes\" rows=\"5\" aria-describedby=\"with-classes-info\"></textarea>\n</div>\n\n \n <div id=\"with-classes-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
133
172
  },
134
173
  {
135
174
  "name": "attributes",
@@ -144,8 +183,8 @@
144
183
  "data-attribute": "my data value"
145
184
  }
146
185
  },
147
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-attributes\">\n With attributes\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-attributes\" name=\"with-attributes\" rows=\"5\" aria-describedby=\"with-attributes-info\" data-attribute=\"my data value\"></textarea>\n</div>\n\n <div id=\"with-attributes-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
148
- "hidden": true
186
+ "hidden": true,
187
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-attributes\">\n With attributes\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-attributes\" name=\"with-attributes\" rows=\"5\" aria-describedby=\"with-attributes-info\" data-attribute=\"my data value\"></textarea>\n</div>\n\n \n <div id=\"with-attributes-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
149
188
  },
150
189
  {
151
190
  "name": "formGroup with classes",
@@ -160,8 +199,8 @@
160
199
  "classes": "app-character-count--custom-modifier"
161
200
  }
162
201
  },
163
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group app-character-count--custom-modifier\">\n <label class=\"govuk-label\" for=\"with-formgroup\">\n With formgroup\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-formgroup\" name=\"with-formgroup\" rows=\"5\" aria-describedby=\"with-formgroup-info\"></textarea>\n</div>\n\n <div id=\"with-formgroup-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
164
- "hidden": true
202
+ "hidden": true,
203
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group app-character-count--custom-modifier\">\n <label class=\"govuk-label\" for=\"with-formgroup\">\n With formgroup\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-formgroup\" name=\"with-formgroup\" rows=\"5\" aria-describedby=\"with-formgroup-info\"></textarea>\n</div>\n\n \n <div id=\"with-formgroup-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
165
204
  },
166
205
  {
167
206
  "name": "custom classes on countMessage",
@@ -176,8 +215,8 @@
176
215
  "classes": "app-custom-count-message"
177
216
  }
178
217
  },
179
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-custom-countmessage-class\">\n With custom countMessage class\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-custom-countmessage-class\" name=\"with-custom-countmessage-class\" rows=\"5\" aria-describedby=\"with-custom-countmessage-class-info\"></textarea>\n</div>\n\n <div id=\"with-custom-countmessage-class-info\" class=\"govuk-hint govuk-character-count__message app-custom-count-message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
180
- "hidden": true
218
+ "hidden": true,
219
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-custom-countmessage-class\">\n With custom countMessage class\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-custom-countmessage-class\" name=\"with-custom-countmessage-class\" rows=\"5\" aria-describedby=\"with-custom-countmessage-class-info\"></textarea>\n</div>\n\n \n <div id=\"with-custom-countmessage-class-info\" class=\"govuk-hint govuk-character-count__message app-custom-count-message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
181
220
  },
182
221
  {
183
222
  "name": "spellcheck enabled",
@@ -190,8 +229,8 @@
190
229
  },
191
230
  "spellcheck": true
192
231
  },
193
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-spellcheck\">\n With spellcheck\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-spellcheck\" name=\"with-spellcheck\" rows=\"5\" spellcheck=\"true\" aria-describedby=\"with-spellcheck-info\"></textarea>\n</div>\n\n <div id=\"with-spellcheck-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
194
- "hidden": true
232
+ "hidden": true,
233
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"with-spellcheck\">\n With spellcheck\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"with-spellcheck\" name=\"with-spellcheck\" rows=\"5\" spellcheck=\"true\" aria-describedby=\"with-spellcheck-info\"></textarea>\n</div>\n\n \n <div id=\"with-spellcheck-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
195
234
  },
196
235
  {
197
236
  "name": "spellcheck disabled",
@@ -204,8 +243,8 @@
204
243
  },
205
244
  "spellcheck": false
206
245
  },
207
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"without-spellcheck\">\n Without spellcheck\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"without-spellcheck\" name=\"without-spellcheck\" rows=\"5\" spellcheck=\"false\" aria-describedby=\"without-spellcheck-info\"></textarea>\n</div>\n\n <div id=\"without-spellcheck-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
208
- "hidden": true
246
+ "hidden": true,
247
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"without-spellcheck\">\n Without spellcheck\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"without-spellcheck\" name=\"without-spellcheck\" rows=\"5\" spellcheck=\"false\" aria-describedby=\"without-spellcheck-info\"></textarea>\n</div>\n\n \n <div id=\"without-spellcheck-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
209
248
  },
210
249
  {
211
250
  "name": "custom classes with error message",
@@ -221,8 +260,8 @@
221
260
  "text": "Error message"
222
261
  }
223
262
  },
224
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group govuk-form-group--error\">\n <label class=\"govuk-label\" for=\"with-custom-error-class\">\n With custom error class\n </label>\n\n\n \n \n <p id=\"with-custom-error-class-error\" class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> Error message\n </p>\n\n <textarea class=\"govuk-textarea govuk-textarea--error govuk-js-character-count govuk-textarea--error app-character-count--custom-modifier\" id=\"with-custom-error-class\" name=\"with-custom-error-class\" rows=\"5\" aria-describedby=\"with-custom-error-class-info with-custom-error-class-error\"></textarea>\n</div>\n\n <div id=\"with-custom-error-class-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
225
- "hidden": true
263
+ "hidden": true,
264
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group govuk-form-group--error\">\n <label class=\"govuk-label\" for=\"with-custom-error-class\">\n With custom error class\n </label>\n\n\n \n \n <p id=\"with-custom-error-class-error\" class=\"govuk-error-message\">\n <span class=\"govuk-visually-hidden\">Error:</span> Error message\n </p>\n\n <textarea class=\"govuk-textarea govuk-textarea--error govuk-js-character-count app-character-count--custom-modifier\" id=\"with-custom-error-class\" name=\"with-custom-error-class\" rows=\"5\" aria-describedby=\"with-custom-error-class-info with-custom-error-class-error\"></textarea>\n</div>\n\n \n <div id=\"with-custom-error-class-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
226
265
  },
227
266
  {
228
267
  "name": "with id starting with number",
@@ -234,8 +273,8 @@
234
273
  "text": "Can you provide more detail?"
235
274
  }
236
275
  },
237
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"1_more-detail\">\n Can you provide more detail?\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"1_more-detail\" name=\"more-detail\" rows=\"5\" aria-describedby=\"1_more-detail-info\"></textarea>\n</div>\n\n <div id=\"1_more-detail-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
238
- "hidden": true
276
+ "hidden": true,
277
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"1_more-detail\">\n Can you provide more detail?\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"1_more-detail\" name=\"more-detail\" rows=\"5\" aria-describedby=\"1_more-detail-info\"></textarea>\n</div>\n\n \n <div id=\"1_more-detail-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
239
278
  },
240
279
  {
241
280
  "name": "with id with special characters",
@@ -247,8 +286,8 @@
247
286
  "text": "Full address"
248
287
  }
249
288
  },
250
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"user1.profile[address]\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"user1.profile[address]\" name=\"address\" rows=\"5\" aria-describedby=\"user1.profile[address]-info\"></textarea>\n</div>\n\n <div id=\"user1.profile[address]-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
251
- "hidden": true
289
+ "hidden": true,
290
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"user1.profile[address]\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"user1.profile[address]\" name=\"address\" rows=\"5\" aria-describedby=\"user1.profile[address]-info\"></textarea>\n</div>\n\n \n <div id=\"user1.profile[address]-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
252
291
  },
253
292
  {
254
293
  "name": "with textarea maxlength attribute",
@@ -263,8 +302,45 @@
263
302
  "text": "Full address"
264
303
  }
265
304
  },
266
- "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\">\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"maxlength-should-be-removed\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"maxlength-should-be-removed\" name=\"address\" rows=\"5\" aria-describedby=\"maxlength-should-be-removed-info\" maxlength=\"10\"></textarea>\n</div>\n\n <div id=\"maxlength-should-be-removed-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>",
267
- "hidden": true
305
+ "hidden": true,
306
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\" data-maxlength=\"10\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"maxlength-should-be-removed\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"maxlength-should-be-removed\" name=\"address\" rows=\"5\" aria-describedby=\"maxlength-should-be-removed-info\" maxlength=\"10\"></textarea>\n</div>\n\n \n <div id=\"maxlength-should-be-removed-info\" class=\"govuk-hint govuk-character-count__message\">\n You can enter up to 10 characters\n</div>\n\n</div>"
307
+ },
308
+ {
309
+ "name": "to configure in JavaScript",
310
+ "options": {
311
+ "id": "to-configure-in-javascript",
312
+ "name": "address",
313
+ "label": {
314
+ "text": "Full address"
315
+ }
316
+ },
317
+ "hidden": true,
318
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"to-configure-in-javascript\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"to-configure-in-javascript\" name=\"address\" rows=\"5\" aria-describedby=\"to-configure-in-javascript-info\"></textarea>\n</div>\n\n \n <div id=\"to-configure-in-javascript-info\" class=\"govuk-hint govuk-character-count__message\">\n \n</div>\n\n</div>"
319
+ },
320
+ {
321
+ "name": "when neither maxlength nor maxwords are set",
322
+ "options": {
323
+ "id": "no-maximum",
324
+ "name": "no-maximum",
325
+ "label": {
326
+ "text": "Full address"
327
+ },
328
+ "textareaDescriptionText": "No more than %{count} characters"
329
+ },
330
+ "hidden": true,
331
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\"\n\n data-i18n.textarea-description.other=\"No more than %{count} characters\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"no-maximum\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"no-maximum\" name=\"no-maximum\" rows=\"5\" aria-describedby=\"no-maximum-info\"></textarea>\n</div>\n\n \n <div id=\"no-maximum-info\" class=\"govuk-hint govuk-character-count__message\">\n \n</div>\n\n</div>"
332
+ },
333
+ {
334
+ "name": "when neither maxlength/maxwords nor textarea description are set",
335
+ "options": {
336
+ "id": "no-maximum",
337
+ "name": "no-maximum",
338
+ "label": {
339
+ "text": "Full address"
340
+ }
341
+ },
342
+ "hidden": true,
343
+ "html": "<div class=\"govuk-character-count\" data-module=\"govuk-character-count\"\n>\n \n\n<div class=\"govuk-form-group\">\n <label class=\"govuk-label\" for=\"no-maximum\">\n Full address\n </label>\n\n\n <textarea class=\"govuk-textarea govuk-js-character-count\" id=\"no-maximum\" name=\"no-maximum\" rows=\"5\" aria-describedby=\"no-maximum-info\"></textarea>\n</div>\n\n \n <div id=\"no-maximum-info\" class=\"govuk-hint govuk-character-count__message\">\n \n</div>\n\n</div>"
268
344
  }
269
345
  ]
270
346
  }
@@ -107,5 +107,47 @@
107
107
  "description": "Classes to add to the count message."
108
108
  }
109
109
  ]
110
+ },
111
+ {
112
+ "name": "textareaDescriptionText",
113
+ "type": "string",
114
+ "required": false,
115
+ "description": "Message made available to assistive technologies to describe that the component accepts only a limited amount of content. It is visible on the page when JavaScript is unavailable. The component will replace the `%{count}` placeholder with the value of the `maxlength` or `maxwords` parameter."
116
+ },
117
+ {
118
+ "name": "charactersUnderLimitText",
119
+ "type": "object",
120
+ "required": false,
121
+ "description": "Message displayed when the number of characters is under the configured maximum, `maxlength`. This message is displayed visually and through assistive technologies. The component will replace the `%{count}` placeholder with the number of remaining characters. This is a [pluralised list of messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend)."
122
+ },
123
+ {
124
+ "name": "charactersAtLimitText",
125
+ "type": "string",
126
+ "required": false,
127
+ "description": "Message displayed when the number of characters reaches the configured maximum, `maxlength`. This message is displayed visually and through assistive technologies."
128
+ },
129
+ {
130
+ "name": "charactersUnderLimitText",
131
+ "type": "object",
132
+ "required": false,
133
+ "description": "Message displayed when the number of characters is over the configured maximum, `maxlength`. This message is displayed visually and through assistive technologies. The component will replace the `%{count}` placeholder with the number of characters above the maximum. This is a [pluralised list of messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend)."
134
+ },
135
+ {
136
+ "name": "wordsUnderLimitText",
137
+ "type": "object",
138
+ "required": false,
139
+ "description": "Message displayed when the number of words is under the configured maximum, `maxwords`. This message is displayed visually and through assistive technologies. The component will replace the `%{count}` placeholder with the number of remaining words. This is a [pluralised list of messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend)."
140
+ },
141
+ {
142
+ "name": "wordsAtLimitText",
143
+ "type": "string",
144
+ "required": false,
145
+ "description": "Message displayed when the number of words reaches the configured maximum, `maxwords`. This message is displayed visually and through assistive technologies."
146
+ },
147
+ {
148
+ "name": "wordsUnderLimitText",
149
+ "type": "object",
150
+ "required": false,
151
+ "description": "Message displayed when the number of words is over the configured maximum, `maxwords`. This message is displayed visually and through assistive technologies. The component will replace the `%{count}` placeholder with the number of characters above the maximum. This is a [pluralised list of messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend)."
110
152
  }
111
153
  ]
@@ -1,10 +1,27 @@
1
+ {% from "../../macros/i18n.njk" import govukPluralisedI18nAttributes %}
2
+
1
3
  {% from "../textarea/macro.njk" import govukTextarea %}
2
4
  {% from "../hint/macro.njk" import govukHint %}
3
5
 
6
+ {%- set hasNoLimit = (not params.maxwords and not params.maxlength) %}
7
+
4
8
  <div class="govuk-character-count" data-module="govuk-character-count"
5
9
  {%- if params.maxlength %} data-maxlength="{{ params.maxlength }}"{% endif %}
6
10
  {%- if params.threshold %} data-threshold="{{ params.threshold }}"{% endif %}
7
- {%- if params.maxwords %} data-maxwords="{{ params.maxwords }}"{% endif %}>
11
+ {%- if params.maxwords %} data-maxwords="{{ params.maxwords }}"{% endif %}
12
+ {#
13
+ Without maxlength or maxwords, we can't guess if the component will count words or characters.
14
+ We can't guess a default textarea description to be interpolated in JavaScript
15
+ once the maximum gets configured there.
16
+ So we only add the attribute if a textarea description was explicitely provided.
17
+ #}
18
+ {%- if hasNoLimit and params.textareaDescriptionText %}{{govukPluralisedI18nAttributes('textarea-description', {other: params.textareaDescriptionText})}}{% endif %}
19
+ {%- if params.charactersUnderLimitText %}{{govukPluralisedI18nAttributes('characters-under-limit', params.charactersUnderLimitText)}}{% endif %}
20
+ {%- if params.charactersAtLimitText %} data-i18n.characters-at-limit="{{ params.charactersAtLimitText | escape}}"{% endif %}
21
+ {%- if params.charactersOverLimitText %}{{govukPluralisedI18nAttributes('characters-over-limit', params.charactersOverLimitText)}}{% endif %}
22
+ {%- if params.wordsUnderLimitText %}{{govukPluralisedI18nAttributes('words-under-limit', params.wordsUnderLimitText)}}{% endif %}
23
+ {%- if params.wordsAtLimitText %} data-i18n.words-at-limit="{{ params.wordsAtLimitText | escape}}"{% endif %}
24
+ {%- if params.wordsOverLimitText %}{{govukPluralisedI18nAttributes('words-over-limit', params.wordsOverLimitText)}}{% endif %}>
8
25
  {{ govukTextarea({
9
26
  id: params.id,
10
27
  name: params.name,
@@ -13,7 +30,7 @@
13
30
  spellcheck: params.spellcheck,
14
31
  value: params.value,
15
32
  formGroup: params.formGroup,
16
- classes: 'govuk-js-character-count' + (' govuk-textarea--error' if params.errorMessage) + (' ' + params.classes if params.classes),
33
+ classes: 'govuk-js-character-count' + (' ' + params.classes if params.classes),
17
34
  label: {
18
35
  html: params.label.html,
19
36
  text: params.label.text,
@@ -26,8 +43,15 @@
26
43
  errorMessage: params.errorMessage,
27
44
  attributes: params.attributes
28
45
  }) }}
46
+ {%- set textareaDescriptionLength = params.maxwords or params.maxlength %}
47
+ {%- set textareaDescriptionText = params.textareaDescriptionText or 'You can enter up to %{count} ' + ('words' if params.maxwords else 'characters') %}
48
+ {#
49
+ If the limit is set in JavaScript, we won't be able to interpolate the message
50
+ until JavaScript, so we only set a text if the `maxlength` or `maxwords` options
51
+ were provided to the macro.
52
+ #}
29
53
  {{ govukHint({
30
- text: 'You can enter up to ' + (params.maxlength or params.maxwords) + (' words' if params.maxwords else ' characters'),
54
+ text: ((textareaDescriptionText) | replace('%{count}', textareaDescriptionLength) if not hasNoLimit),
31
55
  id: params.id + '-info',
32
56
  classes: 'govuk-character-count__message' + (' ' + params.countMessage.classes if params.countMessage.classes)
33
57
  }) }}
@@ -1014,10 +1014,24 @@ if (detect) return
1014
1014
 
1015
1015
  }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1016
1016
 
1017
+ /**
1018
+ * Common helpers which do not require polyfill.
1019
+ *
1020
+ * IMPORTANT: If a helper require a polyfill, please isolate it in its own module
1021
+ * so that the polyfill can be properly tree-shaken and does not burden
1022
+ * the components that do not need that helper
1023
+ *
1024
+ * @module common/index
1025
+ */
1026
+
1017
1027
  /**
1018
1028
  * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
1019
1029
  * This seems to fail in IE8, requires more investigation.
1020
1030
  * See: https://github.com/imagitama/nodelist-foreach-polyfill
1031
+ *
1032
+ * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
1033
+ * @param {nodeListIterator} callback - Callback function to run for each node
1034
+ * @returns {undefined}
1021
1035
  */
1022
1036
  function nodeListForEach (nodes, callback) {
1023
1037
  if (window.NodeList.prototype.forEach) {
@@ -1028,6 +1042,20 @@ function nodeListForEach (nodes, callback) {
1028
1042
  }
1029
1043
  }
1030
1044
 
1045
+ /**
1046
+ * @callback nodeListIterator
1047
+ * @param {Element} value - The current node being iterated on
1048
+ * @param {number} index - The current index in the iteration
1049
+ * @param {NodeListOf<Element>} nodes - NodeList from querySelectorAll()
1050
+ * @returns {undefined}
1051
+ */
1052
+
1053
+ /**
1054
+ * Checkboxes component
1055
+ *
1056
+ * @class
1057
+ * @param {HTMLElement} $module - HTML element to use for checkboxes
1058
+ */
1031
1059
  function Checkboxes ($module) {
1032
1060
  this.$module = $module;
1033
1061
  this.$inputs = $module.querySelectorAll('input[type="checkbox"]');
@@ -1097,7 +1125,7 @@ Checkboxes.prototype.syncAllConditionalReveals = function () {
1097
1125
  * Synchronise the visibility of the conditional reveal, and its accessible
1098
1126
  * state, with the input's checked state.
1099
1127
  *
1100
- * @param {HTMLInputElement} $input Checkbox input
1128
+ * @param {HTMLInputElement} $input - Checkbox input
1101
1129
  */
1102
1130
  Checkboxes.prototype.syncConditionalRevealWithInputState = function ($input) {
1103
1131
  var $target = document.getElementById($input.getAttribute('aria-controls'));
@@ -1155,7 +1183,7 @@ Checkboxes.prototype.unCheckExclusiveInputs = function ($input) {
1155
1183
  * Handle a click within the $module – if the click occurred on a checkbox, sync
1156
1184
  * the state of any associated conditional reveal with the checkbox state.
1157
1185
  *
1158
- * @param {MouseEvent} event Click event
1186
+ * @param {MouseEvent} event - Click event
1159
1187
  */
1160
1188
  Checkboxes.prototype.handleClick = function (event) {
1161
1189
  var $target = event.target;