whitehall-ui 1.0.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/README.md +108 -0
- package/dist/chunk-2QKZ6DPC.js +27 -0
- package/dist/chunk-3INCIYDO.js +213 -0
- package/dist/chunk-3YIKJK6M.js +181 -0
- package/dist/chunk-4MXR4WNS.js +17 -0
- package/dist/chunk-5AKGRLG2.js +190 -0
- package/dist/chunk-5H55YDJS.js +69 -0
- package/dist/chunk-5PIQJ22R.js +106 -0
- package/dist/chunk-5TI2WXYU.js +64 -0
- package/dist/chunk-5XNKIBMP.js +21 -0
- package/dist/chunk-6VXVJERU.js +38 -0
- package/dist/chunk-72PH2FMG.js +180 -0
- package/dist/chunk-7ZCZQN5N.js +71 -0
- package/dist/chunk-AO6HPG4R.js +50 -0
- package/dist/chunk-CEPBVMFU.js +34 -0
- package/dist/chunk-G6T44BDV.js +75 -0
- package/dist/chunk-GUZIKVAE.js +119 -0
- package/dist/chunk-JESMK3XK.js +105 -0
- package/dist/chunk-JFZN5XP6.js +88 -0
- package/dist/chunk-KD4LPFIZ.js +67 -0
- package/dist/chunk-KWAC6IEK.js +95 -0
- package/dist/chunk-LRNZYPC2.js +107 -0
- package/dist/chunk-M6CLPMRP.js +227 -0
- package/dist/chunk-N67H5OUQ.js +51 -0
- package/dist/chunk-NRXTKHI2.js +169 -0
- package/dist/chunk-OP35ZJ4X.js +46 -0
- package/dist/chunk-P4GCF5FQ.js +62 -0
- package/dist/chunk-PGZHPAT5.js +183 -0
- package/dist/chunk-QTSEOPVX.js +94 -0
- package/dist/chunk-RPV43YDC.js +93 -0
- package/dist/chunk-SK27BMU5.js +140 -0
- package/dist/chunk-TXGBUZB4.js +44 -0
- package/dist/chunk-UWQFFFTB.js +136 -0
- package/dist/chunk-VB6V3PHD.js +67 -0
- package/dist/chunk-VQOCX44T.js +41 -0
- package/dist/chunk-WONVZ7WK.js +29 -0
- package/dist/chunk-WPPWPEFV.js +150 -0
- package/dist/chunk-XQOYWPKV.js +48 -0
- package/dist/chunk-YAKI4SI7.js +205 -0
- package/dist/chunk-YCLGXX3R.js +68 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +39 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +1 -0
- package/dist/ui/accordion.d.ts +27 -0
- package/dist/ui/accordion.js +2 -0
- package/dist/ui/back-link.d.ts +9 -0
- package/dist/ui/back-link.js +2 -0
- package/dist/ui/breadcrumbs.d.ts +22 -0
- package/dist/ui/breadcrumbs.js +2 -0
- package/dist/ui/button.d.ts +17 -0
- package/dist/ui/button.js +2 -0
- package/dist/ui/character-count.d.ts +27 -0
- package/dist/ui/character-count.js +3 -0
- package/dist/ui/checkboxes.d.ts +30 -0
- package/dist/ui/checkboxes.js +2 -0
- package/dist/ui/cookie-banner.d.ts +24 -0
- package/dist/ui/cookie-banner.js +2 -0
- package/dist/ui/date-input.d.ts +21 -0
- package/dist/ui/date-input.js +2 -0
- package/dist/ui/details.d.ts +20 -0
- package/dist/ui/details.js +2 -0
- package/dist/ui/error-message.d.ts +9 -0
- package/dist/ui/error-message.js +2 -0
- package/dist/ui/error-summary.d.ts +15 -0
- package/dist/ui/error-summary.js +2 -0
- package/dist/ui/exit-this-page.d.ts +14 -0
- package/dist/ui/exit-this-page.js +3 -0
- package/dist/ui/fieldset.d.ts +22 -0
- package/dist/ui/fieldset.js +2 -0
- package/dist/ui/file-upload.d.ts +19 -0
- package/dist/ui/file-upload.js +2 -0
- package/dist/ui/footer.d.ts +61 -0
- package/dist/ui/footer.js +2 -0
- package/dist/ui/generic-header.d.ts +22 -0
- package/dist/ui/generic-header.js +2 -0
- package/dist/ui/header.d.ts +39 -0
- package/dist/ui/header.js +2 -0
- package/dist/ui/hint.d.ts +8 -0
- package/dist/ui/hint.js +2 -0
- package/dist/ui/inset-text.d.ts +8 -0
- package/dist/ui/inset-text.js +2 -0
- package/dist/ui/label.d.ts +18 -0
- package/dist/ui/label.js +2 -0
- package/dist/ui/link.d.ts +16 -0
- package/dist/ui/link.js +2 -0
- package/dist/ui/notification-banner.d.ts +29 -0
- package/dist/ui/notification-banner.js +2 -0
- package/dist/ui/pagination.d.ts +45 -0
- package/dist/ui/pagination.js +2 -0
- package/dist/ui/panel.d.ts +16 -0
- package/dist/ui/panel.js +2 -0
- package/dist/ui/password-input.d.ts +16 -0
- package/dist/ui/password-input.js +4 -0
- package/dist/ui/phase-banner.d.ts +20 -0
- package/dist/ui/phase-banner.js +2 -0
- package/dist/ui/radios.d.ts +25 -0
- package/dist/ui/radios.js +2 -0
- package/dist/ui/select.d.ts +36 -0
- package/dist/ui/select.js +2 -0
- package/dist/ui/service-navigation.d.ts +30 -0
- package/dist/ui/service-navigation.js +2 -0
- package/dist/ui/skip-link.d.ts +8 -0
- package/dist/ui/skip-link.js +2 -0
- package/dist/ui/summary-list.d.ts +49 -0
- package/dist/ui/summary-list.js +2 -0
- package/dist/ui/table.d.ts +40 -0
- package/dist/ui/table.js +2 -0
- package/dist/ui/tabs.d.ts +25 -0
- package/dist/ui/tabs.js +2 -0
- package/dist/ui/tag.d.ts +15 -0
- package/dist/ui/tag.js +2 -0
- package/dist/ui/task-list.d.ts +30 -0
- package/dist/ui/task-list.js +2 -0
- package/dist/ui/text-input.d.ts +18 -0
- package/dist/ui/text-input.js +2 -0
- package/dist/ui/textarea.d.ts +14 -0
- package/dist/ui/textarea.js +2 -0
- package/dist/ui/warning-text.d.ts +9 -0
- package/dist/ui/warning-text.js +2 -0
- package/package.json +263 -0
- package/registry/default/theme/govuk-tokens.css +434 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var TaskList = ({ className, ref, children, ...props }) => /* @__PURE__ */ jsx(
|
|
5
|
+
"ul",
|
|
6
|
+
{
|
|
7
|
+
ref,
|
|
8
|
+
className: cn(
|
|
9
|
+
"font-govuk text-govuk-body text-govuk-black",
|
|
10
|
+
"mt-0 mb-govuk-6 p-0 list-none",
|
|
11
|
+
className
|
|
12
|
+
),
|
|
13
|
+
...props,
|
|
14
|
+
children
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
var TaskListItem = ({
|
|
18
|
+
className,
|
|
19
|
+
hasLink,
|
|
20
|
+
ref,
|
|
21
|
+
children,
|
|
22
|
+
...props
|
|
23
|
+
}) => /* @__PURE__ */ jsx(
|
|
24
|
+
"li",
|
|
25
|
+
{
|
|
26
|
+
ref,
|
|
27
|
+
className: cn(
|
|
28
|
+
"table relative w-full mb-0",
|
|
29
|
+
"py-govuk-2",
|
|
30
|
+
"border-b border-govuk-mid-grey",
|
|
31
|
+
"first:border-t first:border-t-govuk-mid-grey",
|
|
32
|
+
hasLink && "hover:bg-govuk-light-grey",
|
|
33
|
+
className
|
|
34
|
+
),
|
|
35
|
+
...props,
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
var TaskListNameAndHint = ({
|
|
40
|
+
className,
|
|
41
|
+
ref,
|
|
42
|
+
children,
|
|
43
|
+
...props
|
|
44
|
+
}) => /* @__PURE__ */ jsx(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
ref,
|
|
48
|
+
className: cn("table-cell align-top text-govuk-black", className),
|
|
49
|
+
...props,
|
|
50
|
+
children
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
var TaskListLink = ({
|
|
54
|
+
className,
|
|
55
|
+
ref,
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
}) => /* @__PURE__ */ jsx(
|
|
59
|
+
"a",
|
|
60
|
+
{
|
|
61
|
+
ref,
|
|
62
|
+
className: cn(
|
|
63
|
+
"text-govuk-brand underline govuk-link-underline",
|
|
64
|
+
"hover:text-govuk-brand-hover hover:govuk-link-underline-hover",
|
|
65
|
+
"focus:govuk-link-focus",
|
|
66
|
+
'after:content-[""] after:block after:absolute after:inset-0',
|
|
67
|
+
className
|
|
68
|
+
),
|
|
69
|
+
...props,
|
|
70
|
+
children
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
var TaskListHint = ({
|
|
74
|
+
className,
|
|
75
|
+
ref,
|
|
76
|
+
children,
|
|
77
|
+
...props
|
|
78
|
+
}) => /* @__PURE__ */ jsx(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
ref,
|
|
82
|
+
className: cn("mt-govuk-1 text-govuk-dark-grey", className),
|
|
83
|
+
...props,
|
|
84
|
+
children
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
var TaskListStatus = ({
|
|
88
|
+
className,
|
|
89
|
+
cannotStartYet,
|
|
90
|
+
ref,
|
|
91
|
+
children,
|
|
92
|
+
...props
|
|
93
|
+
}) => /* @__PURE__ */ jsx(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
ref,
|
|
97
|
+
className: cn(
|
|
98
|
+
"table-cell pl-govuk-2 text-right align-top",
|
|
99
|
+
cannotStartYet ? "text-govuk-dark-grey" : "text-govuk-black",
|
|
100
|
+
className
|
|
101
|
+
),
|
|
102
|
+
...props,
|
|
103
|
+
children
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var PaginationBlockContext = createContext(false);
|
|
6
|
+
var PrevArrow = () => {
|
|
7
|
+
const isBlock = useContext(PaginationBlockContext);
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
"svg",
|
|
10
|
+
{
|
|
11
|
+
className: cn(
|
|
12
|
+
"govuk-pagination-icon fill-current",
|
|
13
|
+
isBlock ? "govuk-pagination-block-arrow" : "mr-govuk-3"
|
|
14
|
+
),
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
16
|
+
height: "13",
|
|
17
|
+
width: "15",
|
|
18
|
+
"aria-hidden": "true",
|
|
19
|
+
focusable: "false",
|
|
20
|
+
viewBox: "0 0 15 13",
|
|
21
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6.5938-0.0078125-6.7266 6.7266 6.7441 6.4062 1.377-1.449-4.1856-3.9768h12.896v-2h-12.984l4.2931-4.293-1.414-1.414z" })
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
var NextArrow = () => {
|
|
26
|
+
const isBlock = useContext(PaginationBlockContext);
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
"svg",
|
|
29
|
+
{
|
|
30
|
+
className: cn(
|
|
31
|
+
"govuk-pagination-icon fill-current",
|
|
32
|
+
isBlock ? "govuk-pagination-block-arrow" : "ml-govuk-3"
|
|
33
|
+
),
|
|
34
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
+
height: "13",
|
|
36
|
+
width: "15",
|
|
37
|
+
"aria-hidden": "true",
|
|
38
|
+
focusable: "false",
|
|
39
|
+
viewBox: "0 0 15 13",
|
|
40
|
+
children: /* @__PURE__ */ jsx("path", { d: "m8.107-0.0078125-1.4136 1.414 4.2926 4.293h-12.986v2h12.896l-4.1855 3.9766 1.377 1.4492 6.7441-6.4062-6.7246-6.7266z" })
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
var Pagination = ({
|
|
45
|
+
className,
|
|
46
|
+
block,
|
|
47
|
+
children,
|
|
48
|
+
ref,
|
|
49
|
+
...props
|
|
50
|
+
}) => {
|
|
51
|
+
const blockValue = block ?? false;
|
|
52
|
+
return /* @__PURE__ */ jsx(PaginationBlockContext.Provider, { value: blockValue, children: /* @__PURE__ */ jsx(
|
|
53
|
+
"nav",
|
|
54
|
+
{
|
|
55
|
+
ref,
|
|
56
|
+
className: cn(
|
|
57
|
+
"font-govuk mb-govuk-6",
|
|
58
|
+
block ? "govuk-pagination-block" : "flex flex-col flex-wrap items-center md:flex-row md:items-start",
|
|
59
|
+
className
|
|
60
|
+
),
|
|
61
|
+
"aria-label": props["aria-label"] ?? "Pagination",
|
|
62
|
+
...props,
|
|
63
|
+
children
|
|
64
|
+
}
|
|
65
|
+
) });
|
|
66
|
+
};
|
|
67
|
+
var PaginationPrevious = ({
|
|
68
|
+
className,
|
|
69
|
+
children,
|
|
70
|
+
ref,
|
|
71
|
+
...props
|
|
72
|
+
}) => {
|
|
73
|
+
const isBlock = useContext(PaginationBlockContext);
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
ref,
|
|
78
|
+
className: cn(
|
|
79
|
+
"govuk-pagination-nav-item box-border relative",
|
|
80
|
+
"min-w-govuk-pagination-touch min-h-govuk-pagination-touch",
|
|
81
|
+
"py-govuk-2 pr-govuk-3 pl-0 font-bold text-govuk-body",
|
|
82
|
+
!isBlock && "govuk-pagination-nav-link float-left",
|
|
83
|
+
className
|
|
84
|
+
),
|
|
85
|
+
...props,
|
|
86
|
+
children
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
var PaginationNext = ({
|
|
91
|
+
className,
|
|
92
|
+
children,
|
|
93
|
+
ref,
|
|
94
|
+
...props
|
|
95
|
+
}) => {
|
|
96
|
+
const isBlock = useContext(PaginationBlockContext);
|
|
97
|
+
return /* @__PURE__ */ jsx(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
ref,
|
|
101
|
+
className: cn(
|
|
102
|
+
"govuk-pagination-nav-item box-border relative",
|
|
103
|
+
"min-w-govuk-pagination-touch min-h-govuk-pagination-touch",
|
|
104
|
+
"py-govuk-2 font-bold text-govuk-body",
|
|
105
|
+
isBlock ? "pl-0 pr-govuk-3" : "govuk-pagination-nav-link pl-govuk-3 pr-0 float-left",
|
|
106
|
+
className
|
|
107
|
+
),
|
|
108
|
+
...props,
|
|
109
|
+
children
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
var PaginationList = ({
|
|
114
|
+
className,
|
|
115
|
+
children,
|
|
116
|
+
ref,
|
|
117
|
+
...props
|
|
118
|
+
}) => /* @__PURE__ */ jsx("ul", { ref, className: cn("m-0 p-0 list-none", className), ...props, children });
|
|
119
|
+
var PaginationItem = ({
|
|
120
|
+
className,
|
|
121
|
+
current,
|
|
122
|
+
children,
|
|
123
|
+
ref,
|
|
124
|
+
...props
|
|
125
|
+
}) => /* @__PURE__ */ jsx(
|
|
126
|
+
"li",
|
|
127
|
+
{
|
|
128
|
+
ref,
|
|
129
|
+
className: cn(
|
|
130
|
+
"box-border relative",
|
|
131
|
+
"min-w-govuk-pagination-touch min-h-govuk-pagination-touch",
|
|
132
|
+
"py-govuk-2 px-govuk-3 float-left text-center text-govuk-body",
|
|
133
|
+
"hidden first:block last:block md:block",
|
|
134
|
+
current ? "block font-bold govuk-pagination-item-current" : "hover:bg-govuk-light-grey",
|
|
135
|
+
className
|
|
136
|
+
),
|
|
137
|
+
...props,
|
|
138
|
+
children
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
var PaginationEllipsis = ({
|
|
142
|
+
className,
|
|
143
|
+
ref,
|
|
144
|
+
...props
|
|
145
|
+
}) => /* @__PURE__ */ jsx(
|
|
146
|
+
"li",
|
|
147
|
+
{
|
|
148
|
+
ref,
|
|
149
|
+
className: cn(
|
|
150
|
+
"box-border relative",
|
|
151
|
+
"min-w-govuk-pagination-touch min-h-govuk-pagination-touch",
|
|
152
|
+
"py-govuk-2 px-govuk-3 float-left text-center text-govuk-body",
|
|
153
|
+
"block font-bold text-govuk-dark-grey",
|
|
154
|
+
"hover:bg-transparent",
|
|
155
|
+
className
|
|
156
|
+
),
|
|
157
|
+
...props,
|
|
158
|
+
children: "\u22EF"
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
var PaginationLink = ({
|
|
162
|
+
className,
|
|
163
|
+
children,
|
|
164
|
+
ref,
|
|
165
|
+
...props
|
|
166
|
+
}) => {
|
|
167
|
+
const isBlock = useContext(PaginationBlockContext);
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
"a",
|
|
170
|
+
{
|
|
171
|
+
ref,
|
|
172
|
+
className: cn(
|
|
173
|
+
"govuk-pagination-link min-w-govuk-3",
|
|
174
|
+
"text-govuk-brand underline govuk-link-underline",
|
|
175
|
+
"hover:text-govuk-brand-hover hover:govuk-link-underline-hover",
|
|
176
|
+
"visited:text-govuk-visited",
|
|
177
|
+
"focus:govuk-link-focus",
|
|
178
|
+
isBlock ? "inline-block pl-govuk-6 text-left govuk-pagination-block-link" : "block",
|
|
179
|
+
className
|
|
180
|
+
),
|
|
181
|
+
...props,
|
|
182
|
+
children
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
var PaginationLinkTitle = ({
|
|
187
|
+
className,
|
|
188
|
+
decorated,
|
|
189
|
+
children,
|
|
190
|
+
ref,
|
|
191
|
+
...props
|
|
192
|
+
}) => {
|
|
193
|
+
const isBlock = useContext(PaginationBlockContext);
|
|
194
|
+
return /* @__PURE__ */ jsx(
|
|
195
|
+
"span",
|
|
196
|
+
{
|
|
197
|
+
ref,
|
|
198
|
+
className: cn(
|
|
199
|
+
"decoration-inherit",
|
|
200
|
+
decorated && "underline govuk-link-underline",
|
|
201
|
+
isBlock && "govuk-pagination-block-title",
|
|
202
|
+
className
|
|
203
|
+
),
|
|
204
|
+
...props,
|
|
205
|
+
children
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
var PaginationLinkLabel = ({
|
|
210
|
+
className,
|
|
211
|
+
children,
|
|
212
|
+
ref,
|
|
213
|
+
...props
|
|
214
|
+
}) => /* @__PURE__ */ jsx(
|
|
215
|
+
"span",
|
|
216
|
+
{
|
|
217
|
+
ref,
|
|
218
|
+
className: cn(
|
|
219
|
+
"font-normal underline govuk-link-underline inline-block",
|
|
220
|
+
className
|
|
221
|
+
),
|
|
222
|
+
...props,
|
|
223
|
+
children
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
export { NextArrow, Pagination, PaginationEllipsis, PaginationItem, PaginationLink, PaginationLinkLabel, PaginationLinkTitle, PaginationList, PaginationNext, PaginationPrevious, PrevArrow };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var BackLink = ({
|
|
5
|
+
className,
|
|
6
|
+
inverse,
|
|
7
|
+
ref,
|
|
8
|
+
children = "Back",
|
|
9
|
+
...props
|
|
10
|
+
}) => /* @__PURE__ */ jsxs(
|
|
11
|
+
"a",
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
className: cn(
|
|
15
|
+
"font-govuk text-govuk-header leading-tight",
|
|
16
|
+
"inline-flex items-center gap-govuk-1",
|
|
17
|
+
"my-govuk-3",
|
|
18
|
+
"underline govuk-link-underline",
|
|
19
|
+
"hover:govuk-link-underline-hover",
|
|
20
|
+
"focus:govuk-link-focus",
|
|
21
|
+
inverse ? [
|
|
22
|
+
"text-white visited:text-white",
|
|
23
|
+
"hover:text-white active:text-white"
|
|
24
|
+
] : [
|
|
25
|
+
"text-govuk-black visited:text-govuk-black",
|
|
26
|
+
"hover:text-govuk-black active:text-govuk-black"
|
|
27
|
+
],
|
|
28
|
+
className
|
|
29
|
+
),
|
|
30
|
+
...props,
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
"svg",
|
|
34
|
+
{
|
|
35
|
+
className: "shrink-0",
|
|
36
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
37
|
+
width: "7",
|
|
38
|
+
height: "11",
|
|
39
|
+
viewBox: "0 0 7 11",
|
|
40
|
+
fill: "none",
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
focusable: "false",
|
|
43
|
+
children: /* @__PURE__ */ jsx("path", { d: "M6 1L1.5 5.5L6 10", stroke: "currentColor", strokeWidth: "1.5" })
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
children
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
export { BackLink };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { buttonVariants } from './chunk-5PIQJ22R.js';
|
|
2
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var REQUIRED_PRESSES = 3;
|
|
7
|
+
var TIMEOUT_MS = 5e3;
|
|
8
|
+
var indicatorStyles = [
|
|
9
|
+
"p-govuk-2 pb-0 pointer-events-none text-center"
|
|
10
|
+
];
|
|
11
|
+
var dotStyles = [
|
|
12
|
+
"inline-block box-border rounded-full",
|
|
13
|
+
"w-govuk-exit-page-dot h-govuk-exit-page-dot",
|
|
14
|
+
"mx-govuk-exit-page-dot-gap",
|
|
15
|
+
"border-2 border-solid border-current"
|
|
16
|
+
];
|
|
17
|
+
var ExitThisPage = ({
|
|
18
|
+
className,
|
|
19
|
+
redirectUrl = "https://www.bbc.co.uk/weather",
|
|
20
|
+
text = "Exit this page",
|
|
21
|
+
activatedText = "Loading.",
|
|
22
|
+
timedOutText = "Exit this page expired.",
|
|
23
|
+
pressTwoMoreTimesText = "Shift, press 2 more times to exit.",
|
|
24
|
+
pressOneMoreTimeText = "Shift, press 1 more time to exit.",
|
|
25
|
+
ref,
|
|
26
|
+
...props
|
|
27
|
+
}) => {
|
|
28
|
+
const [keypressCount, setKeypressCount] = useState(0);
|
|
29
|
+
const [announcement, setAnnouncement] = useState("");
|
|
30
|
+
const [activated, setActivated] = useState(false);
|
|
31
|
+
const countRef = useRef(0);
|
|
32
|
+
const lastKeyModifiedRef = useRef(false);
|
|
33
|
+
const keypressTimeoutRef = useRef(null);
|
|
34
|
+
const messageTimeoutRef = useRef(null);
|
|
35
|
+
const exitPage = () => {
|
|
36
|
+
setAnnouncement("");
|
|
37
|
+
setActivated(true);
|
|
38
|
+
globalThis.location.assign(redirectUrl);
|
|
39
|
+
};
|
|
40
|
+
const handleClick = (event) => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
exitPage();
|
|
43
|
+
};
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const clearKeypressTimer = () => {
|
|
46
|
+
if (keypressTimeoutRef.current !== null) {
|
|
47
|
+
globalThis.clearTimeout(keypressTimeoutRef.current);
|
|
48
|
+
keypressTimeoutRef.current = null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const resetKeypressTimer = () => {
|
|
52
|
+
clearKeypressTimer();
|
|
53
|
+
countRef.current = 0;
|
|
54
|
+
setKeypressCount(0);
|
|
55
|
+
setAnnouncement(timedOutText);
|
|
56
|
+
if (messageTimeoutRef.current !== null) {
|
|
57
|
+
globalThis.clearTimeout(messageTimeoutRef.current);
|
|
58
|
+
}
|
|
59
|
+
messageTimeoutRef.current = globalThis.setTimeout(() => {
|
|
60
|
+
setAnnouncement("");
|
|
61
|
+
}, TIMEOUT_MS);
|
|
62
|
+
};
|
|
63
|
+
const setKeypressTimer = () => {
|
|
64
|
+
clearKeypressTimer();
|
|
65
|
+
keypressTimeoutRef.current = globalThis.setTimeout(
|
|
66
|
+
resetKeypressTimer,
|
|
67
|
+
TIMEOUT_MS
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
const handleKeyup = (event) => {
|
|
71
|
+
if (event.key === "Shift" && !lastKeyModifiedRef.current) {
|
|
72
|
+
countRef.current += 1;
|
|
73
|
+
setKeypressCount(countRef.current);
|
|
74
|
+
if (messageTimeoutRef.current !== null) {
|
|
75
|
+
globalThis.clearTimeout(messageTimeoutRef.current);
|
|
76
|
+
messageTimeoutRef.current = null;
|
|
77
|
+
}
|
|
78
|
+
if (countRef.current >= REQUIRED_PRESSES) {
|
|
79
|
+
countRef.current = 0;
|
|
80
|
+
clearKeypressTimer();
|
|
81
|
+
exitPage();
|
|
82
|
+
} else {
|
|
83
|
+
setAnnouncement(
|
|
84
|
+
countRef.current === 1 ? pressTwoMoreTimesText : pressOneMoreTimeText
|
|
85
|
+
);
|
|
86
|
+
setKeypressTimer();
|
|
87
|
+
}
|
|
88
|
+
} else if (keypressTimeoutRef.current !== null) {
|
|
89
|
+
resetKeypressTimer();
|
|
90
|
+
}
|
|
91
|
+
lastKeyModifiedRef.current = event.shiftKey;
|
|
92
|
+
};
|
|
93
|
+
document.addEventListener("keyup", handleKeyup, true);
|
|
94
|
+
return () => {
|
|
95
|
+
document.removeEventListener("keyup", handleKeyup, true);
|
|
96
|
+
clearKeypressTimer();
|
|
97
|
+
if (messageTimeoutRef.current !== null) {
|
|
98
|
+
globalThis.clearTimeout(messageTimeoutRef.current);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}, [
|
|
102
|
+
redirectUrl,
|
|
103
|
+
timedOutText,
|
|
104
|
+
pressTwoMoreTimesText,
|
|
105
|
+
pressOneMoreTimeText
|
|
106
|
+
]);
|
|
107
|
+
return /* @__PURE__ */ jsxs(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
ref,
|
|
111
|
+
className: cn(
|
|
112
|
+
"block sm:inline-block",
|
|
113
|
+
"sticky top-0 left-0 z-govuk-exit-page w-full",
|
|
114
|
+
"mb-govuk-8",
|
|
115
|
+
"sm:right-0 sm:left-auto sm:w-auto sm:float-right",
|
|
116
|
+
"print:hidden",
|
|
117
|
+
className
|
|
118
|
+
),
|
|
119
|
+
...props,
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsxs(
|
|
122
|
+
"a",
|
|
123
|
+
{
|
|
124
|
+
href: redirectUrl,
|
|
125
|
+
rel: "nofollow noreferrer",
|
|
126
|
+
onClick: handleClick,
|
|
127
|
+
className: cn(
|
|
128
|
+
buttonVariants({ variant: "warning" }),
|
|
129
|
+
"mb-0 max-sm:w-full"
|
|
130
|
+
),
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Emergency" }),
|
|
133
|
+
" ",
|
|
134
|
+
text,
|
|
135
|
+
/* @__PURE__ */ jsx(
|
|
136
|
+
"span",
|
|
137
|
+
{
|
|
138
|
+
"aria-hidden": "true",
|
|
139
|
+
className: cn(indicatorStyles, keypressCount > 0 ? "block" : "hidden"),
|
|
140
|
+
children: [0, 1, 2].map((index) => /* @__PURE__ */ jsx(
|
|
141
|
+
"span",
|
|
142
|
+
{
|
|
143
|
+
className: cn(
|
|
144
|
+
dotStyles,
|
|
145
|
+
index < keypressCount && "border-govuk-exit-page-dot"
|
|
146
|
+
)
|
|
147
|
+
},
|
|
148
|
+
index
|
|
149
|
+
))
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ jsx("output", { className: "sr-only", children: announcement }),
|
|
156
|
+
activated && /* @__PURE__ */ jsx(
|
|
157
|
+
"div",
|
|
158
|
+
{
|
|
159
|
+
role: "alert",
|
|
160
|
+
className: "fixed inset-0 z-govuk-exit-page-overlay bg-govuk-canvas text-govuk-canvas-text",
|
|
161
|
+
children: activatedText
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export { ExitThisPage };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var WarningText = ({
|
|
5
|
+
className,
|
|
6
|
+
ref,
|
|
7
|
+
assistiveText = "Warning",
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}) => /* @__PURE__ */ jsxs(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
className: cn(
|
|
15
|
+
"font-govuk text-govuk-body font-bold",
|
|
16
|
+
"relative py-govuk-2 mb-govuk-6",
|
|
17
|
+
className
|
|
18
|
+
),
|
|
19
|
+
...props,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
"span",
|
|
23
|
+
{
|
|
24
|
+
className: cn(
|
|
25
|
+
"box-border absolute left-0",
|
|
26
|
+
"flex items-center justify-center",
|
|
27
|
+
"min-w-govuk-warning-icon-size min-h-govuk-warning-icon-size",
|
|
28
|
+
"mt-govuk-warning-icon-mt",
|
|
29
|
+
"border-govuk-warning-icon-border border-solid border-govuk-black rounded-full",
|
|
30
|
+
"bg-govuk-black text-white",
|
|
31
|
+
"text-3xl",
|
|
32
|
+
"select-none"
|
|
33
|
+
),
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
children: "!"
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ jsxs("strong", { className: cn("block pl-govuk-warning-text-pl font-inherit"), children: [
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: assistiveText }),
|
|
40
|
+
children
|
|
41
|
+
] })
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export { WarningText };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { TextInput } from './chunk-QTSEOPVX.js';
|
|
2
|
+
import { Button } from './chunk-5PIQJ22R.js';
|
|
3
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
4
|
+
import { useId, useState } from 'react';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var PasswordInput = ({
|
|
8
|
+
className,
|
|
9
|
+
id,
|
|
10
|
+
error = false,
|
|
11
|
+
disabled = false,
|
|
12
|
+
autoComplete = "current-password",
|
|
13
|
+
showPasswordText = "Show",
|
|
14
|
+
hidePasswordText = "Hide",
|
|
15
|
+
showPasswordAriaLabel = "Show password",
|
|
16
|
+
hidePasswordAriaLabel = "Hide password",
|
|
17
|
+
passwordShownAnnouncement = "Your password is shown",
|
|
18
|
+
passwordHiddenAnnouncement = "Your password is hidden",
|
|
19
|
+
ref,
|
|
20
|
+
...props
|
|
21
|
+
}) => {
|
|
22
|
+
const generatedId = useId();
|
|
23
|
+
const inputId = id ?? generatedId;
|
|
24
|
+
const [shown, setShown] = useState(false);
|
|
25
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-start", children: [
|
|
26
|
+
/* @__PURE__ */ jsx(
|
|
27
|
+
TextInput,
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
id: inputId,
|
|
31
|
+
type: shown ? "text" : "password",
|
|
32
|
+
error,
|
|
33
|
+
disabled,
|
|
34
|
+
spellCheck: false,
|
|
35
|
+
autoCapitalize: "none",
|
|
36
|
+
autoComplete,
|
|
37
|
+
className: cn("flex-auto", className),
|
|
38
|
+
...props
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
Button,
|
|
43
|
+
{
|
|
44
|
+
type: "button",
|
|
45
|
+
variant: "secondary",
|
|
46
|
+
disabled,
|
|
47
|
+
"aria-controls": inputId,
|
|
48
|
+
"aria-label": shown ? hidePasswordAriaLabel : showPasswordAriaLabel,
|
|
49
|
+
onClick: () => setShown((prev) => !prev),
|
|
50
|
+
className: cn(
|
|
51
|
+
"mt-0 mb-0 ml-govuk-1",
|
|
52
|
+
"w-24 sm:w-24 shrink-0 grow-0",
|
|
53
|
+
"leading-none whitespace-nowrap"
|
|
54
|
+
),
|
|
55
|
+
children: shown ? hidePasswordText : showPasswordText
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: shown ? passwordShownAnnouncement : passwordHiddenAnnouncement })
|
|
59
|
+
] });
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { PasswordInput };
|