@govuk-one-login/frontend-ui 1.2.1 → 1.3.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.
- package/build/all.css +1 -1
- package/build/cjs/index-fe.cjs +102 -116
- package/build/cjs/index.cjs +6 -4
- package/build/cjs/index.d.ts +1 -37
- package/build/cjs/index.d.ts.map +1 -1
- package/build/cjs/typescript/spinner.d.ts +6 -0
- package/build/cjs/typescript/spinner.d.ts.map +1 -0
- package/build/cjs/utils/types.d.ts +51 -0
- package/build/cjs/utils/types.d.ts.map +1 -0
- package/build/components/cookie-banner/template.njk +12 -3
- package/build/components/footer/_index.scss +9 -0
- package/build/components/header/_index.scss +63 -34
- package/build/components/phase-banner/_index.scss +6 -0
- package/build/components/phase-banner/template.njk +2 -1
- package/build/components/skip-link/template.njk +5 -1
- package/build/esm/index-fe.js +102 -116
- package/build/esm/index.d.ts +1 -37
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +6 -4
- package/build/esm/typescript/spinner.d.ts +6 -0
- package/build/esm/typescript/spinner.d.ts.map +1 -0
- package/build/esm/utils/types.d.ts +51 -0
- package/build/esm/utils/types.d.ts.map +1 -0
- package/package.json +11 -6
- package/build/cjs/__tests__/index.spec.d.ts +0 -2
- package/build/cjs/__tests__/index.spec.d.ts.map +0 -1
- package/build/cjs/__tests__/logger.spec.d.ts +0 -2
- package/build/cjs/__tests__/logger.spec.d.ts.map +0 -1
- package/build/components/spinner/javascript/spinner.js +0 -118
- package/build/esm/__tests__/index.spec.d.ts +0 -2
- package/build/esm/__tests__/index.spec.d.ts.map +0 -1
- package/build/esm/__tests__/logger.spec.d.ts +0 -2
- package/build/esm/__tests__/logger.spec.d.ts.map +0 -1
package/build/all.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@media(max-width: 640px){.govuk-header__navigation-item{border-left:none !important}.govuk-template--rebranded .govuk-header__navigation-list{padding-bottom:0px !important}.govuk-header__navigation-item{padding-top:
|
|
1
|
+
@media(max-width: 640px){.govuk-header__navigation-item{border-left:none !important}.govuk-template--rebranded .govuk-header__navigation-list{padding-bottom:0px !important}.govuk-header__navigation-item{padding-top:8px !important}}.frontendUi_header_signOut-item{padding:5px 0px 5px 30px;border-left:1px solid #b1b4b6;margin-left:auto}.frontendUi_header_signOut-item--rebrand{border-left:none;padding:5px 0px 5px 0px;margin-left:auto;font-weight:700 !important}.frontendUi_header__signOut{display:flex;flex-wrap:wrap}.frontendUi-header__content{margin-left:auto}.govuk-header__navigation--signOut{padding:15px 0 15px !important}.govuk-template--rebranded .govuk-header__navigation{padding:15px 0 15px !important}@media(max-width: 640px){.govuk-header__navigation--signOut{padding:18px 0 8px !important}.govuk-template--rebranded .govuk-header__navigation{padding:18px 0 8px !important}}.govuk-template--rebranded .govuk-header__navigation-item a{font-weight:700 !important}.govuk-template--rebranded .govuk-header__navigation-item{padding-top:5px !important}@media(min-width: 20em)and (max-width: 48.0525em){.govuk-template--rebranded .govuk-header__navigation-list{padding-bottom:0px}}@media(max-width: 323px){.govuk-header__logo{padding-right:5px}.frontendUi_header_signOut-item{padding-left:0px}}@media(max-width: 261px){.frontendUi-header__content{margin-left:unset}.govuk-template--rebranded .govuk-header__navigation{padding:0px 0 8px !important}.govuk-header__logotype{max-width:100%;max-height:auto}.govuk-template--rebranded .govuk-header__logo{padding-top:5% !important;padding-bottom:5% !important}}.govuk-tag{font-family:"GDS Transport",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-weight:700;font-size:14px;font-size:.875rem;line-height:1;display:inline-block;padding-top:5px;padding-right:8px;padding-bottom:4px;padding-left:8px;outline:2px solid rgba(0,0,0,0);outline-offset:-2px;color:#fff !important;background-color:#1d70b8 !important;letter-spacing:1px !important;text-decoration:none !important;text-transform:uppercase !important}/*! Copyright (c) 2011 by Margaret Calvert & Henrik Kubel. All rights reserved. The font has been customised for exclusive use on gov.uk. This cut is not commercially available. */@font-face{font-family:"GDS Transport";font-style:normal;font-weight:normal;src:url("/assets/fonts/light-94a07e06a1-v2.woff2") format("woff2"),url("/assets/fonts/light-f591b13f7d-v2.woff") format("woff");font-display:fallback}@font-face{font-family:"GDS Transport";font-style:normal;font-weight:bold;src:url("/assets/fonts/bold-b542beb274-v2.woff2") format("woff2"),url("/assets/fonts/bold-affa96571d-v2.woff") format("woff");font-display:fallback}@media print{.govuk-tag{font-family:sans-serif}}@media(min-width: 40.0625em){.govuk-tag{font-size:16px;font-size:1rem;line-height:1}}@media print{.govuk-tag{font-size:14pt;line-height:1}}@media(max-width: 256px){.govuk-phase-banner__content{display:block}}.language-select{margin:15px 0 15px 0}.language-select__list{margin-top:1em;text-align:right}.language-select__list-item{display:inline-block}.language-select__list-item:first-child::after{content:"";display:inline-block;position:relative;top:.1875em;height:1em;border-right:.09375em solid #000}.language-select__list-item a,.language-select__list-item [aria-current]{padding:.3125em}@media screen and (max-width: 641px){.language-select__list{float:none;text-align:left;padding-bottom:10px;border-bottom:1px solid #b1b4b6}}.spinner{width:80px;height:80px;border-radius:50%;border-width:12px;border-style:solid;border-color:#dee0e2;border-top-color:#005ea5;margin-bottom:govuk-spacing(3)}@media(forced-colors: active){.spinner{forced-color-adjust:none;border-top-color:rgba(0,0,0,0) !important}}@media not (prefers-reduced-motion){.spinner{-webkit-animation:spin 2s linear infinite;animation:spin 2s linear infinite}}@media(prefers-reduced-motion){.spinner{transform:rotate(0.125turn)}}.spinner__ready{border-color:#005ea5;-webkit-animation:none;animation:none}#spinner-container__error .spinner,#spinner-container__error .spinner-state-text{display:none}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.centre{margin-left:auto;margin-right:auto;text-align:center;display:block}.govuk-footer__copyright-logo::before{background-image:url("../frontendUiAssets/images/govuk-crest.svg"),url("/frontendUiAssets/images/govuk-crest.svg") !important}.govuk-footer__copyright-logo{background-image:url("../frontendUiAssets/images/govuk-crest.svg"),url("/frontendUiAssets/images/govuk-crest.svg") !important}@media(max-width: 256px){.govuk-footer__crown{max-width:100%;max-height:auto}}
|
package/build/cjs/index-fe.cjs
CHANGED
|
@@ -1,122 +1,108 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const WaitInteractions = (() => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
init: () => {
|
|
107
|
-
timers.updateDomTimer = setInterval(updateDom, 2000);
|
|
108
|
-
|
|
109
|
-
timers.abortUnresponsiveRequest = setTimeout(() => {
|
|
110
|
-
reflectError();
|
|
111
|
-
}, 15000);
|
|
112
|
-
|
|
113
|
-
updateDom();
|
|
114
|
-
|
|
115
|
-
requestIDProcessingStatus().then(() => {
|
|
116
|
-
updateDom();
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
};
|
|
4
|
+
const content = {
|
|
5
|
+
initial: {
|
|
6
|
+
spinnerState: "pending",
|
|
7
|
+
},
|
|
8
|
+
complete: { spinnerState: "completed" },
|
|
9
|
+
};
|
|
10
|
+
const state = {
|
|
11
|
+
spinnerState: content.initial.spinnerState,
|
|
12
|
+
done: false,
|
|
13
|
+
virtualDom: [],
|
|
14
|
+
};
|
|
15
|
+
const timers = {};
|
|
16
|
+
const createVirtualDom = () => {
|
|
17
|
+
const initialState = [
|
|
18
|
+
{
|
|
19
|
+
nodeName: "div",
|
|
20
|
+
id: "spinner",
|
|
21
|
+
classes: ["spinner", "spinner__pending", "centre", state.spinnerState],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
return initialState;
|
|
25
|
+
};
|
|
26
|
+
const vDomHasChanged = (currentVDom, nextVDom) => {
|
|
27
|
+
return JSON.stringify(currentVDom) !== JSON.stringify(nextVDom);
|
|
28
|
+
};
|
|
29
|
+
const updateDom = () => {
|
|
30
|
+
var _a;
|
|
31
|
+
const vDomChanged = vDomHasChanged(state.virtualDom, createVirtualDom());
|
|
32
|
+
const container = document.getElementById("spinner-container");
|
|
33
|
+
if (vDomChanged) {
|
|
34
|
+
state.virtualDom = createVirtualDom();
|
|
35
|
+
const elements = (_a = state === null || state === void 0 ? void 0 : state.virtualDom) === null || _a === void 0 ? void 0 : _a.map(convert);
|
|
36
|
+
container === null || container === void 0 ? void 0 : container.replaceChildren(...elements);
|
|
37
|
+
}
|
|
38
|
+
if (state.error) {
|
|
39
|
+
container === null || container === void 0 ? void 0 : container.classList.add("spinner-container__error");
|
|
40
|
+
}
|
|
41
|
+
if (state.done) {
|
|
42
|
+
clearInterval(timers.updateDomTimer);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const reflectCompletion = () => {
|
|
46
|
+
state.spinnerState = "spinner__ready";
|
|
47
|
+
state.spinnerStateText = content.complete.spinnerState;
|
|
48
|
+
state.done = true;
|
|
49
|
+
};
|
|
50
|
+
const reflectError = () => {
|
|
51
|
+
state.spinnerState = "spinner__failed";
|
|
52
|
+
state.done = true;
|
|
53
|
+
state.error = true;
|
|
54
|
+
};
|
|
55
|
+
const convert = (node) => {
|
|
56
|
+
const el = document.createElement(node.nodeName);
|
|
57
|
+
if (node.text)
|
|
58
|
+
el.textContent = node.text;
|
|
59
|
+
if (node.innerHTML)
|
|
60
|
+
el.innerHTML = node.innerHTML;
|
|
61
|
+
if (node.id)
|
|
62
|
+
el.id = node.id;
|
|
63
|
+
if (node.classes)
|
|
64
|
+
el.classList.add(...node.classes);
|
|
65
|
+
return el;
|
|
66
|
+
};
|
|
67
|
+
const notInErrorOrDoneState = () => {
|
|
68
|
+
return !(state.done || state.error);
|
|
69
|
+
};
|
|
70
|
+
const requestIDProcessingStatus = async () => {
|
|
71
|
+
var _a;
|
|
72
|
+
const apiRoute = (_a = document === null || document === void 0 ? void 0 : document.getElementById("spinner-container")) === null || _a === void 0 ? void 0 : _a.dataset.apiRoute;
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(apiRoute);
|
|
75
|
+
if (response.status !== 200) {
|
|
76
|
+
throw new Error(`Status code ${response.status} received`);
|
|
77
|
+
}
|
|
78
|
+
const data = await response.json();
|
|
79
|
+
if (data.status === "Clear to proceed") {
|
|
80
|
+
reflectCompletion();
|
|
81
|
+
}
|
|
82
|
+
else if (notInErrorOrDoneState()) {
|
|
83
|
+
setTimeout(async () => {
|
|
84
|
+
await requestIDProcessingStatus();
|
|
85
|
+
}, 1000);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
console.log(e);
|
|
90
|
+
reflectError();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
state: state,
|
|
95
|
+
init: () => {
|
|
96
|
+
timers.updateDomTimer = setInterval(updateDom, 2000);
|
|
97
|
+
timers.abortUnresponsiveRequest = setTimeout(() => {
|
|
98
|
+
reflectError();
|
|
99
|
+
}, 15000);
|
|
100
|
+
updateDom();
|
|
101
|
+
requestIDProcessingStatus().then(() => {
|
|
102
|
+
updateDom();
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
};
|
|
120
106
|
})();
|
|
121
107
|
|
|
122
108
|
exports.WaitInteractions = WaitInteractions;
|
package/build/cjs/index.cjs
CHANGED
|
@@ -38,7 +38,7 @@ var footer$1 = {
|
|
|
38
38
|
text: "Telerau ac amodau"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
href: "https://
|
|
41
|
+
href: "https://www.gov.uk/government/publications/govuk-one-login-privacy-notice",
|
|
42
42
|
text: "Hysbysiad preifatrwydd"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
@@ -68,7 +68,8 @@ var languageSelect$1 = {
|
|
|
68
68
|
var phaseBanner$1 = {
|
|
69
69
|
tag: "BETA",
|
|
70
70
|
text: "Mae hwn yn wasanaeth newydd. Helpwch ni i'w wella a ",
|
|
71
|
-
link: "rhoi eich adborth (agor mewn tab newydd)."
|
|
71
|
+
link: "rhoi eich adborth (agor mewn tab newydd).",
|
|
72
|
+
ariaLabel: "Rhyddhau Baner Cyfnod"
|
|
72
73
|
};
|
|
73
74
|
var skipLink$1 = {
|
|
74
75
|
title: "Neidio i'r prif gynnwys"
|
|
@@ -117,7 +118,7 @@ var footer = {
|
|
|
117
118
|
text: "Terms and conditions"
|
|
118
119
|
},
|
|
119
120
|
{
|
|
120
|
-
href: "https://
|
|
121
|
+
href: "https://www.gov.uk/government/publications/govuk-one-login-privacy-notice",
|
|
121
122
|
text: "Privacy notice"
|
|
122
123
|
},
|
|
123
124
|
{
|
|
@@ -147,7 +148,8 @@ var languageSelect = {
|
|
|
147
148
|
var phaseBanner = {
|
|
148
149
|
tag: "BETA",
|
|
149
150
|
text: "This is a new service. Help us improve it and ",
|
|
150
|
-
link: "give your feedback (opens in a new tab)."
|
|
151
|
+
link: "give your feedback (opens in a new tab).",
|
|
152
|
+
ariaLabel: "Release Phase Banner"
|
|
151
153
|
};
|
|
152
154
|
var skipLink = {
|
|
153
155
|
title: "Skip to main content"
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { NextFunction, Request, Response } from "express";
|
|
3
|
-
interface I18nData {
|
|
4
|
-
language: string;
|
|
5
|
-
store: {
|
|
6
|
-
data: {
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface ExpressRequest extends Request {
|
|
12
|
-
i18n: I18nData;
|
|
13
|
-
}
|
|
14
|
-
interface ExpressResponse extends Response {
|
|
15
|
-
locals: {
|
|
16
|
-
translations: unknown;
|
|
17
|
-
basePath?: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
interface PlainRequest {
|
|
21
|
-
i18n: I18nData;
|
|
22
|
-
}
|
|
23
|
-
interface PlainResponse {
|
|
24
|
-
locals: {
|
|
25
|
-
translations: unknown;
|
|
26
|
-
basePath?: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare function frontendUiMiddleware(req: ExpressRequest, res: ExpressResponse, next: NextFunction): void;
|
|
30
|
-
export declare function frontendUiMiddleware(req: PlainRequest, res: PlainResponse, next: NextFunction): void;
|
|
31
|
-
export declare const setFrontendUiTranslations: (instanceI18n: typeof i18next) => void;
|
|
32
|
-
export declare const frontendUiMiddlewareIdentityBypass: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => void;
|
|
33
|
-
export declare function addLanguageParam(language: string, url?: URL): string;
|
|
34
|
-
export declare function contactUsUrl(baseUrl: string, urlToAppend: string): string | null;
|
|
35
|
-
export declare const setBaseTranslations: (instanceI18n: typeof i18next, filePath?: string) => void;
|
|
36
|
-
export declare const getTranslationObject: (locale: string, filepath?: string) => Record<string, unknown>;
|
|
37
|
-
export {};
|
|
1
|
+
export { WaitInteractions } from "./typescript/spinner";
|
|
38
2
|
//# sourceMappingURL=index.d.ts.map
|
package/build/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../frontend-src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../frontend-src/typescript/spinner.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAEN,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,gBAAgB;;;CA2HzB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface virtualDom {
|
|
2
|
+
nodeName?: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
classes?: string[];
|
|
5
|
+
}
|
|
6
|
+
export type error = {
|
|
7
|
+
spinnerState: string;
|
|
8
|
+
done: boolean;
|
|
9
|
+
virtualDom: never[];
|
|
10
|
+
state: {
|
|
11
|
+
error: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type apiRoute = RequestInfo | URL;
|
|
15
|
+
export type content = {
|
|
16
|
+
initial: {
|
|
17
|
+
spinnerState: string | virtualDom;
|
|
18
|
+
};
|
|
19
|
+
complete: {
|
|
20
|
+
spinnerState: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type timers = {
|
|
24
|
+
updateDomTimer?: unknown | number;
|
|
25
|
+
abortUnresponsiveRequest?: unknown | number;
|
|
26
|
+
};
|
|
27
|
+
export type state = {
|
|
28
|
+
error?: boolean | error;
|
|
29
|
+
spinnerState?: string;
|
|
30
|
+
done?: boolean;
|
|
31
|
+
virtualDom?: unknown[];
|
|
32
|
+
timers?: {
|
|
33
|
+
timers: timers;
|
|
34
|
+
};
|
|
35
|
+
spinnerStateText?: string;
|
|
36
|
+
};
|
|
37
|
+
export type node = {
|
|
38
|
+
text: object;
|
|
39
|
+
innerHTML: HTMLElement;
|
|
40
|
+
id: string;
|
|
41
|
+
classes: string[];
|
|
42
|
+
nodeName: keyof HTMLElementTagNameMap;
|
|
43
|
+
textContent: unknown | HTMLElement | string;
|
|
44
|
+
el: unknown | HTMLElement | string;
|
|
45
|
+
};
|
|
46
|
+
export type initialState = {
|
|
47
|
+
nodeName: string;
|
|
48
|
+
id: string;
|
|
49
|
+
classes: (string | undefined)[];
|
|
50
|
+
}[];
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../frontend-src/utils/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,KAAK,EAAE,CAAC;IACpB,KAAK,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,GAAG,CAAC;AAEzC,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,GAAG,UAAU,CAAC;KACnC,CAAC;IACF,QAAQ,EAAE;QACR,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC,wBAAwB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,WAAW,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;IACtC,WAAW,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;IAC5C,EAAE,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;CACjC,EAAE,CAAC"}
|
|
@@ -43,17 +43,26 @@
|
|
|
43
43
|
text: cookieBanner.acceptAdditionalCookies,
|
|
44
44
|
type: "button",
|
|
45
45
|
name: "cookiesAccept",
|
|
46
|
-
value: "accept"
|
|
46
|
+
value: "accept",
|
|
47
|
+
attributes: {
|
|
48
|
+
"aria-label": cookieBanner.acceptAdditionalCookies
|
|
49
|
+
}
|
|
47
50
|
},
|
|
48
51
|
{
|
|
49
52
|
text: cookieBanner.rejectAdditionalCookies,
|
|
50
53
|
type: "button",
|
|
51
54
|
name: "cookiesReject",
|
|
52
|
-
value: "reject"
|
|
55
|
+
value: "reject",
|
|
56
|
+
attributes: {
|
|
57
|
+
"aria-label": cookieBanner.rejectAdditionalCookies
|
|
58
|
+
}
|
|
53
59
|
},
|
|
54
60
|
{
|
|
55
61
|
text: cookieBanner.viewCookies,
|
|
56
|
-
href: "https://signin.account.gov.uk/cookies"
|
|
62
|
+
href: "https://signin.account.gov.uk/cookies",
|
|
63
|
+
attributes: {
|
|
64
|
+
"aria-label": cookieBanner.viewCookies
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
]
|
|
59
68
|
},
|
|
@@ -1,73 +1,102 @@
|
|
|
1
1
|
@media (max-width: 640px) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
.govuk-header__navigation-item {
|
|
3
|
+
border-left: none !important;
|
|
4
|
+
}
|
|
5
|
+
.govuk-template--rebranded .govuk-header__navigation-list {
|
|
6
|
+
padding-bottom: 0px !important;
|
|
7
|
+
}
|
|
8
8
|
|
|
9
9
|
.govuk-header__navigation-item{
|
|
10
|
-
padding-top:
|
|
10
|
+
padding-top: 8px !important;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.frontendUi_header_signOut-item{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
.frontendUi_header_signOut-item {
|
|
15
|
+
padding: 5px 0px 5px 30px;
|
|
16
|
+
border-left: 1px solid #b1b4b6;
|
|
17
|
+
margin-left: auto;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
.frontendUi_header_signOut-item--rebrand{
|
|
20
|
+
.frontendUi_header_signOut-item--rebrand {
|
|
21
21
|
border-left: none;
|
|
22
|
-
padding: 5px 0px 5px
|
|
22
|
+
padding: 5px 0px 5px 0px;
|
|
23
23
|
margin-left: auto;
|
|
24
24
|
font-weight: 700 !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.frontendUi_header__signOut{
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
.frontendUi_header__signOut {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.frontendUi-header__content{
|
|
33
|
-
|
|
32
|
+
.frontendUi-header__content {
|
|
33
|
+
margin-left: auto;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.govuk-header__navigation--signOut{
|
|
36
|
+
.govuk-header__navigation--signOut {
|
|
37
37
|
padding: 15px 0 15px !important;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.govuk-template--rebranded .govuk-header__navigation{
|
|
40
|
+
.govuk-template--rebranded .govuk-header__navigation {
|
|
41
41
|
padding: 15px 0 15px !important;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
@media (max-width: 640px) {
|
|
45
|
-
.govuk-header__navigation--signOut{
|
|
46
|
-
|
|
47
|
-
}
|
|
45
|
+
.govuk-header__navigation--signOut {
|
|
46
|
+
padding: 18px 0 8px !important;
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
.govuk-template--rebranded .govuk-header__navigation{
|
|
50
|
-
|
|
49
|
+
.govuk-template--rebranded .govuk-header__navigation {
|
|
50
|
+
padding: 18px 0 8px !important;
|
|
51
|
+
}
|
|
51
52
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
53
|
|
|
55
54
|
.govuk-template--rebranded .govuk-header__navigation-item a {
|
|
56
55
|
font-weight: 700 !important;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
.govuk-template--rebranded .govuk-header__navigation-item{
|
|
58
|
+
.govuk-template--rebranded .govuk-header__navigation-item {
|
|
60
59
|
padding-top: 5px !important;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
@media (min-width: 20em) and (max-width: 48.0525em) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
.govuk-template--rebranded .govuk-header__navigation-list {
|
|
64
|
+
padding-bottom: 0px;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@media (max-width: 323px) {
|
|
69
|
+
|
|
70
|
+
.govuk-header__logo{
|
|
71
|
+
padding-right: 5px;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
.frontendUi_header_signOut-item
|
|
75
|
+
{
|
|
76
|
+
padding-left: 0px;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (max-width: 261px) {
|
|
81
|
+
|
|
82
|
+
.frontendUi-header__content {
|
|
71
83
|
margin-left: unset;
|
|
72
84
|
}
|
|
73
|
-
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
.govuk-template--rebranded .govuk-header__navigation {
|
|
90
|
+
padding: 0px 0 8px !important;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.govuk-header__logotype{
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
max-height: auto;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.govuk-template--rebranded .govuk-header__logo{
|
|
99
|
+
padding-top: 5% !important;
|
|
100
|
+
padding-bottom: 5% !important;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{% set phaseBanner = params.translations %}
|
|
2
2
|
{% from "./tag/macro.njk" import frontendUiTag -%}
|
|
3
3
|
|
|
4
|
-
<div class="govuk-phase-banner
|
|
4
|
+
<div role="region" class="govuk-phase-banner
|
|
5
5
|
{%- if params.classes %} {{ params.classes }}{% endif %}"{% for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
6
6
|
<p class="govuk-phase-banner__content">
|
|
7
7
|
{{ frontendUiTag({
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
{{ phaseBanner.text }}
|
|
17
17
|
{% endif %}
|
|
18
18
|
<a class="govuk-link"
|
|
19
|
+
aria-label= "{{ phaseBanner.ariaLabel }}"
|
|
19
20
|
rel="noopener"
|
|
20
21
|
target="_blank"
|
|
21
22
|
href="{{ contactUsUrl(params.contactUrl, params.url) or contactUsUrl('https://signin.account.gov.uk/contact-us', params.url) }}">
|
package/build/esm/index-fe.js
CHANGED
|
@@ -1,120 +1,106 @@
|
|
|
1
1
|
const WaitInteractions = (() => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
init: () => {
|
|
105
|
-
timers.updateDomTimer = setInterval(updateDom, 2000);
|
|
106
|
-
|
|
107
|
-
timers.abortUnresponsiveRequest = setTimeout(() => {
|
|
108
|
-
reflectError();
|
|
109
|
-
}, 15000);
|
|
110
|
-
|
|
111
|
-
updateDom();
|
|
112
|
-
|
|
113
|
-
requestIDProcessingStatus().then(() => {
|
|
114
|
-
updateDom();
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
};
|
|
2
|
+
const content = {
|
|
3
|
+
initial: {
|
|
4
|
+
spinnerState: "pending",
|
|
5
|
+
},
|
|
6
|
+
complete: { spinnerState: "completed" },
|
|
7
|
+
};
|
|
8
|
+
const state = {
|
|
9
|
+
spinnerState: content.initial.spinnerState,
|
|
10
|
+
done: false,
|
|
11
|
+
virtualDom: [],
|
|
12
|
+
};
|
|
13
|
+
const timers = {};
|
|
14
|
+
const createVirtualDom = () => {
|
|
15
|
+
const initialState = [
|
|
16
|
+
{
|
|
17
|
+
nodeName: "div",
|
|
18
|
+
id: "spinner",
|
|
19
|
+
classes: ["spinner", "spinner__pending", "centre", state.spinnerState],
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
return initialState;
|
|
23
|
+
};
|
|
24
|
+
const vDomHasChanged = (currentVDom, nextVDom) => {
|
|
25
|
+
return JSON.stringify(currentVDom) !== JSON.stringify(nextVDom);
|
|
26
|
+
};
|
|
27
|
+
const updateDom = () => {
|
|
28
|
+
var _a;
|
|
29
|
+
const vDomChanged = vDomHasChanged(state.virtualDom, createVirtualDom());
|
|
30
|
+
const container = document.getElementById("spinner-container");
|
|
31
|
+
if (vDomChanged) {
|
|
32
|
+
state.virtualDom = createVirtualDom();
|
|
33
|
+
const elements = (_a = state === null || state === void 0 ? void 0 : state.virtualDom) === null || _a === void 0 ? void 0 : _a.map(convert);
|
|
34
|
+
container === null || container === void 0 ? void 0 : container.replaceChildren(...elements);
|
|
35
|
+
}
|
|
36
|
+
if (state.error) {
|
|
37
|
+
container === null || container === void 0 ? void 0 : container.classList.add("spinner-container__error");
|
|
38
|
+
}
|
|
39
|
+
if (state.done) {
|
|
40
|
+
clearInterval(timers.updateDomTimer);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const reflectCompletion = () => {
|
|
44
|
+
state.spinnerState = "spinner__ready";
|
|
45
|
+
state.spinnerStateText = content.complete.spinnerState;
|
|
46
|
+
state.done = true;
|
|
47
|
+
};
|
|
48
|
+
const reflectError = () => {
|
|
49
|
+
state.spinnerState = "spinner__failed";
|
|
50
|
+
state.done = true;
|
|
51
|
+
state.error = true;
|
|
52
|
+
};
|
|
53
|
+
const convert = (node) => {
|
|
54
|
+
const el = document.createElement(node.nodeName);
|
|
55
|
+
if (node.text)
|
|
56
|
+
el.textContent = node.text;
|
|
57
|
+
if (node.innerHTML)
|
|
58
|
+
el.innerHTML = node.innerHTML;
|
|
59
|
+
if (node.id)
|
|
60
|
+
el.id = node.id;
|
|
61
|
+
if (node.classes)
|
|
62
|
+
el.classList.add(...node.classes);
|
|
63
|
+
return el;
|
|
64
|
+
};
|
|
65
|
+
const notInErrorOrDoneState = () => {
|
|
66
|
+
return !(state.done || state.error);
|
|
67
|
+
};
|
|
68
|
+
const requestIDProcessingStatus = async () => {
|
|
69
|
+
var _a;
|
|
70
|
+
const apiRoute = (_a = document === null || document === void 0 ? void 0 : document.getElementById("spinner-container")) === null || _a === void 0 ? void 0 : _a.dataset.apiRoute;
|
|
71
|
+
try {
|
|
72
|
+
const response = await fetch(apiRoute);
|
|
73
|
+
if (response.status !== 200) {
|
|
74
|
+
throw new Error(`Status code ${response.status} received`);
|
|
75
|
+
}
|
|
76
|
+
const data = await response.json();
|
|
77
|
+
if (data.status === "Clear to proceed") {
|
|
78
|
+
reflectCompletion();
|
|
79
|
+
}
|
|
80
|
+
else if (notInErrorOrDoneState()) {
|
|
81
|
+
setTimeout(async () => {
|
|
82
|
+
await requestIDProcessingStatus();
|
|
83
|
+
}, 1000);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
console.log(e);
|
|
88
|
+
reflectError();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
state: state,
|
|
93
|
+
init: () => {
|
|
94
|
+
timers.updateDomTimer = setInterval(updateDom, 2000);
|
|
95
|
+
timers.abortUnresponsiveRequest = setTimeout(() => {
|
|
96
|
+
reflectError();
|
|
97
|
+
}, 15000);
|
|
98
|
+
updateDom();
|
|
99
|
+
requestIDProcessingStatus().then(() => {
|
|
100
|
+
updateDom();
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
};
|
|
118
104
|
})();
|
|
119
105
|
|
|
120
106
|
export { WaitInteractions };
|
package/build/esm/index.d.ts
CHANGED
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { NextFunction, Request, Response } from "express";
|
|
3
|
-
interface I18nData {
|
|
4
|
-
language: string;
|
|
5
|
-
store: {
|
|
6
|
-
data: {
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface ExpressRequest extends Request {
|
|
12
|
-
i18n: I18nData;
|
|
13
|
-
}
|
|
14
|
-
interface ExpressResponse extends Response {
|
|
15
|
-
locals: {
|
|
16
|
-
translations: unknown;
|
|
17
|
-
basePath?: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
interface PlainRequest {
|
|
21
|
-
i18n: I18nData;
|
|
22
|
-
}
|
|
23
|
-
interface PlainResponse {
|
|
24
|
-
locals: {
|
|
25
|
-
translations: unknown;
|
|
26
|
-
basePath?: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare function frontendUiMiddleware(req: ExpressRequest, res: ExpressResponse, next: NextFunction): void;
|
|
30
|
-
export declare function frontendUiMiddleware(req: PlainRequest, res: PlainResponse, next: NextFunction): void;
|
|
31
|
-
export declare const setFrontendUiTranslations: (instanceI18n: typeof i18next) => void;
|
|
32
|
-
export declare const frontendUiMiddlewareIdentityBypass: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => void;
|
|
33
|
-
export declare function addLanguageParam(language: string, url?: URL): string;
|
|
34
|
-
export declare function contactUsUrl(baseUrl: string, urlToAppend: string): string | null;
|
|
35
|
-
export declare const setBaseTranslations: (instanceI18n: typeof i18next, filePath?: string) => void;
|
|
36
|
-
export declare const getTranslationObject: (locale: string, filepath?: string) => Record<string, unknown>;
|
|
37
|
-
export {};
|
|
1
|
+
export { WaitInteractions } from "./typescript/spinner";
|
|
38
2
|
//# sourceMappingURL=index.d.ts.map
|
package/build/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../frontend-src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/build/esm/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var footer$1 = {
|
|
|
36
36
|
text: "Telerau ac amodau"
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
href: "https://
|
|
39
|
+
href: "https://www.gov.uk/government/publications/govuk-one-login-privacy-notice",
|
|
40
40
|
text: "Hysbysiad preifatrwydd"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
@@ -66,7 +66,8 @@ var languageSelect$1 = {
|
|
|
66
66
|
var phaseBanner$1 = {
|
|
67
67
|
tag: "BETA",
|
|
68
68
|
text: "Mae hwn yn wasanaeth newydd. Helpwch ni i'w wella a ",
|
|
69
|
-
link: "rhoi eich adborth (agor mewn tab newydd)."
|
|
69
|
+
link: "rhoi eich adborth (agor mewn tab newydd).",
|
|
70
|
+
ariaLabel: "Rhyddhau Baner Cyfnod"
|
|
70
71
|
};
|
|
71
72
|
var skipLink$1 = {
|
|
72
73
|
title: "Neidio i'r prif gynnwys"
|
|
@@ -115,7 +116,7 @@ var footer = {
|
|
|
115
116
|
text: "Terms and conditions"
|
|
116
117
|
},
|
|
117
118
|
{
|
|
118
|
-
href: "https://
|
|
119
|
+
href: "https://www.gov.uk/government/publications/govuk-one-login-privacy-notice",
|
|
119
120
|
text: "Privacy notice"
|
|
120
121
|
},
|
|
121
122
|
{
|
|
@@ -145,7 +146,8 @@ var languageSelect = {
|
|
|
145
146
|
var phaseBanner = {
|
|
146
147
|
tag: "BETA",
|
|
147
148
|
text: "This is a new service. Help us improve it and ",
|
|
148
|
-
link: "give your feedback (opens in a new tab)."
|
|
149
|
+
link: "give your feedback (opens in a new tab).",
|
|
150
|
+
ariaLabel: "Release Phase Banner"
|
|
149
151
|
};
|
|
150
152
|
var skipLink = {
|
|
151
153
|
title: "Skip to main content"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../frontend-src/typescript/spinner.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,EAEN,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,gBAAgB;;;CA2HzB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface virtualDom {
|
|
2
|
+
nodeName?: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
classes?: string[];
|
|
5
|
+
}
|
|
6
|
+
export type error = {
|
|
7
|
+
spinnerState: string;
|
|
8
|
+
done: boolean;
|
|
9
|
+
virtualDom: never[];
|
|
10
|
+
state: {
|
|
11
|
+
error: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type apiRoute = RequestInfo | URL;
|
|
15
|
+
export type content = {
|
|
16
|
+
initial: {
|
|
17
|
+
spinnerState: string | virtualDom;
|
|
18
|
+
};
|
|
19
|
+
complete: {
|
|
20
|
+
spinnerState: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type timers = {
|
|
24
|
+
updateDomTimer?: unknown | number;
|
|
25
|
+
abortUnresponsiveRequest?: unknown | number;
|
|
26
|
+
};
|
|
27
|
+
export type state = {
|
|
28
|
+
error?: boolean | error;
|
|
29
|
+
spinnerState?: string;
|
|
30
|
+
done?: boolean;
|
|
31
|
+
virtualDom?: unknown[];
|
|
32
|
+
timers?: {
|
|
33
|
+
timers: timers;
|
|
34
|
+
};
|
|
35
|
+
spinnerStateText?: string;
|
|
36
|
+
};
|
|
37
|
+
export type node = {
|
|
38
|
+
text: object;
|
|
39
|
+
innerHTML: HTMLElement;
|
|
40
|
+
id: string;
|
|
41
|
+
classes: string[];
|
|
42
|
+
nodeName: keyof HTMLElementTagNameMap;
|
|
43
|
+
textContent: unknown | HTMLElement | string;
|
|
44
|
+
el: unknown | HTMLElement | string;
|
|
45
|
+
};
|
|
46
|
+
export type initialState = {
|
|
47
|
+
nodeName: string;
|
|
48
|
+
id: string;
|
|
49
|
+
classes: (string | undefined)[];
|
|
50
|
+
}[];
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../frontend-src/utils/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,KAAK,EAAE,CAAC;IACpB,KAAK,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,GAAG,CAAC;AAEzC,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,GAAG,UAAU,CAAC;KACnC,CAAC;IACF,QAAQ,EAAE;QACR,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC,wBAAwB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,WAAW,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;IACtC,WAAW,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;IAC5C,EAAE,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;CACjC,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govuk-one-login/frontend-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/cjs/index.cjs",
|
|
6
6
|
"module": "build/esm/index.js",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "rollup -c",
|
|
13
13
|
"dev": "rollup -c --watch",
|
|
14
|
-
"test": "jest"
|
|
15
|
-
"test:coverage": "jest --coverage src"
|
|
14
|
+
"test": "jest --coverage src"
|
|
16
15
|
},
|
|
17
16
|
"files": [
|
|
18
17
|
"build/",
|
|
@@ -38,17 +37,23 @@
|
|
|
38
37
|
"devDependencies": {
|
|
39
38
|
"@rollup/plugin-json": "^6.1.0",
|
|
40
39
|
"@types/express": "5.0.1",
|
|
41
|
-
"@types/jest": "29.5.12",
|
|
40
|
+
"@types/jest": "^29.5.12",
|
|
42
41
|
"@types/jest-axe": "3.5.9",
|
|
43
42
|
"@types/js-yaml": "^4.0.9",
|
|
43
|
+
"@types/jsdom": "^21.1.7",
|
|
44
44
|
"@types/lodash": "4.17.15",
|
|
45
45
|
"@types/node": "22.12.0",
|
|
46
|
-
"
|
|
46
|
+
"axe-core": "^4.10.3",
|
|
47
|
+
"jest": "^29.5.0",
|
|
48
|
+
"jest-axe": "^10.0.0",
|
|
49
|
+
"jest-environment-jsdom": "^30.0.0-beta.3",
|
|
50
|
+
"jsdom": "^26.1.0",
|
|
51
|
+
"nunjucks": "^3.2.4",
|
|
47
52
|
"rollup": "4.37.0",
|
|
48
53
|
"rollup-plugin-scss": "4.0.1",
|
|
49
54
|
"rollup-plugin-typescript2": "0.36.0",
|
|
50
55
|
"sass": "1.86.0",
|
|
51
|
-
"ts-jest": "29.3.
|
|
56
|
+
"ts-jest": "^29.3.4",
|
|
52
57
|
"tsx": "4.19.3",
|
|
53
58
|
"typescript": "5.8.2"
|
|
54
59
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/index.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/logger.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
export const WaitInteractions = (() => {
|
|
2
|
-
const content = {
|
|
3
|
-
initial: {
|
|
4
|
-
spinnerState: "pending",
|
|
5
|
-
},
|
|
6
|
-
complete: { spinnerState: "completed" },
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const state = {
|
|
10
|
-
spinnerState: content.initial.spinnerState,
|
|
11
|
-
done: false,
|
|
12
|
-
virtualDom: [],
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const timers = {};
|
|
16
|
-
|
|
17
|
-
const createVirtualDom = () => {
|
|
18
|
-
const initialState = [
|
|
19
|
-
{
|
|
20
|
-
nodeName: "div",
|
|
21
|
-
id: "spinner",
|
|
22
|
-
classes: ["spinner", "spinner__pending", "centre", state.spinnerState],
|
|
23
|
-
},
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
return initialState;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const vDomHasChanged = (currentVDom, nextVDom) => {
|
|
30
|
-
return JSON.stringify(currentVDom) !== JSON.stringify(nextVDom);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const updateDom = () => {
|
|
34
|
-
const vDomChanged = vDomHasChanged(state.virtualDom, createVirtualDom());
|
|
35
|
-
const container = document.getElementById("spinner-container");
|
|
36
|
-
|
|
37
|
-
if (vDomChanged) {
|
|
38
|
-
state.virtualDom = createVirtualDom();
|
|
39
|
-
const elements = state?.virtualDom?.map(convert);
|
|
40
|
-
container?.replaceChildren(...elements);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (state.error) {
|
|
44
|
-
container?.classList.add("spinner-container__error");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (state.done) {
|
|
48
|
-
clearInterval(timers.updateDomTimer);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const reflectCompletion = () => {
|
|
53
|
-
state.spinnerState = "spinner__ready";
|
|
54
|
-
state.spinnerStateText = content.complete.spinnerState;
|
|
55
|
-
state.done = true;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const reflectError = () => {
|
|
59
|
-
state.spinnerState = "spinner__failed";
|
|
60
|
-
state.done = true;
|
|
61
|
-
state.error = true;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const convert = (node) => {
|
|
65
|
-
const el = document.createElement(node.nodeName);
|
|
66
|
-
if (node.text) el.textContent = node.text;
|
|
67
|
-
if (node.innerHTML) el.innerHTML = node.innerHTML;
|
|
68
|
-
if (node.id) el.id = node.id;
|
|
69
|
-
if (node.classes) el.classList.add(...node.classes);
|
|
70
|
-
return el;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const notInErrorOrDoneState = () => {
|
|
74
|
-
return !(state.done || state.error);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const requestIDProcessingStatus = async () => {
|
|
78
|
-
const apiRoute =
|
|
79
|
-
document?.getElementById("spinner-container")?.dataset.apiRoute;
|
|
80
|
-
try {
|
|
81
|
-
const response = await fetch(apiRoute);
|
|
82
|
-
|
|
83
|
-
if (response.status !== 200) {
|
|
84
|
-
throw new Error(`Status code ${response.status} received`);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const data = await response.json();
|
|
88
|
-
|
|
89
|
-
if (data.status === "Clear to proceed") {
|
|
90
|
-
reflectCompletion();
|
|
91
|
-
} else if (notInErrorOrDoneState()) {
|
|
92
|
-
setTimeout(async () => {
|
|
93
|
-
await requestIDProcessingStatus();
|
|
94
|
-
}, 1000);
|
|
95
|
-
}
|
|
96
|
-
} catch (e) {
|
|
97
|
-
console.log(e);
|
|
98
|
-
reflectError();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
state: state,
|
|
104
|
-
init: () => {
|
|
105
|
-
timers.updateDomTimer = setInterval(updateDom, 2000);
|
|
106
|
-
|
|
107
|
-
timers.abortUnresponsiveRequest = setTimeout(() => {
|
|
108
|
-
reflectError();
|
|
109
|
-
}, 15000);
|
|
110
|
-
|
|
111
|
-
updateDom();
|
|
112
|
-
|
|
113
|
-
requestIDProcessingStatus().then(() => {
|
|
114
|
-
updateDom();
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/index.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/logger.spec.ts"],"names":[],"mappings":""}
|