govuk_publishing_components 62.0.0 → 62.1.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.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/option-select.js +4 -3
  3. data/app/assets/javascripts/govuk_publishing_components/lib/filter-list.js +48 -0
  4. data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +373 -245
  5. data/app/assets/stylesheets/component_guide/application.scss +1 -42
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +5 -1
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +6 -11
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_option-select.scss +2 -2
  9. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +6 -38
  10. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_warning-callout.scss +2 -3
  11. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +6 -1
  12. data/app/controllers/govuk_publishing_components/applications_page_controller.rb +50 -0
  13. data/app/models/govuk_publishing_components/applications_page.rb +64 -0
  14. data/app/views/govuk_publishing_components/applications_page/_table-content.html.erb +39 -0
  15. data/app/views/govuk_publishing_components/applications_page/show.html.erb +37 -0
  16. data/app/views/govuk_publishing_components/audit/show.html.erb +5 -1
  17. data/app/views/govuk_publishing_components/component_guide/_component_list.html.erb +14 -0
  18. data/app/views/govuk_publishing_components/component_guide/example.html.erb +3 -3
  19. data/app/views/govuk_publishing_components/component_guide/index.html.erb +50 -75
  20. data/app/views/govuk_publishing_components/component_guide/show.html.erb +7 -7
  21. data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +27 -25
  22. data/app/views/govuk_publishing_components/components/docs/govspeak.yml +6 -0
  23. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +7 -1
  24. data/config/routes.rb +1 -0
  25. data/lib/govuk_publishing_components/minitest/component_guide_test.rb +1 -1
  26. data/lib/govuk_publishing_components/presenters/organisation_logo_helper.rb +7 -1
  27. data/lib/govuk_publishing_components/version.rb +1 -1
  28. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +37 -133
  29. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
  30. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +37 -133
  31. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
  32. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  33. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +4 -4
  34. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss.map +1 -1
  35. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +1 -126
  36. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
  37. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +1 -126
  38. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
  39. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +1 -1
  40. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss.map +1 -1
  41. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +2 -2
  42. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss.map +1 -1
  43. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +1 -126
  44. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
  45. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +1 -126
  46. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
  47. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/fixtures.json +34 -29
  48. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/macro-options.json +1 -1
  49. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-default.html +23 -23
  50. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-conditional-reveal.html +21 -21
  51. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-divider-and-none.html +30 -30
  52. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-error.html +26 -26
  53. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-hint.html +25 -25
  54. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-long-text.html +23 -23
  55. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small.html +23 -23
  56. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-conditional-items.html +35 -35
  57. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-divider-and-none.html +30 -30
  58. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-divider-none-and-conditional-items.html +40 -40
  59. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-error-message.html +32 -32
  60. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-hint.html +25 -25
  61. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-hints-on-items.html +21 -21
  62. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-legend-as-a-page-heading.html +27 -27
  63. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-optional-form-group-classes-showing-group-error.html +36 -36
  64. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-pre-checked-values.html +35 -35
  65. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-very-long-option-text.html +25 -25
  66. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template.njk +1 -1
  67. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss +1 -1
  68. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss.map +1 -1
  69. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +1 -126
  70. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
  71. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +1 -126
  72. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
  73. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +2 -1
  74. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss.map +1 -1
  75. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +36 -132
  76. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js.map +1 -1
  77. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +36 -132
  78. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs.map +1 -1
  79. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +35 -6
  80. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs.map +1 -1
  81. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/fixtures.json +17 -0
  82. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced-multiple-files.html +10 -0
  83. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +4 -4
  84. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -1
  85. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +20 -20
  86. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -1
  87. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +7 -15
  88. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss.map +1 -1
  89. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +2 -2
  90. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss.map +1 -1
  91. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +4 -2
  92. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss.map +1 -1
  93. data/node_modules/govuk-frontend/dist/govuk/components/pagination/fixtures.json +1 -1
  94. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-many-pages.html +2 -2
  95. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template.njk +1 -1
  96. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +2 -2
  97. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss.map +1 -1
  98. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +2 -2
  99. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss.map +1 -1
  100. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +1 -126
  101. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
  102. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +1 -126
  103. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
  104. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +1 -1
  105. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss.map +1 -1
  106. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +1 -1
  107. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss.map +1 -1
  108. data/node_modules/govuk-frontend/dist/govuk/components/radios/fixtures.json +36 -31
  109. data/node_modules/govuk-frontend/dist/govuk/components/radios/macro-options.json +3 -3
  110. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-default.html +17 -17
  111. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-inline.html +19 -19
  112. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-inline.html +23 -23
  113. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-a-divider.html +24 -24
  114. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-conditional-reveal.html +27 -27
  115. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-error.html +26 -26
  116. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-hint.html +25 -25
  117. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-long-text.html +23 -23
  118. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small.html +23 -23
  119. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-a-divider.html +24 -24
  120. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-item-checked.html +35 -35
  121. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-items-and-pre-checked-value.html +35 -35
  122. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-items.html +35 -35
  123. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-fieldset-and-error-message.html +20 -20
  124. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-hint.html +19 -19
  125. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-hints-on-items.html +23 -23
  126. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-legend-as-page-heading.html +21 -21
  127. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-optional-form-group-classes-showing-group-error.html +36 -36
  128. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-very-long-option-text.html +28 -28
  129. data/node_modules/govuk-frontend/dist/govuk/components/radios/template.njk +1 -1
  130. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +1 -7
  131. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss.map +1 -1
  132. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +5 -5
  133. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss.map +1 -1
  134. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +16 -16
  135. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss.map +1 -1
  136. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +1 -1
  137. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss.map +1 -1
  138. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +1 -1
  139. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss.map +1 -1
  140. data/node_modules/govuk-frontend/dist/govuk/components/task-list/fixtures.json +46 -0
  141. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-forced-hover-state.html +37 -0
  142. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +1 -7
  143. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss.map +1 -1
  144. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +1 -1
  145. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -1
  146. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
  147. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +2 -2
  148. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss.map +1 -1
  149. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +3 -3
  150. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss.map +1 -1
  151. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
  152. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
  153. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  154. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
  155. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +34 -0
  156. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss.map +1 -1
  157. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
  158. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss.map +1 -1
  159. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +1 -1
  160. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss.map +1 -1
  161. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +172 -33
  162. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss.map +1 -1
  163. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +1 -1
  164. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss.map +1 -1
  165. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +4 -4
  166. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss.map +1 -1
  167. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +1 -126
  168. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs.map +1 -1
  169. data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss +1 -1
  170. data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss.map +1 -1
  171. data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss +1 -1
  172. data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss.map +1 -1
  173. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +1 -1
  174. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss.map +1 -1
  175. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +2 -2
  176. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss.map +1 -1
  177. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +1 -1
  178. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss.map +1 -1
  179. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +5 -5
  180. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss.map +1 -1
  181. data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss +7 -0
  182. data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss.map +1 -1
  183. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss +4 -2
  184. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss.map +1 -1
  185. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +1 -1
  186. data/node_modules/govuk-frontend/package.json +9 -8
  187. metadata +9 -4
  188. data/app/assets/javascripts/component_guide/filter-components.js +0 -35
  189. data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss +0 -349
  190. data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss.map +0 -1
@@ -1,4 +1,4 @@
1
- const version = '5.11.2';
1
+ const version = '5.13.0';
2
2
 
3
3
  function getBreakpoint(name) {
4
4
  const property = `--govuk-breakpoint-${name}`;
@@ -423,7 +423,7 @@ class I18n {
423
423
  return 'other';
424
424
  }
425
425
  const translation = this.translations[lookupKey];
426
- const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
426
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
427
427
  if (isObject(translation)) {
428
428
  if (preferredForm in translation) {
429
429
  return preferredForm;
@@ -434,132 +434,7 @@ class I18n {
434
434
  }
435
435
  throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
436
436
  }
437
- selectPluralFormUsingFallbackRules(count) {
438
- count = Math.abs(Math.floor(count));
439
- const ruleset = this.getPluralRulesForLocale();
440
- if (ruleset) {
441
- return I18n.pluralRules[ruleset](count);
442
- }
443
- return 'other';
444
- }
445
- getPluralRulesForLocale() {
446
- const localeShort = this.locale.split('-')[0];
447
- for (const pluralRule in I18n.pluralRulesMap) {
448
- const languages = I18n.pluralRulesMap[pluralRule];
449
- if (languages.includes(this.locale) || languages.includes(localeShort)) {
450
- return pluralRule;
451
- }
452
- }
453
- }
454
437
  }
455
- I18n.pluralRulesMap = {
456
- arabic: ['ar'],
457
- chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
458
- french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
459
- german: ['af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka', 'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'],
460
- irish: ['ga'],
461
- russian: ['ru', 'uk'],
462
- scottish: ['gd'],
463
- spanish: ['pt-PT', 'it', 'es'],
464
- welsh: ['cy']
465
- };
466
- I18n.pluralRules = {
467
- arabic(n) {
468
- if (n === 0) {
469
- return 'zero';
470
- }
471
- if (n === 1) {
472
- return 'one';
473
- }
474
- if (n === 2) {
475
- return 'two';
476
- }
477
- if (n % 100 >= 3 && n % 100 <= 10) {
478
- return 'few';
479
- }
480
- if (n % 100 >= 11 && n % 100 <= 99) {
481
- return 'many';
482
- }
483
- return 'other';
484
- },
485
- chinese() {
486
- return 'other';
487
- },
488
- french(n) {
489
- return n === 0 || n === 1 ? 'one' : 'other';
490
- },
491
- german(n) {
492
- return n === 1 ? 'one' : 'other';
493
- },
494
- irish(n) {
495
- if (n === 1) {
496
- return 'one';
497
- }
498
- if (n === 2) {
499
- return 'two';
500
- }
501
- if (n >= 3 && n <= 6) {
502
- return 'few';
503
- }
504
- if (n >= 7 && n <= 10) {
505
- return 'many';
506
- }
507
- return 'other';
508
- },
509
- russian(n) {
510
- const lastTwo = n % 100;
511
- const last = lastTwo % 10;
512
- if (last === 1 && lastTwo !== 11) {
513
- return 'one';
514
- }
515
- if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
516
- return 'few';
517
- }
518
- if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
519
- return 'many';
520
- }
521
- return 'other';
522
- },
523
- scottish(n) {
524
- if (n === 1 || n === 11) {
525
- return 'one';
526
- }
527
- if (n === 2 || n === 12) {
528
- return 'two';
529
- }
530
- if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
531
- return 'few';
532
- }
533
- return 'other';
534
- },
535
- spanish(n) {
536
- if (n === 1) {
537
- return 'one';
538
- }
539
- if (n % 1000000 === 0 && n !== 0) {
540
- return 'many';
541
- }
542
- return 'other';
543
- },
544
- welsh(n) {
545
- if (n === 0) {
546
- return 'zero';
547
- }
548
- if (n === 1) {
549
- return 'one';
550
- }
551
- if (n === 2) {
552
- return 'two';
553
- }
554
- if (n === 3) {
555
- return 'few';
556
- }
557
- if (n === 6) {
558
- return 'many';
559
- }
560
- return 'other';
561
- }
562
- };
563
438
 
564
439
  /**
565
440
  * Accordion component
@@ -1795,7 +1670,7 @@ class FileUpload extends ConfigurableComponent {
1795
1670
  if (this.$button.disabled) return;
1796
1671
  if (event.target instanceof Node) {
1797
1672
  if (this.$root.contains(event.target)) {
1798
- if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
1673
+ if (event.dataTransfer && this.canDrop(event.dataTransfer)) {
1799
1674
  if (!this.$button.classList.contains('govuk-file-upload-button--dragging')) {
1800
1675
  this.showDraggingState();
1801
1676
  this.$announcements.innerText = this.i18n.t('enteredDropZone');
@@ -1817,12 +1692,30 @@ class FileUpload extends ConfigurableComponent {
1817
1692
  }
1818
1693
  onDrop(event) {
1819
1694
  event.preventDefault();
1820
- if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
1695
+ if (event.dataTransfer && this.canFillInput(event.dataTransfer)) {
1821
1696
  this.$input.files = event.dataTransfer.files;
1822
1697
  this.$input.dispatchEvent(new CustomEvent('change'));
1823
1698
  this.hideDraggingState();
1824
1699
  }
1825
1700
  }
1701
+ canFillInput(dataTransfer) {
1702
+ return this.matchesInputCapacity(dataTransfer.files.length);
1703
+ }
1704
+ canDrop(dataTransfer) {
1705
+ if (dataTransfer.items.length) {
1706
+ return this.matchesInputCapacity(countFileItems(dataTransfer.items));
1707
+ }
1708
+ if (dataTransfer.types.length) {
1709
+ return dataTransfer.types.includes('Files');
1710
+ }
1711
+ return true;
1712
+ }
1713
+ matchesInputCapacity(numberOfFiles) {
1714
+ if (this.$input.multiple) {
1715
+ return numberOfFiles > 0;
1716
+ }
1717
+ return numberOfFiles === 1;
1718
+ }
1826
1719
  onChange() {
1827
1720
  const fileCount = this.$input.files.length;
1828
1721
  if (fileCount === 0) {
@@ -1869,6 +1762,13 @@ class FileUpload extends ConfigurableComponent {
1869
1762
  this.$root.classList.toggle('govuk-drop-zone--disabled', this.$button.disabled);
1870
1763
  }
1871
1764
  }
1765
+
1766
+ /**
1767
+ * Counts the number of `DataTransferItem` whose kind is `file`
1768
+ *
1769
+ * @param {DataTransferItemList} list - The list
1770
+ * @returns {number} - The number of items whose kind is `file` in the list
1771
+ */
1872
1772
  FileUpload.moduleName = 'govuk-file-upload';
1873
1773
  FileUpload.defaults = Object.freeze({
1874
1774
  i18n: {
@@ -1890,10 +1790,14 @@ FileUpload.schema = Object.freeze({
1890
1790
  }
1891
1791
  }
1892
1792
  });
1893
- function isContainingFiles(dataTransfer) {
1894
- const hasNoTypesInfo = dataTransfer.types.length === 0;
1895
- const isDraggingFiles = dataTransfer.types.some(type => type === 'Files');
1896
- return hasNoTypesInfo || isDraggingFiles;
1793
+ function countFileItems(list) {
1794
+ let result = 0;
1795
+ for (let i = 0; i < list.length; i++) {
1796
+ if (list[i].kind === 'file') {
1797
+ result++;
1798
+ }
1799
+ }
1800
+ return result;
1897
1801
  }
1898
1802
 
1899
1803
  /**