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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +15 -0
  4. data/README.md +11 -3
  5. data/example/config/tech-docs.yml +1 -1
  6. data/govuk_tech_docs.gemspec +1 -1
  7. data/lib/assets/stylesheets/_core.scss +1 -0
  8. data/lib/assets/stylesheets/_govuk_tech_docs.scss +13 -15
  9. data/lib/assets/stylesheets/modules/_app-pane.scss +3 -3
  10. data/lib/assets/stylesheets/modules/_page-review.scss +4 -4
  11. data/lib/assets/stylesheets/modules/_search.scss +3 -3
  12. data/lib/assets/stylesheets/modules/_service-navigation.scss +5 -0
  13. data/lib/assets/stylesheets/modules/_technical-documentation.scss +7 -7
  14. data/lib/assets/stylesheets/modules/_toc.scss +13 -13
  15. data/lib/assets/stylesheets/palette/_syntax-highlighting.scss +9 -7
  16. data/lib/govuk_tech_docs/meta_tags.rb +1 -1
  17. data/lib/govuk_tech_docs/version.rb +1 -1
  18. data/lib/source/layouts/_header.erb +2 -16
  19. data/lib/source/layouts/_service_navigation.erb +27 -0
  20. data/lib/source/layouts/core.erb +7 -7
  21. data/node_modules/govuk-frontend/dist/govuk/_base.scss +1 -0
  22. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +87 -229
  23. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +88 -229
  24. data/node_modules/govuk-frontend/dist/govuk/all.mjs +0 -1
  25. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.ico +0 -0
  26. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.svg +1 -1
  27. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-180.png +0 -0
  28. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-192.png +0 -0
  29. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-512.png +0 -0
  30. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-opengraph-image.png +0 -0
  31. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  32. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +18 -15
  33. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +1 -126
  34. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +1 -126
  35. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_index.scss +2 -2
  36. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +2 -2
  37. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +18 -21
  38. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +2 -2
  39. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +20 -135
  40. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +20 -135
  41. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +19 -9
  42. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +7 -6
  43. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +2 -5
  44. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +5 -0
  45. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +6 -4
  46. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_index.scss +1 -1
  47. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +4 -2
  48. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss +1 -1
  49. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +1 -126
  50. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +1 -126
  51. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +30 -38
  52. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +36 -132
  53. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +36 -132
  54. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +35 -6
  55. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +30 -27
  56. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +89 -449
  57. data/node_modules/govuk-frontend/dist/govuk/components/hint/_index.scss +1 -1
  58. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +14 -20
  59. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_index.scss +2 -1
  60. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +10 -8
  61. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +12 -11
  62. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +4 -4
  63. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +2 -2
  64. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +1 -126
  65. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +1 -126
  66. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +12 -6
  67. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +8 -7
  68. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +6 -11
  69. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +55 -76
  70. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +30 -2
  71. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +30 -2
  72. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +30 -2
  73. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +7 -2
  74. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +25 -21
  75. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +7 -8
  76. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +9 -6
  77. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +66 -31
  78. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +7 -5
  79. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +5 -10
  80. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +5 -4
  81. data/node_modules/govuk-frontend/dist/govuk/core/_index.scss +0 -1
  82. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +2 -2
  83. data/node_modules/govuk-frontend/dist/govuk/core/_section-break.scss +2 -1
  84. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +6 -20
  85. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_breakpoints.scss +17 -0
  86. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.scss +15 -0
  87. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss +17 -0
  88. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_index.scss +5 -0
  89. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  90. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +168 -82
  91. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +41 -6
  92. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
  93. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +24 -40
  94. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +172 -33
  95. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +1 -1
  96. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +6 -30
  97. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +1 -126
  98. data/node_modules/govuk-frontend/dist/govuk/init.mjs +1 -2
  99. data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss +1 -1
  100. data/node_modules/govuk-frontend/dist/govuk/objects/_form-group.scss +2 -1
  101. data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss +1 -1
  102. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +3 -7
  103. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +2 -2
  104. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +1 -1
  105. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +0 -2
  106. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +5 -5
  107. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss +3 -188
  108. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-functional.scss +366 -0
  109. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +9 -255
  110. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-palette.scss +117 -25
  111. data/node_modules/govuk-frontend/dist/govuk/settings/_custom-properties.scss +18 -0
  112. data/node_modules/govuk-frontend/dist/govuk/settings/_index.scss +3 -14
  113. data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss +0 -9
  114. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +12 -189
  115. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +0 -1
  116. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss +4 -2
  117. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-rem.scss +2 -0
  118. data/package-lock.json +3228 -4
  119. data/package.json +1 -1
  120. metadata +10 -26
  121. data/node_modules/govuk-frontend/dist/govuk/all.scss +0 -9
  122. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.ico +0 -0
  123. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.svg +0 -1
  124. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-crest.svg +0 -1
  125. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-180.png +0 -0
  126. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-192.png +0 -0
  127. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-512.png +0 -0
  128. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-mask.svg +0 -1
  129. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-opengraph-image.png +0 -0
  130. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/manifest.json +0 -39
  131. data/node_modules/govuk-frontend/dist/govuk/components/_all.scss +0 -10
  132. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +0 -238
  133. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +0 -230
  134. data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +0 -89
  135. data/node_modules/govuk-frontend/dist/govuk/core/_all.scss +0 -10
  136. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +0 -15
  137. data/node_modules/govuk-frontend/dist/govuk/helpers/_all.scss +0 -10
  138. data/node_modules/govuk-frontend/dist/govuk/objects/_all.scss +0 -10
  139. data/node_modules/govuk-frontend/dist/govuk/overrides/_all.scss +0 -9
  140. data/node_modules/govuk-frontend/dist/govuk/settings/_all.scss +0 -10
  141. data/node_modules/govuk-frontend/dist/govuk/tools/_all.scss +0 -10
  142. data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss +0 -65
  143. data/node_modules/govuk-frontend/dist/govuk/utilities/_all.scss +0 -10
  144. data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss +0 -349
  145. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/functions.js +0 -25
@@ -367,7 +367,7 @@ class I18n {
367
367
  return 'other';
368
368
  }
369
369
  const translation = this.translations[lookupKey];
370
- const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
370
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
371
371
  if (isObject(translation)) {
372
372
  if (preferredForm in translation) {
373
373
  return preferredForm;
@@ -378,132 +378,7 @@ class I18n {
378
378
  }
379
379
  throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
380
380
  }
381
- selectPluralFormUsingFallbackRules(count) {
382
- count = Math.abs(Math.floor(count));
383
- const ruleset = this.getPluralRulesForLocale();
384
- if (ruleset) {
385
- return I18n.pluralRules[ruleset](count);
386
- }
387
- return 'other';
388
- }
389
- getPluralRulesForLocale() {
390
- const localeShort = this.locale.split('-')[0];
391
- for (const pluralRule in I18n.pluralRulesMap) {
392
- const languages = I18n.pluralRulesMap[pluralRule];
393
- if (languages.includes(this.locale) || languages.includes(localeShort)) {
394
- return pluralRule;
395
- }
396
- }
397
- }
398
381
  }
399
- I18n.pluralRulesMap = {
400
- arabic: ['ar'],
401
- chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
402
- french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
403
- 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'],
404
- irish: ['ga'],
405
- russian: ['ru', 'uk'],
406
- scottish: ['gd'],
407
- spanish: ['pt-PT', 'it', 'es'],
408
- welsh: ['cy']
409
- };
410
- I18n.pluralRules = {
411
- arabic(n) {
412
- if (n === 0) {
413
- return 'zero';
414
- }
415
- if (n === 1) {
416
- return 'one';
417
- }
418
- if (n === 2) {
419
- return 'two';
420
- }
421
- if (n % 100 >= 3 && n % 100 <= 10) {
422
- return 'few';
423
- }
424
- if (n % 100 >= 11 && n % 100 <= 99) {
425
- return 'many';
426
- }
427
- return 'other';
428
- },
429
- chinese() {
430
- return 'other';
431
- },
432
- french(n) {
433
- return n === 0 || n === 1 ? 'one' : 'other';
434
- },
435
- german(n) {
436
- return n === 1 ? 'one' : 'other';
437
- },
438
- irish(n) {
439
- if (n === 1) {
440
- return 'one';
441
- }
442
- if (n === 2) {
443
- return 'two';
444
- }
445
- if (n >= 3 && n <= 6) {
446
- return 'few';
447
- }
448
- if (n >= 7 && n <= 10) {
449
- return 'many';
450
- }
451
- return 'other';
452
- },
453
- russian(n) {
454
- const lastTwo = n % 100;
455
- const last = lastTwo % 10;
456
- if (last === 1 && lastTwo !== 11) {
457
- return 'one';
458
- }
459
- if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
460
- return 'few';
461
- }
462
- if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
463
- return 'many';
464
- }
465
- return 'other';
466
- },
467
- scottish(n) {
468
- if (n === 1 || n === 11) {
469
- return 'one';
470
- }
471
- if (n === 2 || n === 12) {
472
- return 'two';
473
- }
474
- if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
475
- return 'few';
476
- }
477
- return 'other';
478
- },
479
- spanish(n) {
480
- if (n === 1) {
481
- return 'one';
482
- }
483
- if (n % 1000000 === 0 && n !== 0) {
484
- return 'many';
485
- }
486
- return 'other';
487
- },
488
- welsh(n) {
489
- if (n === 0) {
490
- return 'zero';
491
- }
492
- if (n === 1) {
493
- return 'one';
494
- }
495
- if (n === 2) {
496
- return 'two';
497
- }
498
- if (n === 3) {
499
- return 'few';
500
- }
501
- if (n === 6) {
502
- return 'many';
503
- }
504
- return 'other';
505
- }
506
- };
507
382
 
508
383
  /**
509
384
  * Character count component
@@ -538,6 +413,7 @@ class CharacterCount extends ConfigurableComponent {
538
413
  var _ref, _this$config$maxwords;
539
414
  super($root, config);
540
415
  this.$textarea = void 0;
416
+ this.count = 0;
541
417
  this.$visibleCountMessage = void 0;
542
418
  this.$screenReaderCountMessage = void 0;
543
419
  this.lastInputTimestamp = null;
@@ -593,15 +469,22 @@ class CharacterCount extends ConfigurableComponent {
593
469
  $textareaDescription.classList.add('govuk-visually-hidden');
594
470
  this.$textarea.removeAttribute('maxlength');
595
471
  this.bindChangeEvents();
596
- window.addEventListener('pageshow', () => this.updateCountMessage());
472
+ window.addEventListener('pageshow', () => {
473
+ if (this.$textarea.value !== this.$textarea.textContent) {
474
+ this.updateCount();
475
+ this.updateCountMessage();
476
+ }
477
+ });
478
+ this.updateCount();
597
479
  this.updateCountMessage();
598
480
  }
599
481
  bindChangeEvents() {
600
- this.$textarea.addEventListener('keyup', () => this.handleKeyUp());
482
+ this.$textarea.addEventListener('input', () => this.handleInput());
601
483
  this.$textarea.addEventListener('focus', () => this.handleFocus());
602
484
  this.$textarea.addEventListener('blur', () => this.handleBlur());
603
485
  }
604
- handleKeyUp() {
486
+ handleInput() {
487
+ this.updateCount();
605
488
  this.updateVisibleCountMessage();
606
489
  this.lastInputTimestamp = Date.now();
607
490
  }
@@ -628,7 +511,7 @@ class CharacterCount extends ConfigurableComponent {
628
511
  this.updateScreenReaderCountMessage();
629
512
  }
630
513
  updateVisibleCountMessage() {
631
- const remainingNumber = this.maxLength - this.count(this.$textarea.value);
514
+ const remainingNumber = this.maxLength - this.count;
632
515
  const isError = remainingNumber < 0;
633
516
  this.$visibleCountMessage.classList.toggle('govuk-character-count__message--disabled', !this.isOverThreshold());
634
517
  if (!this.$errorMessage) {
@@ -646,16 +529,18 @@ class CharacterCount extends ConfigurableComponent {
646
529
  }
647
530
  this.$screenReaderCountMessage.textContent = this.getCountMessage();
648
531
  }
649
- count(text) {
532
+ updateCount() {
533
+ const text = this.$textarea.value;
650
534
  if (this.config.maxwords) {
651
535
  var _text$match;
652
536
  const tokens = (_text$match = text.match(/\S+/g)) != null ? _text$match : [];
653
- return tokens.length;
537
+ this.count = tokens.length;
538
+ return;
654
539
  }
655
- return text.length;
540
+ this.count = text.length;
656
541
  }
657
542
  getCountMessage() {
658
- const remainingNumber = this.maxLength - this.count(this.$textarea.value);
543
+ const remainingNumber = this.maxLength - this.count;
659
544
  const countType = this.config.maxwords ? 'words' : 'characters';
660
545
  return this.formatCountMessage(remainingNumber, countType);
661
546
  }
@@ -672,7 +557,7 @@ class CharacterCount extends ConfigurableComponent {
672
557
  if (!this.config.threshold) {
673
558
  return true;
674
559
  }
675
- const currentLength = this.count(this.$textarea.value);
560
+ const currentLength = this.count;
676
561
  const maxLength = this.maxLength;
677
562
  const thresholdValue = maxLength * this.config.threshold / 100;
678
563
  return thresholdValue <= currentLength;
@@ -37,6 +37,7 @@ class CharacterCount extends ConfigurableComponent {
37
37
  var _ref, _this$config$maxwords;
38
38
  super($root, config);
39
39
  this.$textarea = void 0;
40
+ this.count = 0;
40
41
  this.$visibleCountMessage = void 0;
41
42
  this.$screenReaderCountMessage = void 0;
42
43
  this.lastInputTimestamp = null;
@@ -92,15 +93,22 @@ class CharacterCount extends ConfigurableComponent {
92
93
  $textareaDescription.classList.add('govuk-visually-hidden');
93
94
  this.$textarea.removeAttribute('maxlength');
94
95
  this.bindChangeEvents();
95
- window.addEventListener('pageshow', () => this.updateCountMessage());
96
+ window.addEventListener('pageshow', () => {
97
+ if (this.$textarea.value !== this.$textarea.textContent) {
98
+ this.updateCount();
99
+ this.updateCountMessage();
100
+ }
101
+ });
102
+ this.updateCount();
96
103
  this.updateCountMessage();
97
104
  }
98
105
  bindChangeEvents() {
99
- this.$textarea.addEventListener('keyup', () => this.handleKeyUp());
106
+ this.$textarea.addEventListener('input', () => this.handleInput());
100
107
  this.$textarea.addEventListener('focus', () => this.handleFocus());
101
108
  this.$textarea.addEventListener('blur', () => this.handleBlur());
102
109
  }
103
- handleKeyUp() {
110
+ handleInput() {
111
+ this.updateCount();
104
112
  this.updateVisibleCountMessage();
105
113
  this.lastInputTimestamp = Date.now();
106
114
  }
@@ -127,7 +135,7 @@ class CharacterCount extends ConfigurableComponent {
127
135
  this.updateScreenReaderCountMessage();
128
136
  }
129
137
  updateVisibleCountMessage() {
130
- const remainingNumber = this.maxLength - this.count(this.$textarea.value);
138
+ const remainingNumber = this.maxLength - this.count;
131
139
  const isError = remainingNumber < 0;
132
140
  this.$visibleCountMessage.classList.toggle('govuk-character-count__message--disabled', !this.isOverThreshold());
133
141
  if (!this.$errorMessage) {
@@ -145,16 +153,18 @@ class CharacterCount extends ConfigurableComponent {
145
153
  }
146
154
  this.$screenReaderCountMessage.textContent = this.getCountMessage();
147
155
  }
148
- count(text) {
156
+ updateCount() {
157
+ const text = this.$textarea.value;
149
158
  if (this.config.maxwords) {
150
159
  var _text$match;
151
160
  const tokens = (_text$match = text.match(/\S+/g)) != null ? _text$match : [];
152
- return tokens.length;
161
+ this.count = tokens.length;
162
+ return;
153
163
  }
154
- return text.length;
164
+ this.count = text.length;
155
165
  }
156
166
  getCountMessage() {
157
- const remainingNumber = this.maxLength - this.count(this.$textarea.value);
167
+ const remainingNumber = this.maxLength - this.count;
158
168
  const countType = this.config.maxwords ? 'words' : 'characters';
159
169
  return this.formatCountMessage(remainingNumber, countType);
160
170
  }
@@ -171,7 +181,7 @@ class CharacterCount extends ConfigurableComponent {
171
181
  if (!this.config.threshold) {
172
182
  return true;
173
183
  }
174
- const currentLength = this.count(this.$textarea.value);
184
+ const currentLength = this.count;
175
185
  const maxLength = this.maxLength;
176
186
  const thresholdValue = maxLength * this.config.threshold / 100;
177
187
  return thresholdValue <= currentLength;
@@ -119,7 +119,7 @@
119
119
  outline-color: Highlight;
120
120
  }
121
121
 
122
- box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;
122
+ box-shadow: 0 0 0 $govuk-focus-width govuk-functional-colour(focus);
123
123
  }
124
124
 
125
125
  // Selected state
@@ -169,7 +169,8 @@
169
169
  @include govuk-responsive-margin(4, "bottom");
170
170
  margin-left: $conditional-margin-left;
171
171
  padding-left: $conditional-padding-left;
172
- border-left: $conditional-border-width solid $govuk-border-colour;
172
+ border-left: $conditional-border-width solid;
173
+ border-left-color: govuk-functional-colour(border);
173
174
 
174
175
  .govuk-frontend-supported &--hidden {
175
176
  display: none;
@@ -271,7 +272,7 @@
271
272
  // Apply an outline for those modes to use instead.
272
273
  outline: $govuk-focus-width dashed transparent;
273
274
  outline-offset: 1px;
274
- box-shadow: 0 0 0 $govuk-hover-width $govuk-hover-colour;
275
+ box-shadow: 0 0 0 $govuk-hover-width govuk-functional-colour(hover);
275
276
  }
276
277
 
277
278
  // Because we've overridden the border-shadow provided by the focus state,
@@ -286,8 +287,8 @@
286
287
  }
287
288
  // prettier-ignore
288
289
  box-shadow:
289
- 0 0 0 $govuk-focus-width $govuk-focus-colour, // 1
290
- 0 0 0 $govuk-hover-width $govuk-hover-colour; // 2
290
+ 0 0 0 $govuk-focus-width govuk-functional-colour(focus), // 1
291
+ 0 0 0 $govuk-hover-width govuk-functional-colour(hover); // 2
291
292
  }
292
293
 
293
294
  // For devices that explicitly don't support hover, don't provide a hover
@@ -302,7 +303,7 @@
302
303
  }
303
304
 
304
305
  .govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
305
- box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;
306
+ box-shadow: 0 0 0 $govuk-focus-width govuk-functional-colour(focus);
306
307
  }
307
308
  }
308
309
  }
@@ -13,11 +13,8 @@
13
13
  // changes colours in their browser.
14
14
  border-bottom: $border-bottom-width solid transparent;
15
15
 
16
- @include _govuk-rebrand(
17
- "background-color",
18
- $govuk-template-background-colour,
19
- $_govuk-rebrand-template-background-colour
20
- );
16
+ color: govuk-functional-colour(surface-text);
17
+ background-color: govuk-functional-colour(surface-background);
21
18
  }
22
19
 
23
20
  // Support older browsers which don't hide elements with the `hidden` attribute
@@ -14,6 +14,11 @@
14
14
  display: inline-block;
15
15
  margin-right: govuk-spacing(4);
16
16
  margin-bottom: 0;
17
+
18
+ // Prevents an issue in iOS Safari 18 where the items vertically
19
+ // shift when the value of inputs is changed.
20
+ // https://github.com/alphagov/reported-bugs/issues/90
21
+ vertical-align: bottom;
17
22
  }
18
23
 
19
24
  .govuk-date-input__label {
@@ -46,7 +46,8 @@
46
46
  // like inset text
47
47
  @media screen\0 {
48
48
  .govuk-details {
49
- border-left: $govuk-border-width-wide solid $govuk-border-colour;
49
+ border-left: $govuk-border-width-wide solid;
50
+ border-left-color: govuk-functional-colour(border);
50
51
  }
51
52
 
52
53
  .govuk-details__summary {
@@ -81,11 +82,11 @@
81
82
  padding-left: govuk-spacing(4) + $govuk-border-width;
82
83
 
83
84
  // Style the summary to look like a link...
84
- color: $govuk-link-colour;
85
+ color: govuk-functional-colour(link);
85
86
  cursor: pointer;
86
87
 
87
88
  &:hover {
88
- color: $govuk-link-hover-colour;
89
+ color: govuk-functional-colour(link-hover);
89
90
  }
90
91
 
91
92
  &:focus {
@@ -131,7 +132,8 @@
131
132
  }
132
133
 
133
134
  .govuk-details__text {
134
- border-left: $govuk-border-width solid $govuk-border-colour;
135
+ border-left: $govuk-border-width solid;
136
+ border-left-color: govuk-functional-colour(border);
135
137
  }
136
138
  }
137
139
  }
@@ -7,7 +7,7 @@
7
7
  margin-bottom: govuk-spacing(3);
8
8
  clear: both;
9
9
 
10
- color: $govuk-error-colour;
10
+ color: govuk-functional-colour(error);
11
11
  }
12
12
  }
13
13
 
@@ -7,10 +7,12 @@
7
7
  @include govuk-responsive-padding(4);
8
8
  @include govuk-responsive-margin(8, "bottom");
9
9
 
10
- border: $govuk-border-width solid $govuk-error-colour;
10
+ border: $govuk-border-width solid;
11
+ border-color: govuk-functional-colour(error);
11
12
 
12
13
  &:focus {
13
- outline: $govuk-focus-width solid $govuk-focus-colour;
14
+ outline: $govuk-focus-width solid;
15
+ outline-color: govuk-functional-colour(focus);
14
16
  }
15
17
  }
16
18
 
@@ -12,7 +12,7 @@
12
12
  left: 0;
13
13
  width: 100%;
14
14
 
15
- @include govuk-media-query($from: tablet) {
15
+ @media #{govuk-from-breakpoint(tablet)} {
16
16
  display: inline-block;
17
17
  right: 0;
18
18
  left: auto;
@@ -348,7 +348,7 @@
348
348
  return 'other';
349
349
  }
350
350
  const translation = this.translations[lookupKey];
351
- const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
351
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
352
352
  if (isObject(translation)) {
353
353
  if (preferredForm in translation) {
354
354
  return preferredForm;
@@ -359,132 +359,7 @@
359
359
  }
360
360
  throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
361
361
  }
362
- selectPluralFormUsingFallbackRules(count) {
363
- count = Math.abs(Math.floor(count));
364
- const ruleset = this.getPluralRulesForLocale();
365
- if (ruleset) {
366
- return I18n.pluralRules[ruleset](count);
367
- }
368
- return 'other';
369
- }
370
- getPluralRulesForLocale() {
371
- const localeShort = this.locale.split('-')[0];
372
- for (const pluralRule in I18n.pluralRulesMap) {
373
- const languages = I18n.pluralRulesMap[pluralRule];
374
- if (languages.includes(this.locale) || languages.includes(localeShort)) {
375
- return pluralRule;
376
- }
377
- }
378
- }
379
362
  }
380
- I18n.pluralRulesMap = {
381
- arabic: ['ar'],
382
- chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
383
- french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
384
- 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'],
385
- irish: ['ga'],
386
- russian: ['ru', 'uk'],
387
- scottish: ['gd'],
388
- spanish: ['pt-PT', 'it', 'es'],
389
- welsh: ['cy']
390
- };
391
- I18n.pluralRules = {
392
- arabic(n) {
393
- if (n === 0) {
394
- return 'zero';
395
- }
396
- if (n === 1) {
397
- return 'one';
398
- }
399
- if (n === 2) {
400
- return 'two';
401
- }
402
- if (n % 100 >= 3 && n % 100 <= 10) {
403
- return 'few';
404
- }
405
- if (n % 100 >= 11 && n % 100 <= 99) {
406
- return 'many';
407
- }
408
- return 'other';
409
- },
410
- chinese() {
411
- return 'other';
412
- },
413
- french(n) {
414
- return n === 0 || n === 1 ? 'one' : 'other';
415
- },
416
- german(n) {
417
- return n === 1 ? 'one' : 'other';
418
- },
419
- irish(n) {
420
- if (n === 1) {
421
- return 'one';
422
- }
423
- if (n === 2) {
424
- return 'two';
425
- }
426
- if (n >= 3 && n <= 6) {
427
- return 'few';
428
- }
429
- if (n >= 7 && n <= 10) {
430
- return 'many';
431
- }
432
- return 'other';
433
- },
434
- russian(n) {
435
- const lastTwo = n % 100;
436
- const last = lastTwo % 10;
437
- if (last === 1 && lastTwo !== 11) {
438
- return 'one';
439
- }
440
- if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
441
- return 'few';
442
- }
443
- if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
444
- return 'many';
445
- }
446
- return 'other';
447
- },
448
- scottish(n) {
449
- if (n === 1 || n === 11) {
450
- return 'one';
451
- }
452
- if (n === 2 || n === 12) {
453
- return 'two';
454
- }
455
- if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
456
- return 'few';
457
- }
458
- return 'other';
459
- },
460
- spanish(n) {
461
- if (n === 1) {
462
- return 'one';
463
- }
464
- if (n % 1000000 === 0 && n !== 0) {
465
- return 'many';
466
- }
467
- return 'other';
468
- },
469
- welsh(n) {
470
- if (n === 0) {
471
- return 'zero';
472
- }
473
- if (n === 1) {
474
- return 'one';
475
- }
476
- if (n === 2) {
477
- return 'two';
478
- }
479
- if (n === 3) {
480
- return 'few';
481
- }
482
- if (n === 6) {
483
- return 'many';
484
- }
485
- return 'other';
486
- }
487
- };
488
363
 
489
364
  /**
490
365
  * Exit this page component