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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/option-select.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/lib/filter-list.js +48 -0
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +373 -245
- data/app/assets/stylesheets/component_guide/application.scss +1 -42
- data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +5 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +6 -11
- data/app/assets/stylesheets/govuk_publishing_components/components/_option-select.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +6 -38
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_warning-callout.scss +2 -3
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +6 -1
- data/app/controllers/govuk_publishing_components/applications_page_controller.rb +50 -0
- data/app/models/govuk_publishing_components/applications_page.rb +64 -0
- data/app/views/govuk_publishing_components/applications_page/_table-content.html.erb +39 -0
- data/app/views/govuk_publishing_components/applications_page/show.html.erb +37 -0
- data/app/views/govuk_publishing_components/audit/show.html.erb +5 -1
- data/app/views/govuk_publishing_components/component_guide/_component_list.html.erb +14 -0
- data/app/views/govuk_publishing_components/component_guide/example.html.erb +3 -3
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +50 -75
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +7 -7
- data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +27 -25
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +7 -1
- data/config/routes.rb +1 -0
- data/lib/govuk_publishing_components/minitest/component_guide_test.rb +1 -1
- data/lib/govuk_publishing_components/presenters/organisation_logo_helper.rb +7 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +37 -133
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +37 -133
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +4 -4
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/fixtures.json +34 -29
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/macro-options.json +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-default.html +23 -23
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-conditional-reveal.html +21 -21
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-divider-and-none.html +30 -30
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-error.html +26 -26
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-hint.html +25 -25
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-long-text.html +23 -23
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small.html +23 -23
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-conditional-items.html +35 -35
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-divider-and-none.html +30 -30
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-divider-none-and-conditional-items.html +40 -40
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-error-message.html +32 -32
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-hint.html +25 -25
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-hints-on-items.html +21 -21
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-legend-as-a-page-heading.html +27 -27
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-optional-form-group-classes-showing-group-error.html +36 -36
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-pre-checked-values.html +35 -35
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-very-long-option-text.html +25 -25
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template.njk +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +2 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +36 -132
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +36 -132
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +35 -6
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/fixtures.json +17 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced-multiple-files.html +10 -0
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +4 -4
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +20 -20
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +7 -15
- data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +4 -2
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/fixtures.json +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-many-pages.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/template.njk +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/fixtures.json +36 -31
- data/node_modules/govuk-frontend/dist/govuk/components/radios/macro-options.json +3 -3
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-default.html +17 -17
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-inline.html +19 -19
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-inline.html +23 -23
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-a-divider.html +24 -24
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-conditional-reveal.html +27 -27
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-error.html +26 -26
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-hint.html +25 -25
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-long-text.html +23 -23
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small.html +23 -23
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-a-divider.html +24 -24
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-item-checked.html +35 -35
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-items-and-pre-checked-value.html +35 -35
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-items.html +35 -35
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-fieldset-and-error-message.html +20 -20
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-hint.html +19 -19
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-hints-on-items.html +23 -23
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-legend-as-page-heading.html +21 -21
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-optional-form-group-classes-showing-group-error.html +36 -36
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-very-long-option-text.html +28 -28
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template.njk +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +1 -7
- data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +5 -5
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +16 -16
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/fixtures.json +46 -0
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-forced-hover-state.html +37 -0
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +1 -7
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +3 -3
- data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +34 -0
- data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +172 -33
- data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +4 -4
- data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/i18n.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +5 -5
- data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss +7 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss +4 -2
- data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss.map +1 -1
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +1 -1
- data/node_modules/govuk-frontend/package.json +9 -8
- metadata +9 -4
- data/app/assets/javascripts/component_guide/filter-components.js +0 -35
- data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss +0 -349
- data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = '5.
|
|
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) :
|
|
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 &&
|
|
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 &&
|
|
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
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
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
|
/**
|