govuk_tech_docs 6.5.2.1 → 6.6.0.rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/publish-gem.yaml +1 -1
- data/lib/assets/stylesheets/_govuk_tech_docs.scss +39 -1
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +202 -137
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +202 -137
- data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +5 -1
- data/node_modules/govuk-frontend/dist/govuk/common/create-element.mjs +13 -0
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
- data/node_modules/govuk-frontend/dist/govuk/component.mjs +2 -1
- data/node_modules/govuk-frontend/dist/govuk/components/_index.import.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +87 -62
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +87 -62
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +60 -56
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +90 -32
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +90 -32
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +64 -27
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_mixin.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +43 -18
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +43 -18
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +16 -12
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_feedback.import.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_index.import.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_index.scss +5 -0
- data/node_modules/govuk-frontend/dist/govuk/components/feedback/_mixin.scss +48 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +54 -30
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +54 -30
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +27 -24
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_mixin.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_index.import.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_index.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_language-navigation.import.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/language-navigation/_mixin.scss +68 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +17 -6
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +32 -9
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +32 -9
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +5 -3
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_mixin.scss +48 -3
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +14 -6
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +14 -6
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +2 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +12 -5
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +12 -5
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_frontend-version.mixin.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/custom-properties/_functional-colours.mixin.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +8 -5
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +8 -8
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +16 -2
- data/package-lock.json +4 -4
- data/package.json +1 -1
- metadata +10 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { closestAttributeValue } from '../../common/closest-attribute-value.mjs';
|
|
2
2
|
import { ConfigurableComponent } from '../../common/configuration.mjs';
|
|
3
|
+
import { createElement } from '../../common/create-element.mjs';
|
|
3
4
|
import { ElementError } from '../../errors/index.mjs';
|
|
4
5
|
import { I18n } from '../../i18n.mjs';
|
|
5
6
|
|
|
@@ -50,9 +51,10 @@ class PasswordInput extends ConfigurableComponent {
|
|
|
50
51
|
locale: closestAttributeValue(this.$root, 'lang')
|
|
51
52
|
});
|
|
52
53
|
this.$showHideButton.removeAttribute('hidden');
|
|
53
|
-
const $screenReaderStatusMessage =
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const $screenReaderStatusMessage = createElement('div', {
|
|
55
|
+
class: 'govuk-password-input__sr-status govuk-visually-hidden',
|
|
56
|
+
'aria-live': 'polite'
|
|
57
|
+
});
|
|
56
58
|
this.$screenReaderStatusMessage = $screenReaderStatusMessage;
|
|
57
59
|
this.$input.insertAdjacentElement('afterend', $screenReaderStatusMessage);
|
|
58
60
|
this.$showHideButton.addEventListener('click', this.toggle.bind(this));
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
function isObject(option) {
|
|
30
30
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
31
31
|
}
|
|
32
|
+
function isScope($scope) {
|
|
33
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
34
|
+
}
|
|
32
35
|
function formatErrorMessage(Component, message) {
|
|
33
36
|
return `${Component.moduleName}: ${message}`;
|
|
34
37
|
}
|
|
@@ -47,11 +50,14 @@
|
|
|
47
50
|
/**
|
|
48
51
|
* Checks if GOV.UK Frontend is supported on this page
|
|
49
52
|
*
|
|
50
|
-
* @param {
|
|
53
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
51
54
|
*/
|
|
52
|
-
constructor(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
constructor(scopeOrMessage = document.body) {
|
|
56
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
57
|
+
if (!isScope(scopeOrMessage)) {
|
|
58
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
59
|
+
}
|
|
60
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
55
61
|
this.name = 'SupportError';
|
|
56
62
|
}
|
|
57
63
|
}
|
|
@@ -86,6 +92,7 @@
|
|
|
86
92
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
87
93
|
*/
|
|
88
94
|
|
|
95
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
89
96
|
class Component {
|
|
90
97
|
/**
|
|
91
98
|
* Returns the root element of the component
|
|
@@ -139,7 +146,7 @@
|
|
|
139
146
|
/**
|
|
140
147
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
141
148
|
*/
|
|
142
|
-
Component.elementType = HTMLElement;
|
|
149
|
+
Component.elementType = _self.HTMLElement;
|
|
143
150
|
|
|
144
151
|
/**
|
|
145
152
|
* Radios component
|
|
@@ -23,6 +23,9 @@ function isArray(option) {
|
|
|
23
23
|
function isObject(option) {
|
|
24
24
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
25
25
|
}
|
|
26
|
+
function isScope($scope) {
|
|
27
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
28
|
+
}
|
|
26
29
|
function formatErrorMessage(Component, message) {
|
|
27
30
|
return `${Component.moduleName}: ${message}`;
|
|
28
31
|
}
|
|
@@ -41,11 +44,14 @@ class SupportError extends GOVUKFrontendError {
|
|
|
41
44
|
/**
|
|
42
45
|
* Checks if GOV.UK Frontend is supported on this page
|
|
43
46
|
*
|
|
44
|
-
* @param {
|
|
47
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
45
48
|
*/
|
|
46
|
-
constructor(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
constructor(scopeOrMessage = document.body) {
|
|
50
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
51
|
+
if (!isScope(scopeOrMessage)) {
|
|
52
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
53
|
+
}
|
|
54
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
49
55
|
this.name = 'SupportError';
|
|
50
56
|
}
|
|
51
57
|
}
|
|
@@ -80,6 +86,7 @@ class InitError extends GOVUKFrontendError {
|
|
|
80
86
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
81
87
|
*/
|
|
82
88
|
|
|
89
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
83
90
|
class Component {
|
|
84
91
|
/**
|
|
85
92
|
* Returns the root element of the component
|
|
@@ -133,7 +140,7 @@ class Component {
|
|
|
133
140
|
/**
|
|
134
141
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
135
142
|
*/
|
|
136
|
-
Component.elementType = HTMLElement;
|
|
143
|
+
Component.elementType = _self.HTMLElement;
|
|
137
144
|
|
|
138
145
|
/**
|
|
139
146
|
* Radios component
|
|
@@ -20,6 +20,28 @@
|
|
|
20
20
|
--govuk-text-colour: #{$govuk-service-navigation-text-colour};
|
|
21
21
|
color: base.govuk-functional-colour(text);
|
|
22
22
|
background-color: $govuk-service-navigation-background;
|
|
23
|
+
|
|
24
|
+
@media print {
|
|
25
|
+
border-bottom-color: currentcolor;
|
|
26
|
+
background-color: transparent;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.govuk-service-navigation__inlining-container {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
align-items: baseline;
|
|
34
|
+
|
|
35
|
+
.govuk-service-navigation__container {
|
|
36
|
+
// Expand the container to shift the `end` slot to the right
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
|
|
39
|
+
// Ensure some space between the `end` slot and the container
|
|
40
|
+
// when displayed inline
|
|
41
|
+
&:not(:last-child) {
|
|
42
|
+
margin-right: base.govuk-spacing(6);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
23
45
|
}
|
|
24
46
|
|
|
25
47
|
.govuk-service-navigation__container {
|
|
@@ -27,9 +49,16 @@
|
|
|
27
49
|
flex-direction: column;
|
|
28
50
|
align-items: start;
|
|
29
51
|
|
|
52
|
+
// Avoid the end slot rendering on the right of the container
|
|
53
|
+
// in small viewports by ensuring the container is full width
|
|
54
|
+
@media #{base.govuk-until-breakpoint(tablet)} {
|
|
55
|
+
width: 100%;
|
|
56
|
+
}
|
|
57
|
+
|
|
30
58
|
@media #{base.govuk-from-breakpoint(tablet)} {
|
|
31
59
|
flex-direction: row;
|
|
32
60
|
flex-wrap: wrap;
|
|
61
|
+
align-items: center;
|
|
33
62
|
}
|
|
34
63
|
}
|
|
35
64
|
|
|
@@ -65,6 +94,10 @@
|
|
|
65
94
|
@include base.govuk-responsive-margin(6, $direction: right);
|
|
66
95
|
}
|
|
67
96
|
}
|
|
97
|
+
|
|
98
|
+
@media print {
|
|
99
|
+
border-color: currentcolor;
|
|
100
|
+
}
|
|
68
101
|
}
|
|
69
102
|
|
|
70
103
|
// Remove the top margin of the first nav item if there is a service name but
|
|
@@ -207,10 +240,19 @@
|
|
|
207
240
|
--govuk-text-colour: #{base.govuk-functional-colour(inverse-text)};
|
|
208
241
|
background-color: base.govuk-functional-colour(brand);
|
|
209
242
|
|
|
243
|
+
@media print {
|
|
244
|
+
--govuk-text-colour: #{base.govuk-functional-colour(print-text)};
|
|
245
|
+
background-color: transparent;
|
|
246
|
+
}
|
|
247
|
+
|
|
210
248
|
.govuk-width-container {
|
|
211
249
|
border-width: 1px 0;
|
|
212
250
|
border-style: solid;
|
|
213
251
|
border-color: $govuk-service-navigation-border-colour;
|
|
252
|
+
|
|
253
|
+
@media print {
|
|
254
|
+
border-color: currentcolor;
|
|
255
|
+
}
|
|
214
256
|
}
|
|
215
257
|
|
|
216
258
|
// Subtract 1px of space to account for the extra border-top
|
|
@@ -224,9 +266,12 @@
|
|
|
224
266
|
border-color: currentcolor;
|
|
225
267
|
}
|
|
226
268
|
|
|
227
|
-
// Override link styles
|
|
228
|
-
|
|
229
|
-
|
|
269
|
+
// Override link styles if on screens
|
|
270
|
+
// In print, we want the normal link styles to still apply
|
|
271
|
+
@media not print {
|
|
272
|
+
.govuk-service-navigation__link {
|
|
273
|
+
@include base.govuk-link-style-text;
|
|
274
|
+
}
|
|
230
275
|
}
|
|
231
276
|
|
|
232
277
|
// Override mobile menu toggle colour when not focused
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
function isObject(option) {
|
|
38
38
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
39
39
|
}
|
|
40
|
+
function isScope($scope) {
|
|
41
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
42
|
+
}
|
|
40
43
|
function formatErrorMessage(Component, message) {
|
|
41
44
|
return `${Component.moduleName}: ${message}`;
|
|
42
45
|
}
|
|
@@ -55,11 +58,14 @@
|
|
|
55
58
|
/**
|
|
56
59
|
* Checks if GOV.UK Frontend is supported on this page
|
|
57
60
|
*
|
|
58
|
-
* @param {
|
|
61
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
59
62
|
*/
|
|
60
|
-
constructor(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
constructor(scopeOrMessage = document.body) {
|
|
64
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
65
|
+
if (!isScope(scopeOrMessage)) {
|
|
66
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
67
|
+
}
|
|
68
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
63
69
|
this.name = 'SupportError';
|
|
64
70
|
}
|
|
65
71
|
}
|
|
@@ -94,6 +100,7 @@
|
|
|
94
100
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
95
101
|
*/
|
|
96
102
|
|
|
103
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
97
104
|
class Component {
|
|
98
105
|
/**
|
|
99
106
|
* Returns the root element of the component
|
|
@@ -147,7 +154,7 @@
|
|
|
147
154
|
/**
|
|
148
155
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
149
156
|
*/
|
|
150
|
-
Component.elementType = HTMLElement;
|
|
157
|
+
Component.elementType = _self.HTMLElement;
|
|
151
158
|
|
|
152
159
|
/**
|
|
153
160
|
* Service Navigation component
|
|
@@ -31,6 +31,9 @@ function isArray(option) {
|
|
|
31
31
|
function isObject(option) {
|
|
32
32
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
33
33
|
}
|
|
34
|
+
function isScope($scope) {
|
|
35
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
36
|
+
}
|
|
34
37
|
function formatErrorMessage(Component, message) {
|
|
35
38
|
return `${Component.moduleName}: ${message}`;
|
|
36
39
|
}
|
|
@@ -49,11 +52,14 @@ class SupportError extends GOVUKFrontendError {
|
|
|
49
52
|
/**
|
|
50
53
|
* Checks if GOV.UK Frontend is supported on this page
|
|
51
54
|
*
|
|
52
|
-
* @param {
|
|
55
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
53
56
|
*/
|
|
54
|
-
constructor(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
constructor(scopeOrMessage = document.body) {
|
|
58
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
59
|
+
if (!isScope(scopeOrMessage)) {
|
|
60
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
61
|
+
}
|
|
62
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
57
63
|
this.name = 'SupportError';
|
|
58
64
|
}
|
|
59
65
|
}
|
|
@@ -88,6 +94,7 @@ class InitError extends GOVUKFrontendError {
|
|
|
88
94
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
89
95
|
*/
|
|
90
96
|
|
|
97
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
91
98
|
class Component {
|
|
92
99
|
/**
|
|
93
100
|
* Returns the root element of the component
|
|
@@ -141,7 +148,7 @@ class Component {
|
|
|
141
148
|
/**
|
|
142
149
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
143
150
|
*/
|
|
144
|
-
Component.elementType = HTMLElement;
|
|
151
|
+
Component.elementType = _self.HTMLElement;
|
|
145
152
|
|
|
146
153
|
/**
|
|
147
154
|
* Service Navigation component
|
|
@@ -53,6 +53,9 @@
|
|
|
53
53
|
function isObject(option) {
|
|
54
54
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
55
55
|
}
|
|
56
|
+
function isScope($scope) {
|
|
57
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
58
|
+
}
|
|
56
59
|
function formatErrorMessage(Component, message) {
|
|
57
60
|
return `${Component.moduleName}: ${message}`;
|
|
58
61
|
}
|
|
@@ -71,11 +74,14 @@
|
|
|
71
74
|
/**
|
|
72
75
|
* Checks if GOV.UK Frontend is supported on this page
|
|
73
76
|
*
|
|
74
|
-
* @param {
|
|
77
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
75
78
|
*/
|
|
76
|
-
constructor(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
constructor(scopeOrMessage = document.body) {
|
|
80
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
81
|
+
if (!isScope(scopeOrMessage)) {
|
|
82
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
83
|
+
}
|
|
84
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
79
85
|
this.name = 'SupportError';
|
|
80
86
|
}
|
|
81
87
|
}
|
|
@@ -110,6 +116,7 @@
|
|
|
110
116
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
111
117
|
*/
|
|
112
118
|
|
|
119
|
+
const _self$1 = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
113
120
|
class Component {
|
|
114
121
|
/**
|
|
115
122
|
* Returns the root element of the component
|
|
@@ -163,8 +170,9 @@
|
|
|
163
170
|
/**
|
|
164
171
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
165
172
|
*/
|
|
166
|
-
Component.elementType = HTMLElement;
|
|
173
|
+
Component.elementType = _self$1.HTMLElement;
|
|
167
174
|
|
|
175
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
168
176
|
/**
|
|
169
177
|
* Skip link component
|
|
170
178
|
*
|
|
@@ -208,7 +216,7 @@
|
|
|
208
216
|
}));
|
|
209
217
|
}
|
|
210
218
|
}
|
|
211
|
-
SkipLink.elementType = HTMLAnchorElement;
|
|
219
|
+
SkipLink.elementType = _self.HTMLAnchorElement;
|
|
212
220
|
SkipLink.moduleName = 'govuk-skip-link';
|
|
213
221
|
|
|
214
222
|
exports.SkipLink = SkipLink;
|
|
@@ -47,6 +47,9 @@ function isArray(option) {
|
|
|
47
47
|
function isObject(option) {
|
|
48
48
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
49
49
|
}
|
|
50
|
+
function isScope($scope) {
|
|
51
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
52
|
+
}
|
|
50
53
|
function formatErrorMessage(Component, message) {
|
|
51
54
|
return `${Component.moduleName}: ${message}`;
|
|
52
55
|
}
|
|
@@ -65,11 +68,14 @@ class SupportError extends GOVUKFrontendError {
|
|
|
65
68
|
/**
|
|
66
69
|
* Checks if GOV.UK Frontend is supported on this page
|
|
67
70
|
*
|
|
68
|
-
* @param {
|
|
71
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
69
72
|
*/
|
|
70
|
-
constructor(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
constructor(scopeOrMessage = document.body) {
|
|
74
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
75
|
+
if (!isScope(scopeOrMessage)) {
|
|
76
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
77
|
+
}
|
|
78
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
73
79
|
this.name = 'SupportError';
|
|
74
80
|
}
|
|
75
81
|
}
|
|
@@ -104,6 +110,7 @@ class InitError extends GOVUKFrontendError {
|
|
|
104
110
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
105
111
|
*/
|
|
106
112
|
|
|
113
|
+
const _self$1 = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
107
114
|
class Component {
|
|
108
115
|
/**
|
|
109
116
|
* Returns the root element of the component
|
|
@@ -157,8 +164,9 @@ class Component {
|
|
|
157
164
|
/**
|
|
158
165
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
159
166
|
*/
|
|
160
|
-
Component.elementType = HTMLElement;
|
|
167
|
+
Component.elementType = _self$1.HTMLElement;
|
|
161
168
|
|
|
169
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
162
170
|
/**
|
|
163
171
|
* Skip link component
|
|
164
172
|
*
|
|
@@ -202,7 +210,7 @@ class SkipLink extends Component {
|
|
|
202
210
|
}));
|
|
203
211
|
}
|
|
204
212
|
}
|
|
205
|
-
SkipLink.elementType = HTMLAnchorElement;
|
|
213
|
+
SkipLink.elementType = _self.HTMLAnchorElement;
|
|
206
214
|
SkipLink.moduleName = 'govuk-skip-link';
|
|
207
215
|
|
|
208
216
|
export { SkipLink };
|
|
@@ -2,6 +2,7 @@ import { setFocus } from '../../common/index.mjs';
|
|
|
2
2
|
import { Component } from '../../component.mjs';
|
|
3
3
|
import { ElementError } from '../../errors/index.mjs';
|
|
4
4
|
|
|
5
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
5
6
|
/**
|
|
6
7
|
* Skip link component
|
|
7
8
|
*
|
|
@@ -45,7 +46,7 @@ class SkipLink extends Component {
|
|
|
45
46
|
}));
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
SkipLink.elementType = HTMLAnchorElement;
|
|
49
|
+
SkipLink.elementType = _self.HTMLAnchorElement;
|
|
49
50
|
SkipLink.moduleName = 'govuk-skip-link';
|
|
50
51
|
|
|
51
52
|
export { SkipLink };
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
function isObject(option) {
|
|
38
38
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
39
39
|
}
|
|
40
|
+
function isScope($scope) {
|
|
41
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
42
|
+
}
|
|
40
43
|
function formatErrorMessage(Component, message) {
|
|
41
44
|
return `${Component.moduleName}: ${message}`;
|
|
42
45
|
}
|
|
@@ -55,11 +58,14 @@
|
|
|
55
58
|
/**
|
|
56
59
|
* Checks if GOV.UK Frontend is supported on this page
|
|
57
60
|
*
|
|
58
|
-
* @param {
|
|
61
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
59
62
|
*/
|
|
60
|
-
constructor(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
constructor(scopeOrMessage = document.body) {
|
|
64
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
65
|
+
if (!isScope(scopeOrMessage)) {
|
|
66
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
67
|
+
}
|
|
68
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
63
69
|
this.name = 'SupportError';
|
|
64
70
|
}
|
|
65
71
|
}
|
|
@@ -94,6 +100,7 @@
|
|
|
94
100
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
95
101
|
*/
|
|
96
102
|
|
|
103
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
97
104
|
class Component {
|
|
98
105
|
/**
|
|
99
106
|
* Returns the root element of the component
|
|
@@ -147,7 +154,7 @@
|
|
|
147
154
|
/**
|
|
148
155
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
149
156
|
*/
|
|
150
|
-
Component.elementType = HTMLElement;
|
|
157
|
+
Component.elementType = _self.HTMLElement;
|
|
151
158
|
|
|
152
159
|
/**
|
|
153
160
|
* Tabs component
|
|
@@ -31,6 +31,9 @@ function isArray(option) {
|
|
|
31
31
|
function isObject(option) {
|
|
32
32
|
return !!option && typeof option === 'object' && !isArray(option);
|
|
33
33
|
}
|
|
34
|
+
function isScope($scope) {
|
|
35
|
+
return !!$scope && ($scope instanceof Element || $scope instanceof Document);
|
|
36
|
+
}
|
|
34
37
|
function formatErrorMessage(Component, message) {
|
|
35
38
|
return `${Component.moduleName}: ${message}`;
|
|
36
39
|
}
|
|
@@ -49,11 +52,14 @@ class SupportError extends GOVUKFrontendError {
|
|
|
49
52
|
/**
|
|
50
53
|
* Checks if GOV.UK Frontend is supported on this page
|
|
51
54
|
*
|
|
52
|
-
* @param {
|
|
55
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
53
56
|
*/
|
|
54
|
-
constructor(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
constructor(scopeOrMessage = document.body) {
|
|
58
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
59
|
+
if (!isScope(scopeOrMessage)) {
|
|
60
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
61
|
+
}
|
|
62
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
57
63
|
this.name = 'SupportError';
|
|
58
64
|
}
|
|
59
65
|
}
|
|
@@ -88,6 +94,7 @@ class InitError extends GOVUKFrontendError {
|
|
|
88
94
|
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
|
89
95
|
*/
|
|
90
96
|
|
|
97
|
+
const _self = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
91
98
|
class Component {
|
|
92
99
|
/**
|
|
93
100
|
* Returns the root element of the component
|
|
@@ -141,7 +148,7 @@ class Component {
|
|
|
141
148
|
/**
|
|
142
149
|
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
|
143
150
|
*/
|
|
144
|
-
Component.elementType = HTMLElement;
|
|
151
|
+
Component.elementType = _self.HTMLElement;
|
|
145
152
|
|
|
146
153
|
/**
|
|
147
154
|
* Tabs component
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isObject, formatErrorMessage } from '../common/index.mjs';
|
|
1
|
+
import { isObject, formatErrorMessage, isScope } from '../common/index.mjs';
|
|
2
2
|
|
|
3
3
|
class GOVUKFrontendError extends Error {
|
|
4
4
|
constructor(...args) {
|
|
@@ -10,11 +10,14 @@ class SupportError extends GOVUKFrontendError {
|
|
|
10
10
|
/**
|
|
11
11
|
* Checks if GOV.UK Frontend is supported on this page
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {Element | Document | null | string} [scopeOrMessage] - HTML element `<body>` checked for browser support or support error message
|
|
14
14
|
*/
|
|
15
|
-
constructor(
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
constructor(scopeOrMessage = document.body) {
|
|
16
|
+
let supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
|
17
|
+
if (!isScope(scopeOrMessage)) {
|
|
18
|
+
supportMessage = 'GOV.UK Frontend initialised without `<script type="module">`';
|
|
19
|
+
}
|
|
20
|
+
super(typeof scopeOrMessage === 'string' ? scopeOrMessage : supportMessage);
|
|
18
21
|
this.name = 'SupportError';
|
|
19
22
|
}
|
|
20
23
|
}
|