govuk_tech_docs 5.2.1 → 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 (169) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +59 -0
  3. data/.npmrc +1 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +19 -0
  6. data/README.md +13 -4
  7. data/example/config/tech-docs.yml +1 -1
  8. data/govuk_tech_docs.gemspec +2 -2
  9. data/lib/assets/stylesheets/_core.scss +1 -0
  10. data/lib/assets/stylesheets/_govuk_tech_docs.scss +13 -15
  11. data/lib/assets/stylesheets/modules/_app-pane.scss +3 -3
  12. data/lib/assets/stylesheets/modules/_page-review.scss +4 -4
  13. data/lib/assets/stylesheets/modules/_search.scss +3 -3
  14. data/lib/assets/stylesheets/modules/_service-navigation.scss +5 -0
  15. data/lib/assets/stylesheets/modules/_technical-documentation.scss +7 -7
  16. data/lib/assets/stylesheets/modules/_toc.scss +13 -13
  17. data/lib/assets/stylesheets/palette/_syntax-highlighting.scss +9 -7
  18. data/lib/govuk_tech_docs/meta_tags.rb +1 -1
  19. data/lib/govuk_tech_docs/version.rb +1 -1
  20. data/lib/source/layouts/_header.erb +2 -16
  21. data/lib/source/layouts/_service_navigation.erb +27 -0
  22. data/lib/source/layouts/core.erb +7 -7
  23. data/node_modules/govuk-frontend/dist/govuk/_base.scss +1 -0
  24. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +183 -300
  25. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +184 -300
  26. data/node_modules/govuk-frontend/dist/govuk/all.mjs +0 -1
  27. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.ico +0 -0
  28. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.svg +1 -1
  29. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-180.png +0 -0
  30. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-192.png +0 -0
  31. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-512.png +0 -0
  32. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-opengraph-image.png +0 -0
  33. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +29 -2
  34. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  35. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +4 -10
  36. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +18 -15
  37. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +14 -137
  38. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +14 -137
  39. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +4 -4
  40. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_index.scss +2 -2
  41. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +2 -2
  42. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +18 -21
  43. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +7 -5
  44. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +7 -5
  45. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +2 -2
  46. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +30 -143
  47. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +30 -143
  48. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +20 -10
  49. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +7 -6
  50. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +10 -5
  51. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +10 -5
  52. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +2 -5
  53. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +5 -0
  54. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +6 -4
  55. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_index.scss +1 -1
  56. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +4 -2
  57. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +8 -12
  58. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +8 -12
  59. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +2 -2
  60. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss +1 -1
  61. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +10 -133
  62. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +10 -133
  63. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +30 -38
  64. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +46 -140
  65. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +46 -140
  66. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +36 -7
  67. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +30 -27
  68. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +89 -449
  69. data/node_modules/govuk-frontend/dist/govuk/components/hint/_index.scss +1 -1
  70. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +14 -20
  71. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_index.scss +2 -1
  72. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +10 -8
  73. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +7 -5
  74. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +7 -5
  75. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +16 -11
  76. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +4 -4
  77. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +2 -2
  78. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +10 -133
  79. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +10 -133
  80. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +12 -6
  81. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +8 -7
  82. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +10 -5
  83. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +10 -5
  84. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +6 -11
  85. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +58 -74
  86. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +40 -7
  87. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +40 -7
  88. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +30 -2
  89. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +8 -4
  90. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +12 -19
  91. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +12 -19
  92. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +3 -9
  93. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +25 -21
  94. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +7 -8
  95. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +9 -6
  96. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +12 -13
  97. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +12 -13
  98. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +3 -3
  99. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +66 -31
  100. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +7 -5
  101. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +5 -10
  102. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +5 -4
  103. data/node_modules/govuk-frontend/dist/govuk/core/_index.scss +0 -1
  104. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +2 -2
  105. data/node_modules/govuk-frontend/dist/govuk/core/_section-break.scss +2 -1
  106. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +6 -20
  107. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_breakpoints.scss +17 -0
  108. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.scss +15 -0
  109. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss +17 -0
  110. data/node_modules/govuk-frontend/dist/govuk/custom-properties/_index.scss +5 -0
  111. data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +5 -3
  112. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  113. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +187 -72
  114. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +41 -6
  115. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
  116. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +24 -40
  117. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +172 -33
  118. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +1 -1
  119. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +6 -30
  120. data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss +4 -1
  121. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +5 -128
  122. data/node_modules/govuk-frontend/dist/govuk/init.mjs +53 -45
  123. data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss +1 -1
  124. data/node_modules/govuk-frontend/dist/govuk/objects/_form-group.scss +2 -1
  125. data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss +1 -1
  126. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +3 -7
  127. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +2 -2
  128. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +1 -1
  129. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +0 -2
  130. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +5 -5
  131. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss +3 -188
  132. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-functional.scss +366 -0
  133. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +9 -255
  134. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-palette.scss +117 -25
  135. data/node_modules/govuk-frontend/dist/govuk/settings/_custom-properties.scss +18 -0
  136. data/node_modules/govuk-frontend/dist/govuk/settings/_index.scss +3 -14
  137. data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss +0 -9
  138. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +12 -189
  139. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +0 -1
  140. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss +4 -2
  141. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-rem.scss +2 -0
  142. data/package-lock.json +2461 -1150
  143. data/package.json +3 -3
  144. metadata +16 -30
  145. data/node_modules/govuk-frontend/dist/govuk/all.scss +0 -9
  146. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.ico +0 -0
  147. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.svg +0 -1
  148. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-crest.svg +0 -1
  149. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-180.png +0 -0
  150. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-192.png +0 -0
  151. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-512.png +0 -0
  152. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-mask.svg +0 -1
  153. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-opengraph-image.png +0 -0
  154. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/manifest.json +0 -39
  155. data/node_modules/govuk-frontend/dist/govuk/components/_all.scss +0 -10
  156. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +0 -233
  157. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +0 -225
  158. data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +0 -89
  159. data/node_modules/govuk-frontend/dist/govuk/core/_all.scss +0 -10
  160. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +0 -15
  161. data/node_modules/govuk-frontend/dist/govuk/helpers/_all.scss +0 -10
  162. data/node_modules/govuk-frontend/dist/govuk/objects/_all.scss +0 -10
  163. data/node_modules/govuk-frontend/dist/govuk/overrides/_all.scss +0 -9
  164. data/node_modules/govuk-frontend/dist/govuk/settings/_all.scss +0 -10
  165. data/node_modules/govuk-frontend/dist/govuk/tools/_all.scss +0 -10
  166. data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss +0 -65
  167. data/node_modules/govuk-frontend/dist/govuk/utilities/_all.scss +0 -10
  168. data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss +0 -349
  169. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/functions.js +0 -25
@@ -1,9 +1,3 @@
1
- function getFragmentFromUrl(url) {
2
- if (!url.includes('#')) {
3
- return undefined;
4
- }
5
- return url.split('#').pop();
6
- }
7
1
  function setFocus($element, options = {}) {
8
2
  var _options$onBeforeFocu;
9
3
  const isFocusable = $element.getAttribute('tabindex');
@@ -60,9 +54,6 @@ function formatErrorMessage(Component, message) {
60
54
  * @typedef ComponentWithModuleName
61
55
  * @property {string} moduleName - Name of the component
62
56
  */
63
- /**
64
- * @import { ObjectNested } from './configuration.mjs'
65
- */
66
57
 
67
58
  class GOVUKFrontendError extends Error {
68
59
  constructor(...args) {
@@ -91,7 +82,7 @@ class ConfigError extends GOVUKFrontendError {
91
82
  class ElementError extends GOVUKFrontendError {
92
83
  constructor(messageOrOptions) {
93
84
  let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
94
- if (typeof messageOrOptions === 'object') {
85
+ if (isObject(messageOrOptions)) {
95
86
  const {
96
87
  component,
97
88
  identifier,
@@ -100,7 +91,9 @@ class ElementError extends GOVUKFrontendError {
100
91
  } = messageOrOptions;
101
92
  message = identifier;
102
93
  message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
103
- message = formatErrorMessage(component, message);
94
+ if (component) {
95
+ message = formatErrorMessage(component, message);
96
+ }
104
97
  }
105
98
  super(message);
106
99
  this.name = 'ElementError';
@@ -314,6 +307,9 @@ function extractConfigByNamespace(schema, dataset, namespace) {
314
307
  * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
315
308
  * @typedef {typeof Component & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
316
309
  */
310
+ /**
311
+ * @import { CompatibleClass, Config, CreateAllOptions, OnErrorCallback } from '../init.mjs'
312
+ */
317
313
 
318
314
  /**
319
315
  * Error summary component
@@ -346,7 +342,7 @@ class ErrorSummary extends ConfigurableComponent {
346
342
  if (!($target instanceof HTMLAnchorElement)) {
347
343
  return false;
348
344
  }
349
- const inputId = getFragmentFromUrl($target.href);
345
+ const inputId = $target.hash.replace('#', '');
350
346
  if (!inputId) {
351
347
  return false;
352
348
  }
@@ -1,5 +1,5 @@
1
1
  import { ConfigurableComponent } from '../../common/configuration.mjs';
2
- import { setFocus, getFragmentFromUrl } from '../../common/index.mjs';
2
+ import { setFocus } from '../../common/index.mjs';
3
3
 
4
4
  /**
5
5
  * Error summary component
@@ -32,7 +32,7 @@ class ErrorSummary extends ConfigurableComponent {
32
32
  if (!($target instanceof HTMLAnchorElement)) {
33
33
  return false;
34
34
  }
35
- const inputId = getFragmentFromUrl($target.href);
35
+ const inputId = $target.hash.replace('#', '');
36
36
  if (!inputId) {
37
37
  return false;
38
38
  }
@@ -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;
@@ -36,9 +36,6 @@
36
36
  * @typedef ComponentWithModuleName
37
37
  * @property {string} moduleName - Name of the component
38
38
  */
39
- /**
40
- * @import { ObjectNested } from './configuration.mjs'
41
- */
42
39
 
43
40
  class GOVUKFrontendError extends Error {
44
41
  constructor(...args) {
@@ -67,7 +64,7 @@
67
64
  class ElementError extends GOVUKFrontendError {
68
65
  constructor(messageOrOptions) {
69
66
  let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
70
- if (typeof messageOrOptions === 'object') {
67
+ if (isObject(messageOrOptions)) {
71
68
  const {
72
69
  component,
73
70
  identifier,
@@ -76,7 +73,9 @@
76
73
  } = messageOrOptions;
77
74
  message = identifier;
78
75
  message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
79
- message = formatErrorMessage(component, message);
76
+ if (component) {
77
+ message = formatErrorMessage(component, message);
78
+ }
80
79
  }
81
80
  super(message);
82
81
  this.name = 'ElementError';
@@ -290,6 +289,9 @@
290
289
  * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
291
290
  * @typedef {typeof Component & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
292
291
  */
292
+ /**
293
+ * @import { CompatibleClass, Config, CreateAllOptions, OnErrorCallback } from '../init.mjs'
294
+ */
293
295
 
294
296
  class I18n {
295
297
  constructor(translations = {}, config = {}) {
@@ -304,7 +306,7 @@
304
306
  throw new Error('i18n: lookup key missing');
305
307
  }
306
308
  let translation = this.translations[lookupKey];
307
- if (typeof (options == null ? void 0 : options.count) === 'number' && typeof translation === 'object') {
309
+ if (typeof (options == null ? void 0 : options.count) === 'number' && isObject(translation)) {
308
310
  const translationPluralForm = translation[this.getPluralSuffix(lookupKey, options.count)];
309
311
  if (translationPluralForm) {
310
312
  translation = translationPluralForm;
@@ -346,8 +348,8 @@
346
348
  return 'other';
347
349
  }
348
350
  const translation = this.translations[lookupKey];
349
- const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
350
- if (typeof translation === 'object') {
351
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
352
+ if (isObject(translation)) {
351
353
  if (preferredForm in translation) {
352
354
  return preferredForm;
353
355
  } else if ('other' in translation) {
@@ -357,132 +359,7 @@
357
359
  }
358
360
  throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
359
361
  }
360
- selectPluralFormUsingFallbackRules(count) {
361
- count = Math.abs(Math.floor(count));
362
- const ruleset = this.getPluralRulesForLocale();
363
- if (ruleset) {
364
- return I18n.pluralRules[ruleset](count);
365
- }
366
- return 'other';
367
- }
368
- getPluralRulesForLocale() {
369
- const localeShort = this.locale.split('-')[0];
370
- for (const pluralRule in I18n.pluralRulesMap) {
371
- const languages = I18n.pluralRulesMap[pluralRule];
372
- if (languages.includes(this.locale) || languages.includes(localeShort)) {
373
- return pluralRule;
374
- }
375
- }
376
- }
377
362
  }
378
- I18n.pluralRulesMap = {
379
- arabic: ['ar'],
380
- chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
381
- french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
382
- 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'],
383
- irish: ['ga'],
384
- russian: ['ru', 'uk'],
385
- scottish: ['gd'],
386
- spanish: ['pt-PT', 'it', 'es'],
387
- welsh: ['cy']
388
- };
389
- I18n.pluralRules = {
390
- arabic(n) {
391
- if (n === 0) {
392
- return 'zero';
393
- }
394
- if (n === 1) {
395
- return 'one';
396
- }
397
- if (n === 2) {
398
- return 'two';
399
- }
400
- if (n % 100 >= 3 && n % 100 <= 10) {
401
- return 'few';
402
- }
403
- if (n % 100 >= 11 && n % 100 <= 99) {
404
- return 'many';
405
- }
406
- return 'other';
407
- },
408
- chinese() {
409
- return 'other';
410
- },
411
- french(n) {
412
- return n === 0 || n === 1 ? 'one' : 'other';
413
- },
414
- german(n) {
415
- return n === 1 ? 'one' : 'other';
416
- },
417
- irish(n) {
418
- if (n === 1) {
419
- return 'one';
420
- }
421
- if (n === 2) {
422
- return 'two';
423
- }
424
- if (n >= 3 && n <= 6) {
425
- return 'few';
426
- }
427
- if (n >= 7 && n <= 10) {
428
- return 'many';
429
- }
430
- return 'other';
431
- },
432
- russian(n) {
433
- const lastTwo = n % 100;
434
- const last = lastTwo % 10;
435
- if (last === 1 && lastTwo !== 11) {
436
- return 'one';
437
- }
438
- if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
439
- return 'few';
440
- }
441
- if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
442
- return 'many';
443
- }
444
- return 'other';
445
- },
446
- scottish(n) {
447
- if (n === 1 || n === 11) {
448
- return 'one';
449
- }
450
- if (n === 2 || n === 12) {
451
- return 'two';
452
- }
453
- if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
454
- return 'few';
455
- }
456
- return 'other';
457
- },
458
- spanish(n) {
459
- if (n === 1) {
460
- return 'one';
461
- }
462
- if (n % 1000000 === 0 && n !== 0) {
463
- return 'many';
464
- }
465
- return 'other';
466
- },
467
- welsh(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 === 3) {
478
- return 'few';
479
- }
480
- if (n === 6) {
481
- return 'many';
482
- }
483
- return 'other';
484
- }
485
- };
486
363
 
487
364
  /**
488
365
  * Exit this page component
@@ -30,9 +30,6 @@ function formatErrorMessage(Component, message) {
30
30
  * @typedef ComponentWithModuleName
31
31
  * @property {string} moduleName - Name of the component
32
32
  */
33
- /**
34
- * @import { ObjectNested } from './configuration.mjs'
35
- */
36
33
 
37
34
  class GOVUKFrontendError extends Error {
38
35
  constructor(...args) {
@@ -61,7 +58,7 @@ class ConfigError extends GOVUKFrontendError {
61
58
  class ElementError extends GOVUKFrontendError {
62
59
  constructor(messageOrOptions) {
63
60
  let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
64
- if (typeof messageOrOptions === 'object') {
61
+ if (isObject(messageOrOptions)) {
65
62
  const {
66
63
  component,
67
64
  identifier,
@@ -70,7 +67,9 @@ class ElementError extends GOVUKFrontendError {
70
67
  } = messageOrOptions;
71
68
  message = identifier;
72
69
  message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
73
- message = formatErrorMessage(component, message);
70
+ if (component) {
71
+ message = formatErrorMessage(component, message);
72
+ }
74
73
  }
75
74
  super(message);
76
75
  this.name = 'ElementError';
@@ -284,6 +283,9 @@ function extractConfigByNamespace(schema, dataset, namespace) {
284
283
  * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
285
284
  * @typedef {typeof Component & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
286
285
  */
286
+ /**
287
+ * @import { CompatibleClass, Config, CreateAllOptions, OnErrorCallback } from '../init.mjs'
288
+ */
287
289
 
288
290
  class I18n {
289
291
  constructor(translations = {}, config = {}) {
@@ -298,7 +300,7 @@ class I18n {
298
300
  throw new Error('i18n: lookup key missing');
299
301
  }
300
302
  let translation = this.translations[lookupKey];
301
- if (typeof (options == null ? void 0 : options.count) === 'number' && typeof translation === 'object') {
303
+ if (typeof (options == null ? void 0 : options.count) === 'number' && isObject(translation)) {
302
304
  const translationPluralForm = translation[this.getPluralSuffix(lookupKey, options.count)];
303
305
  if (translationPluralForm) {
304
306
  translation = translationPluralForm;
@@ -340,8 +342,8 @@ class I18n {
340
342
  return 'other';
341
343
  }
342
344
  const translation = this.translations[lookupKey];
343
- const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
344
- if (typeof translation === 'object') {
345
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : 'other';
346
+ if (isObject(translation)) {
345
347
  if (preferredForm in translation) {
346
348
  return preferredForm;
347
349
  } else if ('other' in translation) {
@@ -351,132 +353,7 @@ class I18n {
351
353
  }
352
354
  throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
353
355
  }
354
- selectPluralFormUsingFallbackRules(count) {
355
- count = Math.abs(Math.floor(count));
356
- const ruleset = this.getPluralRulesForLocale();
357
- if (ruleset) {
358
- return I18n.pluralRules[ruleset](count);
359
- }
360
- return 'other';
361
- }
362
- getPluralRulesForLocale() {
363
- const localeShort = this.locale.split('-')[0];
364
- for (const pluralRule in I18n.pluralRulesMap) {
365
- const languages = I18n.pluralRulesMap[pluralRule];
366
- if (languages.includes(this.locale) || languages.includes(localeShort)) {
367
- return pluralRule;
368
- }
369
- }
370
- }
371
356
  }
372
- I18n.pluralRulesMap = {
373
- arabic: ['ar'],
374
- chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
375
- french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
376
- 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'],
377
- irish: ['ga'],
378
- russian: ['ru', 'uk'],
379
- scottish: ['gd'],
380
- spanish: ['pt-PT', 'it', 'es'],
381
- welsh: ['cy']
382
- };
383
- I18n.pluralRules = {
384
- arabic(n) {
385
- if (n === 0) {
386
- return 'zero';
387
- }
388
- if (n === 1) {
389
- return 'one';
390
- }
391
- if (n === 2) {
392
- return 'two';
393
- }
394
- if (n % 100 >= 3 && n % 100 <= 10) {
395
- return 'few';
396
- }
397
- if (n % 100 >= 11 && n % 100 <= 99) {
398
- return 'many';
399
- }
400
- return 'other';
401
- },
402
- chinese() {
403
- return 'other';
404
- },
405
- french(n) {
406
- return n === 0 || n === 1 ? 'one' : 'other';
407
- },
408
- german(n) {
409
- return n === 1 ? 'one' : 'other';
410
- },
411
- irish(n) {
412
- if (n === 1) {
413
- return 'one';
414
- }
415
- if (n === 2) {
416
- return 'two';
417
- }
418
- if (n >= 3 && n <= 6) {
419
- return 'few';
420
- }
421
- if (n >= 7 && n <= 10) {
422
- return 'many';
423
- }
424
- return 'other';
425
- },
426
- russian(n) {
427
- const lastTwo = n % 100;
428
- const last = lastTwo % 10;
429
- if (last === 1 && lastTwo !== 11) {
430
- return 'one';
431
- }
432
- if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
433
- return 'few';
434
- }
435
- if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
436
- return 'many';
437
- }
438
- return 'other';
439
- },
440
- scottish(n) {
441
- if (n === 1 || n === 11) {
442
- return 'one';
443
- }
444
- if (n === 2 || n === 12) {
445
- return 'two';
446
- }
447
- if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
448
- return 'few';
449
- }
450
- return 'other';
451
- },
452
- spanish(n) {
453
- if (n === 1) {
454
- return 'one';
455
- }
456
- if (n % 1000000 === 0 && n !== 0) {
457
- return 'many';
458
- }
459
- return 'other';
460
- },
461
- welsh(n) {
462
- if (n === 0) {
463
- return 'zero';
464
- }
465
- if (n === 1) {
466
- return 'one';
467
- }
468
- if (n === 2) {
469
- return 'two';
470
- }
471
- if (n === 3) {
472
- return 'few';
473
- }
474
- if (n === 6) {
475
- return 'many';
476
- }
477
- return 'other';
478
- }
479
- };
480
357
 
481
358
  /**
482
359
  * Exit this page component
@@ -6,8 +6,8 @@
6
6
  $file-upload-border-width: 2px;
7
7
  $component-padding: govuk-spacing(1);
8
8
  $empty-button-background-colour: govuk-colour("white");
9
- $empty-pseudo-button-background-colour: govuk-colour("light-grey");
10
- $empty-status-background-colour: govuk-tint(govuk-colour("blue"), 70%);
9
+ $empty-pseudo-button-background-colour: govuk-colour("black", $variant: "tint-95");
10
+ $empty-status-background-colour: govuk-colour("blue", $variant: "tint-80");
11
11
 
12
12
  .govuk-file-upload {
13
13
  @include govuk-font($size: 19);
@@ -27,11 +27,12 @@
27
27
  }
28
28
 
29
29
  &:focus {
30
- outline: $govuk-focus-width solid $govuk-focus-colour;
30
+ outline: $govuk-focus-width solid;
31
+ outline-color: govuk-functional-colour(focus);
31
32
  // Use `box-shadow` to add border instead of changing `border-width`
32
33
  // (which changes element size) and since `outline` is already used for
33
34
  // the yellow focus state.
34
- box-shadow: inset 0 0 0 4px $govuk-input-border-colour;
35
+ box-shadow: inset 0 0 0 4px govuk-functional-colour(input-border);
35
36
  }
36
37
 
37
38
  // Set "focus-within" to fix https://bugzil.la/1430196 so that component
@@ -40,9 +41,10 @@
40
41
  // to recognise `focus-within` and don't set any styles from the block
41
42
  // when it's a selector.
42
43
  &:focus-within {
43
- outline: $govuk-focus-width solid $govuk-focus-colour;
44
+ outline: $govuk-focus-width solid;
45
+ outline-color: govuk-functional-colour(focus);
44
46
 
45
- box-shadow: inset 0 0 0 4px $govuk-input-border-colour;
47
+ box-shadow: inset 0 0 0 4px govuk-functional-colour(input-border);
46
48
  }
47
49
 
48
50
  &:disabled {
@@ -55,7 +57,7 @@
55
57
  display: block;
56
58
  position: relative;
57
59
  z-index: 0;
58
- background-color: $govuk-body-background-colour;
60
+ background-color: govuk-functional-colour(body-background);
59
61
  }
60
62
 
61
63
  // required because disabling pointer events
@@ -82,8 +84,10 @@
82
84
  display: block;
83
85
  margin-bottom: govuk-spacing(2);
84
86
  padding: govuk-spacing(3) govuk-spacing(2);
85
- background-color: govuk-colour("white");
87
+ color: govuk-colour("white");
88
+ background-color: govuk-colour("blue");
86
89
  text-align: left;
90
+ @include govuk-text-break-word;
87
91
  }
88
92
 
89
93
  // bugs documented with button using flex
@@ -99,37 +103,38 @@
99
103
  width: 100%;
100
104
  // align the padding to be same as notification banner and error summary accounting for the thicker borders
101
105
  padding: (govuk-spacing(3) + $govuk-border-width - $file-upload-border-width);
102
- border: $file-upload-border-width govuk-colour("mid-grey") solid;
103
- background-color: govuk-colour("light-grey");
106
+ border: $file-upload-border-width govuk-colour("black", $variant: "tint-80") solid;
107
+ background-color: govuk-colour("white");
104
108
  cursor: pointer;
105
109
 
106
- @include govuk-media-query($from: tablet) {
110
+ @media #{govuk-from-breakpoint(tablet)} {
107
111
  padding: (govuk-spacing(4) + $govuk-border-width - $file-upload-border-width);
108
112
  }
109
113
 
110
114
  .govuk-file-upload-button__pseudo-button {
111
- background-color: govuk-colour("white");
115
+ background-color: govuk-colour("black", $variant: "tint-95");
112
116
  }
113
117
 
114
118
  &:hover {
115
- background-color: govuk-tint(govuk-colour("mid-grey"), 20%);
119
+ border-color: govuk-colour("black", $variant: "tint-50");
116
120
 
117
121
  .govuk-file-upload-button__pseudo-button {
118
- background-color: govuk-shade(govuk-colour("light-grey"), 10%);
122
+ background-color: govuk-colour("black", $variant: "tint-80");
119
123
  }
120
124
 
121
125
  .govuk-file-upload-button__status {
122
- background-color: govuk-tint(govuk-colour("blue"), 80%);
126
+ background-color: govuk-colour("blue");
123
127
  }
124
128
  }
125
129
 
126
130
  &:active,
127
131
  &:focus {
128
132
  border: $file-upload-border-width solid govuk-colour("black");
129
- outline: $govuk-focus-width solid $govuk-focus-colour;
133
+ outline: $govuk-focus-width solid;
134
+ outline-color: govuk-functional-colour(focus);
130
135
  // Ensure outline appears outside of the element
131
136
  outline-offset: 0;
132
- background-color: govuk-tint(govuk-colour("mid-grey"), 20%);
137
+ background-color: govuk-colour("black", $variant: "tint-95");
133
138
  // Double the border by adding its width again. Use `box-shadow` for this
134
139
  // instead of changing `border-width` - this is for consistency with
135
140
  // components such as textarea where we avoid changing `border-width` as
@@ -138,15 +143,15 @@
138
143
  box-shadow: inset 0 0 0 $govuk-border-width-form-element;
139
144
 
140
145
  .govuk-file-upload-button__pseudo-button {
141
- background-color: $govuk-focus-colour;
146
+ background-color: govuk-functional-colour(focus);
142
147
  box-shadow: 0 2px 0 govuk-colour("black");
143
148
  }
144
149
 
145
150
  &:hover .govuk-file-upload-button__pseudo-button {
146
- border-color: $govuk-focus-colour;
151
+ border-color: govuk-functional-colour(focus);
147
152
  outline: 3px solid transparent;
148
- background-color: govuk-colour("light-grey");
149
- box-shadow: inset 0 0 0 1px $govuk-focus-colour;
153
+ background-color: govuk-colour("black", $variant: "tint-80");
154
+ box-shadow: inset 0 0 0 1px govuk-functional-colour(focus);
150
155
  }
151
156
  }
152
157
  }
@@ -160,17 +165,17 @@
160
165
  }
161
166
 
162
167
  .govuk-file-upload-button__status {
163
- color: govuk-shade(govuk-colour("blue"), 60%);
168
+ color: govuk-colour("black");
164
169
  background-color: $empty-status-background-colour;
165
170
  }
166
171
 
167
172
  &:hover,
168
173
  &:focus,
169
174
  &:active {
170
- background-color: govuk-colour("light-grey");
175
+ background-color: govuk-colour("black", $variant: "tint-95");
171
176
 
172
177
  .govuk-file-upload-button__status {
173
- background-color: govuk-tint(govuk-colour("blue"), 80%);
178
+ background-color: govuk-colour("blue", $variant: "tint-80");
174
179
  }
175
180
  }
176
181
  }
@@ -181,21 +186,8 @@
181
186
 
182
187
  // extra specificity to apply when
183
188
  // empty
184
- &.govuk-file-upload-button {
185
- background-color: govuk-tint(govuk-colour("mid-grey"), 20%);
186
- }
187
-
188
189
  &.govuk-file-upload-button--empty {
189
- background-color: govuk-colour("light-grey");
190
- }
191
-
192
- &.govuk-file-upload-button--empty:not(:disabled) .govuk-file-upload-button__status,
193
- &.govuk-file-upload-button--empty .govuk-file-upload-button__pseudo-button {
194
- background-color: govuk-colour("white");
195
- }
196
-
197
- .govuk-file-upload-button__pseudo-button {
198
- background-color: govuk-shade(govuk-colour("light-grey"), 10%);
190
+ background-color: govuk-colour("black", $variant: "tint-95");
199
191
  }
200
192
  }
201
193