govuk_tech_docs 5.2.2 → 6.0.0.beta
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/.ruby-version +1 -0
- data/CHANGELOG.md +15 -0
- data/README.md +11 -3
- data/example/config/tech-docs.yml +1 -1
- data/govuk_tech_docs.gemspec +1 -1
- data/lib/assets/stylesheets/_core.scss +1 -0
- data/lib/assets/stylesheets/_govuk_tech_docs.scss +13 -15
- data/lib/assets/stylesheets/modules/_app-pane.scss +3 -3
- data/lib/assets/stylesheets/modules/_page-review.scss +4 -4
- data/lib/assets/stylesheets/modules/_search.scss +3 -3
- data/lib/assets/stylesheets/modules/_service-navigation.scss +5 -0
- data/lib/assets/stylesheets/modules/_technical-documentation.scss +7 -7
- data/lib/assets/stylesheets/modules/_toc.scss +13 -13
- data/lib/assets/stylesheets/palette/_syntax-highlighting.scss +9 -7
- data/lib/govuk_tech_docs/meta_tags.rb +1 -1
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/source/layouts/_header.erb +2 -16
- data/lib/source/layouts/_service_navigation.erb +27 -0
- data/lib/source/layouts/core.erb +7 -7
- data/node_modules/govuk-frontend/dist/govuk/_base.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +87 -229
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +88 -229
- data/node_modules/govuk-frontend/dist/govuk/all.mjs +0 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.ico +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.svg +1 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-180.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-192.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-512.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-opengraph-image.png +0 -0
- 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 +18 -15
- 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.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/back-link/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +18 -21
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +20 -135
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +20 -135
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +19 -9
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +7 -6
- data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +2 -5
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +5 -0
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +6 -4
- data/node_modules/govuk-frontend/dist/govuk/components/error-message/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +4 -2
- 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/exit-this-page.bundle.js +1 -126
- 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/file-upload/_index.scss +30 -38
- 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.mjs +36 -132
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +35 -6
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +30 -27
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +89 -449
- data/node_modules/govuk-frontend/dist/govuk/components/hint/_index.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +14 -20
- data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_index.scss +2 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +10 -8
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +12 -11
- data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +4 -4
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +2 -2
- 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.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +12 -6
- data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +8 -7
- data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +6 -11
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +55 -76
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +30 -2
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +30 -2
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +30 -2
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +7 -2
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +25 -21
- data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +7 -8
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +9 -6
- data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +66 -31
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +7 -5
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +5 -10
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +5 -4
- data/node_modules/govuk-frontend/dist/govuk/core/_index.scss +0 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/core/_section-break.scss +2 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +6 -20
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_breakpoints.scss +17 -0
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.scss +15 -0
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss +17 -0
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_index.scss +5 -0
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +168 -82
- data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +41 -6
- data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +24 -40
- data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +172 -33
- data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +6 -30
- data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +1 -126
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +1 -2
- data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_form-group.scss +2 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +3 -7
- data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +0 -2
- data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +5 -5
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss +3 -188
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-functional.scss +366 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +9 -255
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-palette.scss +117 -25
- data/node_modules/govuk-frontend/dist/govuk/settings/_custom-properties.scss +18 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_index.scss +3 -14
- data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss +0 -9
- data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +12 -189
- data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +0 -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-rem.scss +2 -0
- data/package-lock.json +3228 -4
- data/package.json +1 -1
- metadata +10 -26
- data/node_modules/govuk-frontend/dist/govuk/all.scss +0 -9
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.ico +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.svg +0 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-crest.svg +0 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-180.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-192.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-512.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-mask.svg +0 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-opengraph-image.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/manifest.json +0 -39
- data/node_modules/govuk-frontend/dist/govuk/components/_all.scss +0 -10
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +0 -238
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +0 -230
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +0 -89
- data/node_modules/govuk-frontend/dist/govuk/core/_all.scss +0 -10
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +0 -15
- data/node_modules/govuk-frontend/dist/govuk/helpers/_all.scss +0 -10
- data/node_modules/govuk-frontend/dist/govuk/objects/_all.scss +0 -10
- data/node_modules/govuk-frontend/dist/govuk/overrides/_all.scss +0 -9
- data/node_modules/govuk-frontend/dist/govuk/settings/_all.scss +0 -10
- data/node_modules/govuk-frontend/dist/govuk/tools/_all.scss +0 -10
- data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss +0 -65
- data/node_modules/govuk-frontend/dist/govuk/utilities/_all.scss +0 -10
- data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss +0 -349
- data/node_modules/govuk-frontend/dist/govuk-prototype-kit/functions.js +0 -25
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = global.GOVUKFrontend || {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const version = '
|
|
7
|
+
const version = '6.0.0';
|
|
8
8
|
|
|
9
9
|
function getBreakpoint(name) {
|
|
10
10
|
const property = `--govuk-breakpoint-${name}`;
|
|
@@ -429,7 +429,7 @@
|
|
|
429
429
|
return 'other';
|
|
430
430
|
}
|
|
431
431
|
const translation = this.translations[lookupKey];
|
|
432
|
-
const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) :
|
|
432
|
+
const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
|
|
433
433
|
if (isObject(translation)) {
|
|
434
434
|
if (preferredForm in translation) {
|
|
435
435
|
return preferredForm;
|
|
@@ -440,132 +440,7 @@
|
|
|
440
440
|
}
|
|
441
441
|
throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
|
|
442
442
|
}
|
|
443
|
-
selectPluralFormUsingFallbackRules(count) {
|
|
444
|
-
count = Math.abs(Math.floor(count));
|
|
445
|
-
const ruleset = this.getPluralRulesForLocale();
|
|
446
|
-
if (ruleset) {
|
|
447
|
-
return I18n.pluralRules[ruleset](count);
|
|
448
|
-
}
|
|
449
|
-
return 'other';
|
|
450
|
-
}
|
|
451
|
-
getPluralRulesForLocale() {
|
|
452
|
-
const localeShort = this.locale.split('-')[0];
|
|
453
|
-
for (const pluralRule in I18n.pluralRulesMap) {
|
|
454
|
-
const languages = I18n.pluralRulesMap[pluralRule];
|
|
455
|
-
if (languages.includes(this.locale) || languages.includes(localeShort)) {
|
|
456
|
-
return pluralRule;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
443
|
}
|
|
461
|
-
I18n.pluralRulesMap = {
|
|
462
|
-
arabic: ['ar'],
|
|
463
|
-
chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
|
|
464
|
-
french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
|
|
465
|
-
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'],
|
|
466
|
-
irish: ['ga'],
|
|
467
|
-
russian: ['ru', 'uk'],
|
|
468
|
-
scottish: ['gd'],
|
|
469
|
-
spanish: ['pt-PT', 'it', 'es'],
|
|
470
|
-
welsh: ['cy']
|
|
471
|
-
};
|
|
472
|
-
I18n.pluralRules = {
|
|
473
|
-
arabic(n) {
|
|
474
|
-
if (n === 0) {
|
|
475
|
-
return 'zero';
|
|
476
|
-
}
|
|
477
|
-
if (n === 1) {
|
|
478
|
-
return 'one';
|
|
479
|
-
}
|
|
480
|
-
if (n === 2) {
|
|
481
|
-
return 'two';
|
|
482
|
-
}
|
|
483
|
-
if (n % 100 >= 3 && n % 100 <= 10) {
|
|
484
|
-
return 'few';
|
|
485
|
-
}
|
|
486
|
-
if (n % 100 >= 11 && n % 100 <= 99) {
|
|
487
|
-
return 'many';
|
|
488
|
-
}
|
|
489
|
-
return 'other';
|
|
490
|
-
},
|
|
491
|
-
chinese() {
|
|
492
|
-
return 'other';
|
|
493
|
-
},
|
|
494
|
-
french(n) {
|
|
495
|
-
return n === 0 || n === 1 ? 'one' : 'other';
|
|
496
|
-
},
|
|
497
|
-
german(n) {
|
|
498
|
-
return n === 1 ? 'one' : 'other';
|
|
499
|
-
},
|
|
500
|
-
irish(n) {
|
|
501
|
-
if (n === 1) {
|
|
502
|
-
return 'one';
|
|
503
|
-
}
|
|
504
|
-
if (n === 2) {
|
|
505
|
-
return 'two';
|
|
506
|
-
}
|
|
507
|
-
if (n >= 3 && n <= 6) {
|
|
508
|
-
return 'few';
|
|
509
|
-
}
|
|
510
|
-
if (n >= 7 && n <= 10) {
|
|
511
|
-
return 'many';
|
|
512
|
-
}
|
|
513
|
-
return 'other';
|
|
514
|
-
},
|
|
515
|
-
russian(n) {
|
|
516
|
-
const lastTwo = n % 100;
|
|
517
|
-
const last = lastTwo % 10;
|
|
518
|
-
if (last === 1 && lastTwo !== 11) {
|
|
519
|
-
return 'one';
|
|
520
|
-
}
|
|
521
|
-
if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
|
|
522
|
-
return 'few';
|
|
523
|
-
}
|
|
524
|
-
if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
|
|
525
|
-
return 'many';
|
|
526
|
-
}
|
|
527
|
-
return 'other';
|
|
528
|
-
},
|
|
529
|
-
scottish(n) {
|
|
530
|
-
if (n === 1 || n === 11) {
|
|
531
|
-
return 'one';
|
|
532
|
-
}
|
|
533
|
-
if (n === 2 || n === 12) {
|
|
534
|
-
return 'two';
|
|
535
|
-
}
|
|
536
|
-
if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
|
|
537
|
-
return 'few';
|
|
538
|
-
}
|
|
539
|
-
return 'other';
|
|
540
|
-
},
|
|
541
|
-
spanish(n) {
|
|
542
|
-
if (n === 1) {
|
|
543
|
-
return 'one';
|
|
544
|
-
}
|
|
545
|
-
if (n % 1000000 === 0 && n !== 0) {
|
|
546
|
-
return 'many';
|
|
547
|
-
}
|
|
548
|
-
return 'other';
|
|
549
|
-
},
|
|
550
|
-
welsh(n) {
|
|
551
|
-
if (n === 0) {
|
|
552
|
-
return 'zero';
|
|
553
|
-
}
|
|
554
|
-
if (n === 1) {
|
|
555
|
-
return 'one';
|
|
556
|
-
}
|
|
557
|
-
if (n === 2) {
|
|
558
|
-
return 'two';
|
|
559
|
-
}
|
|
560
|
-
if (n === 3) {
|
|
561
|
-
return 'few';
|
|
562
|
-
}
|
|
563
|
-
if (n === 6) {
|
|
564
|
-
return 'many';
|
|
565
|
-
}
|
|
566
|
-
return 'other';
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
444
|
|
|
570
445
|
/**
|
|
571
446
|
* Accordion component
|
|
@@ -1011,6 +886,7 @@
|
|
|
1011
886
|
var _ref, _this$config$maxwords;
|
|
1012
887
|
super($root, config);
|
|
1013
888
|
this.$textarea = void 0;
|
|
889
|
+
this.count = 0;
|
|
1014
890
|
this.$visibleCountMessage = void 0;
|
|
1015
891
|
this.$screenReaderCountMessage = void 0;
|
|
1016
892
|
this.lastInputTimestamp = null;
|
|
@@ -1066,15 +942,22 @@
|
|
|
1066
942
|
$textareaDescription.classList.add('govuk-visually-hidden');
|
|
1067
943
|
this.$textarea.removeAttribute('maxlength');
|
|
1068
944
|
this.bindChangeEvents();
|
|
1069
|
-
window.addEventListener('pageshow', () =>
|
|
945
|
+
window.addEventListener('pageshow', () => {
|
|
946
|
+
if (this.$textarea.value !== this.$textarea.textContent) {
|
|
947
|
+
this.updateCount();
|
|
948
|
+
this.updateCountMessage();
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
this.updateCount();
|
|
1070
952
|
this.updateCountMessage();
|
|
1071
953
|
}
|
|
1072
954
|
bindChangeEvents() {
|
|
1073
|
-
this.$textarea.addEventListener('
|
|
955
|
+
this.$textarea.addEventListener('input', () => this.handleInput());
|
|
1074
956
|
this.$textarea.addEventListener('focus', () => this.handleFocus());
|
|
1075
957
|
this.$textarea.addEventListener('blur', () => this.handleBlur());
|
|
1076
958
|
}
|
|
1077
|
-
|
|
959
|
+
handleInput() {
|
|
960
|
+
this.updateCount();
|
|
1078
961
|
this.updateVisibleCountMessage();
|
|
1079
962
|
this.lastInputTimestamp = Date.now();
|
|
1080
963
|
}
|
|
@@ -1101,7 +984,7 @@
|
|
|
1101
984
|
this.updateScreenReaderCountMessage();
|
|
1102
985
|
}
|
|
1103
986
|
updateVisibleCountMessage() {
|
|
1104
|
-
const remainingNumber = this.maxLength - this.count
|
|
987
|
+
const remainingNumber = this.maxLength - this.count;
|
|
1105
988
|
const isError = remainingNumber < 0;
|
|
1106
989
|
this.$visibleCountMessage.classList.toggle('govuk-character-count__message--disabled', !this.isOverThreshold());
|
|
1107
990
|
if (!this.$errorMessage) {
|
|
@@ -1119,16 +1002,18 @@
|
|
|
1119
1002
|
}
|
|
1120
1003
|
this.$screenReaderCountMessage.textContent = this.getCountMessage();
|
|
1121
1004
|
}
|
|
1122
|
-
|
|
1005
|
+
updateCount() {
|
|
1006
|
+
const text = this.$textarea.value;
|
|
1123
1007
|
if (this.config.maxwords) {
|
|
1124
1008
|
var _text$match;
|
|
1125
1009
|
const tokens = (_text$match = text.match(/\S+/g)) != null ? _text$match : [];
|
|
1126
|
-
|
|
1010
|
+
this.count = tokens.length;
|
|
1011
|
+
return;
|
|
1127
1012
|
}
|
|
1128
|
-
|
|
1013
|
+
this.count = text.length;
|
|
1129
1014
|
}
|
|
1130
1015
|
getCountMessage() {
|
|
1131
|
-
const remainingNumber = this.maxLength - this.count
|
|
1016
|
+
const remainingNumber = this.maxLength - this.count;
|
|
1132
1017
|
const countType = this.config.maxwords ? 'words' : 'characters';
|
|
1133
1018
|
return this.formatCountMessage(remainingNumber, countType);
|
|
1134
1019
|
}
|
|
@@ -1145,7 +1030,7 @@
|
|
|
1145
1030
|
if (!this.config.threshold) {
|
|
1146
1031
|
return true;
|
|
1147
1032
|
}
|
|
1148
|
-
const currentLength = this.count
|
|
1033
|
+
const currentLength = this.count;
|
|
1149
1034
|
const maxLength = this.maxLength;
|
|
1150
1035
|
const thresholdValue = maxLength * this.config.threshold / 100;
|
|
1151
1036
|
return thresholdValue <= currentLength;
|
|
@@ -1801,7 +1686,7 @@
|
|
|
1801
1686
|
if (this.$button.disabled) return;
|
|
1802
1687
|
if (event.target instanceof Node) {
|
|
1803
1688
|
if (this.$root.contains(event.target)) {
|
|
1804
|
-
if (event.dataTransfer &&
|
|
1689
|
+
if (event.dataTransfer && this.canDrop(event.dataTransfer)) {
|
|
1805
1690
|
if (!this.$button.classList.contains('govuk-file-upload-button--dragging')) {
|
|
1806
1691
|
this.showDraggingState();
|
|
1807
1692
|
this.$announcements.innerText = this.i18n.t('enteredDropZone');
|
|
@@ -1823,12 +1708,30 @@
|
|
|
1823
1708
|
}
|
|
1824
1709
|
onDrop(event) {
|
|
1825
1710
|
event.preventDefault();
|
|
1826
|
-
if (event.dataTransfer &&
|
|
1711
|
+
if (event.dataTransfer && this.canFillInput(event.dataTransfer)) {
|
|
1827
1712
|
this.$input.files = event.dataTransfer.files;
|
|
1828
1713
|
this.$input.dispatchEvent(new CustomEvent('change'));
|
|
1829
1714
|
this.hideDraggingState();
|
|
1830
1715
|
}
|
|
1831
1716
|
}
|
|
1717
|
+
canFillInput(dataTransfer) {
|
|
1718
|
+
return this.matchesInputCapacity(dataTransfer.files.length);
|
|
1719
|
+
}
|
|
1720
|
+
canDrop(dataTransfer) {
|
|
1721
|
+
if (dataTransfer.items.length) {
|
|
1722
|
+
return this.matchesInputCapacity(countFileItems(dataTransfer.items));
|
|
1723
|
+
}
|
|
1724
|
+
if (dataTransfer.types.length) {
|
|
1725
|
+
return dataTransfer.types.includes('Files');
|
|
1726
|
+
}
|
|
1727
|
+
return true;
|
|
1728
|
+
}
|
|
1729
|
+
matchesInputCapacity(numberOfFiles) {
|
|
1730
|
+
if (this.$input.multiple) {
|
|
1731
|
+
return numberOfFiles > 0;
|
|
1732
|
+
}
|
|
1733
|
+
return numberOfFiles === 1;
|
|
1734
|
+
}
|
|
1832
1735
|
onChange() {
|
|
1833
1736
|
const fileCount = this.$input.files.length;
|
|
1834
1737
|
if (fileCount === 0) {
|
|
@@ -1875,6 +1778,13 @@
|
|
|
1875
1778
|
this.$root.classList.toggle('govuk-drop-zone--disabled', this.$button.disabled);
|
|
1876
1779
|
}
|
|
1877
1780
|
}
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* Counts the number of `DataTransferItem` whose kind is `file`
|
|
1784
|
+
*
|
|
1785
|
+
* @param {DataTransferItemList} list - The list
|
|
1786
|
+
* @returns {number} - The number of items whose kind is `file` in the list
|
|
1787
|
+
*/
|
|
1878
1788
|
FileUpload.moduleName = 'govuk-file-upload';
|
|
1879
1789
|
FileUpload.defaults = Object.freeze({
|
|
1880
1790
|
i18n: {
|
|
@@ -1896,10 +1806,14 @@
|
|
|
1896
1806
|
}
|
|
1897
1807
|
}
|
|
1898
1808
|
});
|
|
1899
|
-
function
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1809
|
+
function countFileItems(list) {
|
|
1810
|
+
let result = 0;
|
|
1811
|
+
for (let i = 0; i < list.length; i++) {
|
|
1812
|
+
if (list[i].kind === 'file') {
|
|
1813
|
+
result++;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
return result;
|
|
1903
1817
|
}
|
|
1904
1818
|
|
|
1905
1819
|
/**
|
|
@@ -1937,89 +1851,6 @@
|
|
|
1937
1851
|
* @import { TranslationPluralForms } from '../../i18n.mjs'
|
|
1938
1852
|
*/
|
|
1939
1853
|
|
|
1940
|
-
/**
|
|
1941
|
-
* Header component
|
|
1942
|
-
*
|
|
1943
|
-
* @preserve
|
|
1944
|
-
*/
|
|
1945
|
-
class Header extends Component {
|
|
1946
|
-
/**
|
|
1947
|
-
* Apply a matchMedia for desktop which will trigger a state sync if the
|
|
1948
|
-
* browser viewport moves between states.
|
|
1949
|
-
*
|
|
1950
|
-
* @param {Element | null} $root - HTML element to use for header
|
|
1951
|
-
*/
|
|
1952
|
-
constructor($root) {
|
|
1953
|
-
super($root);
|
|
1954
|
-
this.$menuButton = void 0;
|
|
1955
|
-
this.$menu = void 0;
|
|
1956
|
-
this.menuIsOpen = false;
|
|
1957
|
-
this.mql = null;
|
|
1958
|
-
const $menuButton = this.$root.querySelector('.govuk-js-header-toggle');
|
|
1959
|
-
if (!$menuButton) {
|
|
1960
|
-
return this;
|
|
1961
|
-
}
|
|
1962
|
-
this.$root.classList.add('govuk-header--with-js-navigation');
|
|
1963
|
-
const menuId = $menuButton.getAttribute('aria-controls');
|
|
1964
|
-
if (!menuId) {
|
|
1965
|
-
throw new ElementError({
|
|
1966
|
-
component: Header,
|
|
1967
|
-
identifier: 'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
|
-
const $menu = document.getElementById(menuId);
|
|
1971
|
-
if (!$menu) {
|
|
1972
|
-
throw new ElementError({
|
|
1973
|
-
component: Header,
|
|
1974
|
-
element: $menu,
|
|
1975
|
-
identifier: `Navigation (\`<ul id="${menuId}">\`)`
|
|
1976
|
-
});
|
|
1977
|
-
}
|
|
1978
|
-
this.$menu = $menu;
|
|
1979
|
-
this.$menuButton = $menuButton;
|
|
1980
|
-
this.setupResponsiveChecks();
|
|
1981
|
-
this.$menuButton.addEventListener('click', () => this.handleMenuButtonClick());
|
|
1982
|
-
}
|
|
1983
|
-
setupResponsiveChecks() {
|
|
1984
|
-
const breakpoint = getBreakpoint('desktop');
|
|
1985
|
-
if (!breakpoint.value) {
|
|
1986
|
-
throw new ElementError({
|
|
1987
|
-
component: Header,
|
|
1988
|
-
identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
|
|
1989
|
-
});
|
|
1990
|
-
}
|
|
1991
|
-
this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`);
|
|
1992
|
-
if ('addEventListener' in this.mql) {
|
|
1993
|
-
this.mql.addEventListener('change', () => this.checkMode());
|
|
1994
|
-
} else {
|
|
1995
|
-
this.mql.addListener(() => this.checkMode());
|
|
1996
|
-
}
|
|
1997
|
-
this.checkMode();
|
|
1998
|
-
}
|
|
1999
|
-
checkMode() {
|
|
2000
|
-
if (!this.mql || !this.$menu || !this.$menuButton) {
|
|
2001
|
-
return;
|
|
2002
|
-
}
|
|
2003
|
-
if (this.mql.matches) {
|
|
2004
|
-
this.$menu.removeAttribute('hidden');
|
|
2005
|
-
this.$menuButton.setAttribute('hidden', '');
|
|
2006
|
-
} else {
|
|
2007
|
-
this.$menuButton.removeAttribute('hidden');
|
|
2008
|
-
this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString());
|
|
2009
|
-
if (this.menuIsOpen) {
|
|
2010
|
-
this.$menu.removeAttribute('hidden');
|
|
2011
|
-
} else {
|
|
2012
|
-
this.$menu.setAttribute('hidden', '');
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
handleMenuButtonClick() {
|
|
2017
|
-
this.menuIsOpen = !this.menuIsOpen;
|
|
2018
|
-
this.checkMode();
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
Header.moduleName = 'govuk-header';
|
|
2022
|
-
|
|
2023
1854
|
/**
|
|
2024
1855
|
* Notification Banner component
|
|
2025
1856
|
*
|
|
@@ -2351,9 +2182,9 @@
|
|
|
2351
2182
|
}
|
|
2352
2183
|
if (this.mql.matches) {
|
|
2353
2184
|
this.$menu.removeAttribute('hidden');
|
|
2354
|
-
this.$menuButton
|
|
2185
|
+
setAttributes(this.$menuButton, attributesForHidingButton);
|
|
2355
2186
|
} else {
|
|
2356
|
-
this.$menuButton.
|
|
2187
|
+
removeAttributes(this.$menuButton, Object.keys(attributesForHidingButton));
|
|
2357
2188
|
this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString());
|
|
2358
2189
|
if (this.menuIsOpen) {
|
|
2359
2190
|
this.$menu.removeAttribute('hidden');
|
|
@@ -2368,6 +2199,34 @@
|
|
|
2368
2199
|
}
|
|
2369
2200
|
}
|
|
2370
2201
|
ServiceNavigation.moduleName = 'govuk-service-navigation';
|
|
2202
|
+
const attributesForHidingButton = {
|
|
2203
|
+
hidden: '',
|
|
2204
|
+
'aria-hidden': 'true'
|
|
2205
|
+
};
|
|
2206
|
+
|
|
2207
|
+
/**
|
|
2208
|
+
* Sets a group of attributes on the given element
|
|
2209
|
+
*
|
|
2210
|
+
* @param {Element} $element - The element to set the attribute on
|
|
2211
|
+
* @param {{[attributeName: string]: string}} attributes - The attributes to set
|
|
2212
|
+
*/
|
|
2213
|
+
function setAttributes($element, attributes) {
|
|
2214
|
+
for (const attributeName in attributes) {
|
|
2215
|
+
$element.setAttribute(attributeName, attributes[attributeName]);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
/**
|
|
2220
|
+
* Removes a list of attributes from the given element
|
|
2221
|
+
*
|
|
2222
|
+
* @param {Element} $element - The element to remove the attributes from
|
|
2223
|
+
* @param {string[]} attributeNames - The names of the attributes to remove
|
|
2224
|
+
*/
|
|
2225
|
+
function removeAttributes($element, attributeNames) {
|
|
2226
|
+
for (const attributeName of attributeNames) {
|
|
2227
|
+
$element.removeAttribute(attributeName);
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2371
2230
|
|
|
2372
2231
|
/**
|
|
2373
2232
|
* Skip link component
|
|
@@ -2723,7 +2582,7 @@
|
|
|
2723
2582
|
}
|
|
2724
2583
|
return;
|
|
2725
2584
|
}
|
|
2726
|
-
const components = [[Accordion, config.accordion], [Button, config.button], [CharacterCount, config.characterCount], [Checkboxes], [ErrorSummary, config.errorSummary], [ExitThisPage, config.exitThisPage], [FileUpload, config.fileUpload], [
|
|
2585
|
+
const components = [[Accordion, config.accordion], [Button, config.button], [CharacterCount, config.characterCount], [Checkboxes], [ErrorSummary, config.errorSummary], [ExitThisPage, config.exitThisPage], [FileUpload, config.fileUpload], [NotificationBanner, config.notificationBanner], [PasswordInput, config.passwordInput], [Radios], [ServiceNavigation], [SkipLink], [Tabs]];
|
|
2727
2586
|
components.forEach(([Component, componentConfig]) => {
|
|
2728
2587
|
createAll(Component, componentConfig, options);
|
|
2729
2588
|
});
|
|
@@ -2856,7 +2715,6 @@
|
|
|
2856
2715
|
exports.ErrorSummary = ErrorSummary;
|
|
2857
2716
|
exports.ExitThisPage = ExitThisPage;
|
|
2858
2717
|
exports.FileUpload = FileUpload;
|
|
2859
|
-
exports.Header = Header;
|
|
2860
2718
|
exports.NotificationBanner = NotificationBanner;
|
|
2861
2719
|
exports.PasswordInput = PasswordInput;
|
|
2862
2720
|
exports.Radios = Radios;
|