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,71 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var GenericHeader = ({
|
|
5
|
+
className,
|
|
6
|
+
fullWidth,
|
|
7
|
+
ref,
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}) => /* @__PURE__ */ jsx(
|
|
11
|
+
"header",
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
className: cn(
|
|
15
|
+
"font-govuk text-govuk-header",
|
|
16
|
+
"border-b border-b-transparent",
|
|
17
|
+
"text-white bg-govuk-black",
|
|
18
|
+
className
|
|
19
|
+
),
|
|
20
|
+
...props,
|
|
21
|
+
children: children ?? /* @__PURE__ */ jsx(GenericHeaderContainer, { fullWidth, children: /* @__PURE__ */ jsx(GenericHeaderLogo, {}) })
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
var GenericHeaderContainer = ({
|
|
25
|
+
className,
|
|
26
|
+
fullWidth,
|
|
27
|
+
ref,
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
}) => /* @__PURE__ */ jsx(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
ref,
|
|
34
|
+
className: cn(
|
|
35
|
+
fullWidth ? "px-govuk-3" : "max-w-240 mx-auto px-govuk-3",
|
|
36
|
+
className
|
|
37
|
+
),
|
|
38
|
+
...props,
|
|
39
|
+
children
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
var GenericHeaderLogo = ({
|
|
43
|
+
className,
|
|
44
|
+
ref,
|
|
45
|
+
children,
|
|
46
|
+
...props
|
|
47
|
+
}) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex py-govuk-3", className), ...props, children });
|
|
48
|
+
var GenericHeaderLink = ({
|
|
49
|
+
className,
|
|
50
|
+
ref,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}) => /* @__PURE__ */ jsx(
|
|
54
|
+
"a",
|
|
55
|
+
{
|
|
56
|
+
ref,
|
|
57
|
+
className: cn(
|
|
58
|
+
"inline-flex items-center gap-govuk-1",
|
|
59
|
+
"text-govuk-header-link",
|
|
60
|
+
"text-white no-underline",
|
|
61
|
+
"visited:text-white active:text-white",
|
|
62
|
+
"hover:underline hover:govuk-link-underline hover:govuk-link-underline-hover",
|
|
63
|
+
"focus:govuk-link-focus",
|
|
64
|
+
className
|
|
65
|
+
),
|
|
66
|
+
...props,
|
|
67
|
+
children
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export { GenericHeader, GenericHeaderContainer, GenericHeaderLink, GenericHeaderLogo };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var textareaVariants = cva(
|
|
6
|
+
[
|
|
7
|
+
"box-border w-full",
|
|
8
|
+
"p-govuk-1",
|
|
9
|
+
"border-2 border-govuk-black",
|
|
10
|
+
"rounded-none",
|
|
11
|
+
"appearance-none resize-y",
|
|
12
|
+
"text-govuk-body font-normal font-govuk",
|
|
13
|
+
"focus:outline-3 focus:outline-govuk-yellow focus:outline-offset-0",
|
|
14
|
+
"focus:inset-ring-2 focus:inset-ring-govuk-black",
|
|
15
|
+
"disabled:opacity-50 disabled:bg-transparent disabled:cursor-not-allowed"
|
|
16
|
+
],
|
|
17
|
+
{
|
|
18
|
+
variants: {
|
|
19
|
+
error: {
|
|
20
|
+
true: "border-govuk-error focus:border-govuk-black",
|
|
21
|
+
false: ""
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
error: false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
var Textarea = ({
|
|
30
|
+
className,
|
|
31
|
+
error = false,
|
|
32
|
+
rows = 5,
|
|
33
|
+
disabled = false,
|
|
34
|
+
"aria-describedby": ariaDescribedBy,
|
|
35
|
+
ref,
|
|
36
|
+
...props
|
|
37
|
+
}) => /* @__PURE__ */ jsx(
|
|
38
|
+
"textarea",
|
|
39
|
+
{
|
|
40
|
+
ref,
|
|
41
|
+
rows,
|
|
42
|
+
disabled,
|
|
43
|
+
"aria-invalid": error || void 0,
|
|
44
|
+
"aria-describedby": ariaDescribedBy || void 0,
|
|
45
|
+
className: cn(textareaVariants({ error }), className),
|
|
46
|
+
...props
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export { Textarea, textareaVariants };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { jsxs } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var ErrorMessage = ({
|
|
5
|
+
className,
|
|
6
|
+
children,
|
|
7
|
+
visuallyHiddenText = "Error",
|
|
8
|
+
ref,
|
|
9
|
+
...props
|
|
10
|
+
}) => /* @__PURE__ */ jsxs(
|
|
11
|
+
"p",
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
className: cn(
|
|
15
|
+
"block",
|
|
16
|
+
"mt-0 mb-govuk-3",
|
|
17
|
+
"clear-both",
|
|
18
|
+
"font-govuk text-govuk-body font-bold",
|
|
19
|
+
"text-govuk-error",
|
|
20
|
+
className
|
|
21
|
+
),
|
|
22
|
+
...props,
|
|
23
|
+
children: [
|
|
24
|
+
visuallyHiddenText && /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
25
|
+
visuallyHiddenText,
|
|
26
|
+
":"
|
|
27
|
+
] }),
|
|
28
|
+
" ",
|
|
29
|
+
children
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export { ErrorMessage };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var linkVariants = cva(
|
|
6
|
+
[
|
|
7
|
+
"font-govuk cursor-pointer",
|
|
8
|
+
"underline govuk-link-underline",
|
|
9
|
+
"hover:govuk-link-underline-hover",
|
|
10
|
+
"focus:govuk-link-focus"
|
|
11
|
+
],
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
default: [
|
|
16
|
+
"text-govuk-brand",
|
|
17
|
+
"hover:text-govuk-brand-hover",
|
|
18
|
+
"visited:text-govuk-visited",
|
|
19
|
+
"active:text-govuk-brand"
|
|
20
|
+
],
|
|
21
|
+
muted: [
|
|
22
|
+
"text-govuk-dark-grey",
|
|
23
|
+
"hover:text-govuk-dark-grey",
|
|
24
|
+
"visited:text-govuk-dark-grey",
|
|
25
|
+
"active:text-govuk-dark-grey"
|
|
26
|
+
],
|
|
27
|
+
inverse: [
|
|
28
|
+
"text-white",
|
|
29
|
+
"hover:text-white",
|
|
30
|
+
"visited:text-white",
|
|
31
|
+
"active:text-white",
|
|
32
|
+
"focus:not-focus:bg-transparent"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
noUnderline: {
|
|
36
|
+
true: "no-underline hover:underline hover:govuk-link-underline"
|
|
37
|
+
},
|
|
38
|
+
noVisitedState: {
|
|
39
|
+
true: ""
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
compoundVariants: [
|
|
43
|
+
{
|
|
44
|
+
variant: "default",
|
|
45
|
+
noVisitedState: true,
|
|
46
|
+
className: "visited:text-govuk-brand"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
variant: "default"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
var Link = ({
|
|
55
|
+
className,
|
|
56
|
+
variant,
|
|
57
|
+
noUnderline,
|
|
58
|
+
noVisitedState,
|
|
59
|
+
ref,
|
|
60
|
+
children,
|
|
61
|
+
...props
|
|
62
|
+
}) => /* @__PURE__ */ jsx(
|
|
63
|
+
"a",
|
|
64
|
+
{
|
|
65
|
+
ref,
|
|
66
|
+
className: cn(
|
|
67
|
+
linkVariants({ variant, noUnderline, noVisitedState }),
|
|
68
|
+
className
|
|
69
|
+
),
|
|
70
|
+
...props,
|
|
71
|
+
children
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
export { Link, linkVariants };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var NotificationBanner = ({
|
|
5
|
+
className,
|
|
6
|
+
variant = "default",
|
|
7
|
+
ref,
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}) => /* @__PURE__ */ jsx(
|
|
11
|
+
"section",
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
role: variant === "success" ? "alert" : void 0,
|
|
15
|
+
"aria-labelledby": props["aria-labelledby"] ?? "govuk-notification-banner-title",
|
|
16
|
+
className: cn(
|
|
17
|
+
"font-govuk text-govuk-body",
|
|
18
|
+
"mb-govuk-8",
|
|
19
|
+
variant === "success" ? "border-govuk-notification-banner-success bg-govuk-green" : "border-govuk-notification-banner bg-govuk-brand",
|
|
20
|
+
"focus:outline-3 focus:outline-govuk-yellow",
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
...props,
|
|
24
|
+
children
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
var NotificationBannerHeader = ({
|
|
28
|
+
className,
|
|
29
|
+
ref,
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}) => /* @__PURE__ */ jsx(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
ref,
|
|
36
|
+
className: cn(
|
|
37
|
+
"py-govuk-1 px-govuk-3 sm:px-govuk-4",
|
|
38
|
+
"border-b border-b-transparent",
|
|
39
|
+
className
|
|
40
|
+
),
|
|
41
|
+
...props,
|
|
42
|
+
children
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
var NotificationBannerTitle = ({
|
|
46
|
+
className,
|
|
47
|
+
ref,
|
|
48
|
+
children = "Important",
|
|
49
|
+
id = "govuk-notification-banner-title",
|
|
50
|
+
...props
|
|
51
|
+
}) => /* @__PURE__ */ jsx(
|
|
52
|
+
"h2",
|
|
53
|
+
{
|
|
54
|
+
ref,
|
|
55
|
+
id,
|
|
56
|
+
className: cn("text-govuk-body font-bold m-0 p-0 text-white", className),
|
|
57
|
+
...props,
|
|
58
|
+
children
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
var NotificationBannerContent = ({
|
|
62
|
+
className,
|
|
63
|
+
ref,
|
|
64
|
+
children,
|
|
65
|
+
...props
|
|
66
|
+
}) => /* @__PURE__ */ jsx(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
ref,
|
|
70
|
+
className: cn(
|
|
71
|
+
"p-govuk-3 sm:p-govuk-4",
|
|
72
|
+
"text-govuk-black bg-white",
|
|
73
|
+
"*:last:mb-0",
|
|
74
|
+
className
|
|
75
|
+
),
|
|
76
|
+
...props,
|
|
77
|
+
children
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
var NotificationBannerHeading = ({
|
|
81
|
+
className,
|
|
82
|
+
ref,
|
|
83
|
+
children,
|
|
84
|
+
...props
|
|
85
|
+
}) => /* @__PURE__ */ jsx(
|
|
86
|
+
"h3",
|
|
87
|
+
{
|
|
88
|
+
ref,
|
|
89
|
+
className: cn(
|
|
90
|
+
"text-govuk-heading-m font-bold m-0 mb-govuk-3 p-0",
|
|
91
|
+
className
|
|
92
|
+
),
|
|
93
|
+
...props,
|
|
94
|
+
children
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
var NotificationBannerLink = ({
|
|
98
|
+
className,
|
|
99
|
+
ref,
|
|
100
|
+
children,
|
|
101
|
+
...props
|
|
102
|
+
}) => /* @__PURE__ */ jsx(
|
|
103
|
+
"a",
|
|
104
|
+
{
|
|
105
|
+
ref,
|
|
106
|
+
className: cn(
|
|
107
|
+
"font-govuk text-govuk-brand font-bold",
|
|
108
|
+
"underline govuk-link-underline",
|
|
109
|
+
"hover:govuk-link-underline-hover",
|
|
110
|
+
"focus:govuk-link-focus",
|
|
111
|
+
"visited:text-govuk-brand",
|
|
112
|
+
className
|
|
113
|
+
),
|
|
114
|
+
...props,
|
|
115
|
+
children
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
export { NotificationBanner, NotificationBannerContent, NotificationBannerHeader, NotificationBannerHeading, NotificationBannerLink, NotificationBannerTitle };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Textarea } from './chunk-AO6HPG4R.js';
|
|
2
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var countWords = (text) => {
|
|
7
|
+
const trimmed = text.trim();
|
|
8
|
+
if (trimmed === "") return 0;
|
|
9
|
+
return trimmed.split(/\s+/).length;
|
|
10
|
+
};
|
|
11
|
+
var defaultFormatMessage = (remaining, mode) => {
|
|
12
|
+
const unit = mode === "words" ? "words" : "characters";
|
|
13
|
+
if (remaining >= 0) {
|
|
14
|
+
return `You have ${remaining} ${unit} remaining`;
|
|
15
|
+
}
|
|
16
|
+
const over = Math.abs(remaining);
|
|
17
|
+
return `You have ${over} ${unit} too many`;
|
|
18
|
+
};
|
|
19
|
+
var getCount = (text, mode) => {
|
|
20
|
+
if (mode === "words") return countWords(text);
|
|
21
|
+
return text.length;
|
|
22
|
+
};
|
|
23
|
+
var CharacterCount = ({
|
|
24
|
+
id,
|
|
25
|
+
maxCount,
|
|
26
|
+
mode = "characters",
|
|
27
|
+
threshold = 0,
|
|
28
|
+
rows = 5,
|
|
29
|
+
defaultValue = "",
|
|
30
|
+
value,
|
|
31
|
+
error = false,
|
|
32
|
+
disabled = false,
|
|
33
|
+
className,
|
|
34
|
+
textareaClassName,
|
|
35
|
+
onChange,
|
|
36
|
+
name,
|
|
37
|
+
ref,
|
|
38
|
+
formatMessage = defaultFormatMessage
|
|
39
|
+
}) => {
|
|
40
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
41
|
+
const currentValue = value ?? internalValue;
|
|
42
|
+
const currentCount = getCount(currentValue, mode);
|
|
43
|
+
const remaining = maxCount - currentCount;
|
|
44
|
+
const isOverLimit = remaining < 0;
|
|
45
|
+
const thresholdValue = Math.ceil(maxCount * threshold / 100);
|
|
46
|
+
const showMessage = threshold === 0 || currentCount >= thresholdValue;
|
|
47
|
+
const message = formatMessage(remaining, mode);
|
|
48
|
+
const handleChange = useCallback(
|
|
49
|
+
(e) => {
|
|
50
|
+
if (value === void 0) {
|
|
51
|
+
setInternalValue(e.target.value);
|
|
52
|
+
}
|
|
53
|
+
onChange?.(e);
|
|
54
|
+
},
|
|
55
|
+
[value, onChange]
|
|
56
|
+
);
|
|
57
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("font-govuk mb-govuk-6", className), children: [
|
|
58
|
+
/* @__PURE__ */ jsx(
|
|
59
|
+
Textarea,
|
|
60
|
+
{
|
|
61
|
+
ref,
|
|
62
|
+
id,
|
|
63
|
+
name,
|
|
64
|
+
rows,
|
|
65
|
+
value: currentValue,
|
|
66
|
+
onChange: handleChange,
|
|
67
|
+
error: error || isOverLimit,
|
|
68
|
+
disabled,
|
|
69
|
+
"aria-describedby": `${id}-info`,
|
|
70
|
+
className: cn("mb-govuk-1", textareaClassName)
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
CharacterCountMessage,
|
|
75
|
+
{
|
|
76
|
+
id: `${id}-info`,
|
|
77
|
+
className: cn(
|
|
78
|
+
isOverLimit && "text-govuk-error font-bold",
|
|
79
|
+
!showMessage && "invisible"
|
|
80
|
+
),
|
|
81
|
+
children: message
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] });
|
|
85
|
+
};
|
|
86
|
+
var CharacterCountMessage = ({
|
|
87
|
+
className,
|
|
88
|
+
children,
|
|
89
|
+
ref,
|
|
90
|
+
...props
|
|
91
|
+
}) => /* @__PURE__ */ jsx(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
ref,
|
|
95
|
+
className: cn(
|
|
96
|
+
"font-govuk text-govuk-body text-govuk-dark-grey",
|
|
97
|
+
"mt-0 mb-0 tabular-nums",
|
|
98
|
+
className
|
|
99
|
+
),
|
|
100
|
+
...props,
|
|
101
|
+
children
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export { CharacterCount, CharacterCountMessage };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var tableCaptionVariants = cva("font-bold table-caption text-left", {
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
m: "text-govuk-heading-m mb-govuk-3",
|
|
9
|
+
l: "text-govuk-heading-l mb-govuk-3",
|
|
10
|
+
xl: "text-govuk-heading-xl mb-govuk-3"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var Table = ({ className, ref, children, ...props }) => /* @__PURE__ */ jsx(
|
|
15
|
+
"table",
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
className: cn(
|
|
19
|
+
"w-full mb-govuk-6 border-spacing-0 border-collapse",
|
|
20
|
+
"font-govuk text-govuk-body text-govuk-black",
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
...props,
|
|
24
|
+
children
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
var TableCaption = ({
|
|
28
|
+
className,
|
|
29
|
+
ref,
|
|
30
|
+
children,
|
|
31
|
+
size,
|
|
32
|
+
...props
|
|
33
|
+
}) => /* @__PURE__ */ jsx(
|
|
34
|
+
"caption",
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
className: cn(
|
|
38
|
+
"font-govuk font-bold table-caption text-left",
|
|
39
|
+
tableCaptionVariants({ size }),
|
|
40
|
+
className
|
|
41
|
+
),
|
|
42
|
+
...props,
|
|
43
|
+
children
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
var TableHead = ({ className, ref, children, ...props }) => /* @__PURE__ */ jsx("thead", { ref, className: cn(className), ...props, children });
|
|
47
|
+
var TableBody = ({ className, ref, children, ...props }) => /* @__PURE__ */ jsx("tbody", { ref, className: cn(className), ...props, children });
|
|
48
|
+
var TableRow = ({ className, ref, children, ...props }) => /* @__PURE__ */ jsx("tr", { ref, className: cn(className), ...props, children });
|
|
49
|
+
var TableHeader = ({
|
|
50
|
+
className,
|
|
51
|
+
ref,
|
|
52
|
+
children,
|
|
53
|
+
numeric,
|
|
54
|
+
...props
|
|
55
|
+
}) => /* @__PURE__ */ jsx(
|
|
56
|
+
"th",
|
|
57
|
+
{
|
|
58
|
+
ref,
|
|
59
|
+
className: cn(
|
|
60
|
+
"govuk-table-cell font-bold",
|
|
61
|
+
numeric && "text-right tabular-nums",
|
|
62
|
+
className
|
|
63
|
+
),
|
|
64
|
+
...props,
|
|
65
|
+
children
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
var TableCell = ({
|
|
69
|
+
className,
|
|
70
|
+
ref,
|
|
71
|
+
children,
|
|
72
|
+
numeric,
|
|
73
|
+
...props
|
|
74
|
+
}) => /* @__PURE__ */ jsx(
|
|
75
|
+
"td",
|
|
76
|
+
{
|
|
77
|
+
ref,
|
|
78
|
+
className: cn(
|
|
79
|
+
"govuk-table-cell",
|
|
80
|
+
numeric && "text-right tabular-nums",
|
|
81
|
+
className
|
|
82
|
+
),
|
|
83
|
+
...props,
|
|
84
|
+
children
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
export { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow, tableCaptionVariants };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { Collapsible } from '@base-ui/react/collapsible';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var Details = ({ className, ref, ...props }) => /* @__PURE__ */ jsx(
|
|
6
|
+
Collapsible.Root,
|
|
7
|
+
{
|
|
8
|
+
ref,
|
|
9
|
+
className: cn(
|
|
10
|
+
"mb-govuk-6 font-govuk text-govuk-body text-govuk-black",
|
|
11
|
+
className
|
|
12
|
+
),
|
|
13
|
+
...props
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
var DetailsSummary = ({
|
|
17
|
+
className,
|
|
18
|
+
ref,
|
|
19
|
+
children,
|
|
20
|
+
...props
|
|
21
|
+
}) => /* @__PURE__ */ jsxs(
|
|
22
|
+
Collapsible.Trigger,
|
|
23
|
+
{
|
|
24
|
+
ref,
|
|
25
|
+
className: cn(
|
|
26
|
+
"group relative w-fit cursor-pointer",
|
|
27
|
+
"pl-govuk-4 border-none bg-transparent p-0",
|
|
28
|
+
"font-govuk text-govuk-body text-govuk-brand",
|
|
29
|
+
"underline govuk-link-underline",
|
|
30
|
+
"hover:text-govuk-brand-hover hover:govuk-link-underline-hover",
|
|
31
|
+
"focus:govuk-link-focus focus:no-underline",
|
|
32
|
+
className
|
|
33
|
+
),
|
|
34
|
+
...props,
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
"svg",
|
|
38
|
+
{
|
|
39
|
+
className: "absolute left-0 top-0 bottom-0 my-auto shrink-0 transition-transform group-data-panel-open:rotate-90",
|
|
40
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
41
|
+
width: "14",
|
|
42
|
+
height: "14",
|
|
43
|
+
viewBox: "0 0 14 14",
|
|
44
|
+
fill: "currentColor",
|
|
45
|
+
"aria-hidden": "true",
|
|
46
|
+
focusable: "false",
|
|
47
|
+
children: /* @__PURE__ */ jsx("path", { d: "M3.5 1L10.5 7L3.5 13z" })
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
children
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
var DetailsText = ({ className, ref, ...props }) => /* @__PURE__ */ jsx(
|
|
55
|
+
Collapsible.Panel,
|
|
56
|
+
{
|
|
57
|
+
ref,
|
|
58
|
+
className: cn(
|
|
59
|
+
"pt-govuk-3 pb-govuk-3 pl-govuk-4",
|
|
60
|
+
"border-l-govuk-inset",
|
|
61
|
+
className
|
|
62
|
+
),
|
|
63
|
+
...props
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export { Details, DetailsSummary, DetailsText };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { cn } from './chunk-WONVZ7WK.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var Breadcrumbs = ({
|
|
5
|
+
className,
|
|
6
|
+
collapseOnMobile,
|
|
7
|
+
inverse,
|
|
8
|
+
ref,
|
|
9
|
+
children,
|
|
10
|
+
...props
|
|
11
|
+
}) => /* @__PURE__ */ jsx(
|
|
12
|
+
"nav",
|
|
13
|
+
{
|
|
14
|
+
ref,
|
|
15
|
+
"aria-label": "Breadcrumb",
|
|
16
|
+
className: cn(
|
|
17
|
+
"font-govuk text-govuk-header",
|
|
18
|
+
"mt-govuk-3 mb-govuk-2",
|
|
19
|
+
inverse ? "text-white" : "text-govuk-black",
|
|
20
|
+
collapseOnMobile && "[&_ol]:max-sm:flex [&_li]:max-sm:hidden [&_li:first-child]:max-sm:inline-block [&_li:last-child]:max-sm:inline-block",
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
...props,
|
|
24
|
+
children
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
var BreadcrumbsList = ({
|
|
28
|
+
className,
|
|
29
|
+
ref,
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}) => /* @__PURE__ */ jsx("ol", { ref, className: cn("m-0 p-0 list-none", className), ...props, children });
|
|
33
|
+
var BreadcrumbsListItem = ({
|
|
34
|
+
className,
|
|
35
|
+
ref,
|
|
36
|
+
children,
|
|
37
|
+
...props
|
|
38
|
+
}) => /* @__PURE__ */ jsxs(
|
|
39
|
+
"li",
|
|
40
|
+
{
|
|
41
|
+
ref,
|
|
42
|
+
className: cn(
|
|
43
|
+
"inline-block mb-govuk-1",
|
|
44
|
+
"first:ml-0 first:pl-0 first:[&>svg]:hidden",
|
|
45
|
+
className
|
|
46
|
+
),
|
|
47
|
+
...props,
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
"svg",
|
|
51
|
+
{
|
|
52
|
+
className: "inline-block align-middle mx-govuk-2 -mt-px",
|
|
53
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
+
width: "7",
|
|
55
|
+
height: "11",
|
|
56
|
+
viewBox: "0 0 7 11",
|
|
57
|
+
fill: "none",
|
|
58
|
+
"aria-hidden": "true",
|
|
59
|
+
focusable: "false",
|
|
60
|
+
children: /* @__PURE__ */ jsx(
|
|
61
|
+
"path",
|
|
62
|
+
{
|
|
63
|
+
d: "M1 1L5.5 5.5L1 10",
|
|
64
|
+
stroke: "currentColor",
|
|
65
|
+
strokeWidth: "1",
|
|
66
|
+
strokeOpacity: "0.65"
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
children
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
var BreadcrumbsLink = ({
|
|
76
|
+
className,
|
|
77
|
+
ref,
|
|
78
|
+
children,
|
|
79
|
+
...props
|
|
80
|
+
}) => /* @__PURE__ */ jsx(
|
|
81
|
+
"a",
|
|
82
|
+
{
|
|
83
|
+
ref,
|
|
84
|
+
className: cn(
|
|
85
|
+
"text-govuk-black underline govuk-link-underline",
|
|
86
|
+
"hover:text-govuk-black hover:govuk-link-underline-hover",
|
|
87
|
+
"focus:govuk-link-focus",
|
|
88
|
+
className
|
|
89
|
+
),
|
|
90
|
+
...props,
|
|
91
|
+
children
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
export { Breadcrumbs, BreadcrumbsLink, BreadcrumbsList, BreadcrumbsListItem };
|