whitehall-ui 2.0.0 → 2.2.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.
Files changed (41) hide show
  1. package/README.md +9 -2
  2. package/dist/chunk-25PZB34H.js +105 -0
  3. package/dist/chunk-336BAPDV.js +153 -0
  4. package/dist/{chunk-CYBPAHLZ.js → chunk-7TI7IVX5.js} +40 -7
  5. package/dist/{chunk-FVBDMMNR.js → chunk-A3JRUVST.js} +1 -1
  6. package/dist/{chunk-OQILIT3B.js → chunk-A3K2CJUC.js} +1 -1
  7. package/dist/{chunk-VMI2XU5D.js → chunk-GFRA77XT.js} +4 -4
  8. package/dist/{chunk-ASBIQC77.js → chunk-IOAJ3OIQ.js} +11 -11
  9. package/dist/{chunk-2KB4IAMZ.js → chunk-JXR63GVO.js} +1 -1
  10. package/dist/chunk-LXPS6UFQ.js +175 -0
  11. package/dist/chunk-VEIYL5NB.js +19 -0
  12. package/dist/{chunk-7Q2C5RB7.js → chunk-WMOWFYPB.js} +28 -1
  13. package/dist/{chunk-QPN5J5IU.js → chunk-XVE5B2T3.js} +1 -1
  14. package/dist/{chunk-ZAKQHDVD.js → chunk-ZT5VOKVY.js} +1 -1
  15. package/dist/index.d.ts +3 -2
  16. package/dist/index.js +14 -13
  17. package/dist/ui/accordion.js +1 -1
  18. package/dist/ui/breadcrumbs.js +1 -1
  19. package/dist/ui/button.js +1 -1
  20. package/dist/ui/checkboxes.d.ts +6 -3
  21. package/dist/ui/checkboxes.js +1 -1
  22. package/dist/ui/exit-this-page.js +2 -2
  23. package/dist/ui/file-upload.d.ts +2 -1
  24. package/dist/ui/file-upload.js +1 -1
  25. package/dist/ui/form-group.d.ts +9 -0
  26. package/dist/ui/form-group.js +2 -0
  27. package/dist/ui/language-navigation.js +1 -1
  28. package/dist/ui/password-input.d.ts +1 -1
  29. package/dist/ui/password-input.js +2 -2
  30. package/dist/ui/phase-banner.js +1 -1
  31. package/dist/ui/radios.d.ts +13 -5
  32. package/dist/ui/radios.js +1 -1
  33. package/dist/ui/service-navigation.d.ts +10 -4
  34. package/dist/ui/service-navigation.js +1 -1
  35. package/dist/ui/task-list.d.ts +1 -1
  36. package/dist/ui/task-list.js +1 -1
  37. package/package.json +1 -1
  38. package/registry/default/theme/govuk-tokens.css +7 -1
  39. package/dist/chunk-4GQRYMDK.js +0 -128
  40. package/dist/chunk-JCERRZV6.js +0 -136
  41. package/dist/chunk-YF6EZ57H.js +0 -77
package/README.md CHANGED
@@ -77,6 +77,13 @@ Copy the component source into your own codebase (fully editable, no runtime dep
77
77
  npx shadcn@latest add https://dawidmakos.github.io/whitehall-ui/r/govuk-tokens.json
78
78
  ```
79
79
 
80
+ This writes `src/styles/govuk-tokens.css`. Import it in your CSS entry point after Tailwind:
81
+
82
+ ```css
83
+ @import "tailwindcss";
84
+ @import "./styles/govuk-tokens.css"; /* path relative to src/index.css */
85
+ ```
86
+
80
87
  ### 2. Add components
81
88
 
82
89
  ```bash
@@ -84,7 +91,7 @@ npx shadcn@latest add https://dawidmakos.github.io/whitehall-ui/r/button.json
84
91
  npx shadcn@latest add https://dawidmakos.github.io/whitehall-ui/r/text-input.json
85
92
  ```
86
93
 
87
- Swap `button` / `text-input` for any component name below. The CLI resolves each component's dependencies (e.g. the `cn` util) automatically.
94
+ Swap `button` / `text-input` for any component name below. The CLI resolves each component's dependencies automatically. One of those is `lib/utils.ts`, which replaces shadcn's default `cn` with a version that understands the GOV.UK token classes and adds `mergeRefs`. Accept the overwrite prompt.
88
95
 
89
96
  ### 3. Use it
90
97
 
@@ -100,7 +107,7 @@ export function Example() {
100
107
 
101
108
  ## Available components
102
109
 
103
- `accordion` · `back-link` · `breadcrumbs` · `button` · `character-count` · `checkboxes` · `cookie-banner` · `date-input` · `details` · `error-message` · `error-summary` · `exit-this-page` · `fieldset` · `file-upload` · `footer` · `generic-header` · `header` · `hint` · `inset-text` · `label` · `link` · `notification-banner` · `pagination` · `panel` · `password-input` · `phase-banner` · `radios` · `select` · `service-navigation` · `skip-link` · `summary-list` · `table` · `tabs` · `tag` · `task-list` · `text-input` · `textarea` · `warning-text`
110
+ `accordion` · `back-link` · `breadcrumbs` · `button` · `character-count` · `checkboxes` · `cookie-banner` · `date-input` · `details` · `error-message` · `error-summary` · `exit-this-page` · `feedback` · `fieldset` · `file-upload` · `footer` · `form-group` · `generic-header` · `header` · `hint` · `inset-text` · `label` · `language-navigation` · `link` · `notification-banner` · `pagination` · `panel` · `password-input` · `phase-banner` · `radios` · `select` · `service-navigation` · `skip-link` · `summary-list` · `table` · `tabs` · `tag` · `task-list` · `text-input` · `textarea` · `warning-text`
104
111
 
105
112
  See the [Storybook](https://dawidmakos.github.io/whitehall-ui/) for props and live examples.
106
113
 
@@ -0,0 +1,105 @@
1
+ import { cn } from './chunk-GKHD33N6.js';
2
+ import { createContext, useId, use } from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var TaskListItemContext = createContext({ hintId: "", statusId: "" });
6
+ var TaskList = ({ className, ...props }) => /* @__PURE__ */ jsx(
7
+ "ul",
8
+ {
9
+ className: cn(
10
+ "font-govuk text-govuk-body text-govuk-black",
11
+ "mt-0 mb-govuk-r6 p-0 list-none",
12
+ className
13
+ ),
14
+ ...props
15
+ }
16
+ );
17
+ var TaskListItem = ({ className, hasLink, ...props }) => {
18
+ const id = useId();
19
+ return /* @__PURE__ */ jsx(
20
+ TaskListItemContext,
21
+ {
22
+ value: { hintId: `${id}-hint`, statusId: `${id}-status` },
23
+ children: /* @__PURE__ */ jsx(
24
+ "li",
25
+ {
26
+ className: cn(
27
+ "table relative w-full mb-0",
28
+ "py-govuk-2",
29
+ "border-b border-govuk-mid-grey",
30
+ "first:border-t first:border-t-govuk-mid-grey",
31
+ hasLink && "hover:bg-govuk-light-grey",
32
+ className
33
+ ),
34
+ ...props
35
+ }
36
+ )
37
+ }
38
+ );
39
+ };
40
+ var TaskListNameAndHint = ({
41
+ className,
42
+ ...props
43
+ }) => /* @__PURE__ */ jsx(
44
+ "div",
45
+ {
46
+ className: cn("table-cell align-top text-govuk-black", className),
47
+ ...props
48
+ }
49
+ );
50
+ var TaskListLink = ({
51
+ className,
52
+ children,
53
+ "aria-describedby": ariaDescribedBy,
54
+ ...props
55
+ }) => {
56
+ const { hintId, statusId } = use(TaskListItemContext);
57
+ return /* @__PURE__ */ jsx(
58
+ "a",
59
+ {
60
+ "aria-describedby": `${hintId} ${statusId} ${ariaDescribedBy ?? ""}`.trim() || void 0,
61
+ className: cn(
62
+ "text-govuk-link underline govuk-link-underline",
63
+ "visited:text-govuk-visited active:text-govuk-black",
64
+ "hover:text-govuk-brand-hover hover:govuk-link-underline-hover",
65
+ "focus:govuk-link-focus",
66
+ "after:block after:absolute after:inset-0",
67
+ className
68
+ ),
69
+ ...props,
70
+ children
71
+ }
72
+ );
73
+ };
74
+ var TaskListHint = ({ className, ...props }) => {
75
+ const { hintId } = use(TaskListItemContext);
76
+ return /* @__PURE__ */ jsx(
77
+ "div",
78
+ {
79
+ className: cn("mt-govuk-1 text-govuk-dark-grey", className),
80
+ ...props,
81
+ id: hintId || props.id
82
+ }
83
+ );
84
+ };
85
+ var TaskListStatus = ({
86
+ className,
87
+ cannotStartYet,
88
+ ...props
89
+ }) => {
90
+ const { statusId } = use(TaskListItemContext);
91
+ return /* @__PURE__ */ jsx(
92
+ "div",
93
+ {
94
+ className: cn(
95
+ "table-cell pl-govuk-2 text-right align-top",
96
+ cannotStartYet ? "text-govuk-dark-grey" : "text-govuk-black",
97
+ className
98
+ ),
99
+ ...props,
100
+ id: statusId || props.id
101
+ }
102
+ );
103
+ };
104
+
105
+ export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus };
@@ -0,0 +1,153 @@
1
+ import { cn } from './chunk-GKHD33N6.js';
2
+ import { useId } from 'react';
3
+ import { Checkbox } from '@base-ui/react/checkbox';
4
+ import { CheckboxGroup } from '@base-ui/react/checkbox-group';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+
7
+ var Checkboxes = (props) => /* @__PURE__ */ jsx(CheckboxGroup, { ...props });
8
+ var CheckboxesItem = ({
9
+ className,
10
+ children,
11
+ hint,
12
+ "aria-describedby": ariaDescribedBy,
13
+ small,
14
+ ...props
15
+ }) => {
16
+ const labelId = useId();
17
+ const hintId = useId();
18
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ /* @__PURE__ */ jsxs(
20
+ "label",
21
+ {
22
+ className: cn(
23
+ "flex flex-wrap items-start",
24
+ "relative",
25
+ small ? "group/item mb-0" : "mb-govuk-2 last:mb-0",
26
+ "cursor-pointer touch-manipulation",
27
+ "has-data-disabled:opacity-50 has-data-disabled:cursor-not-allowed",
28
+ className
29
+ ),
30
+ children: [
31
+ /* @__PURE__ */ jsxs(
32
+ Checkbox.Root,
33
+ {
34
+ "aria-labelledby": labelId,
35
+ "aria-describedby": `${hint ? hintId : ""} ${ariaDescribedBy ?? ""}`.trim() || void 0,
36
+ className: cn(
37
+ "group/checkbox",
38
+ "relative flex-none",
39
+ "w-govuk-checkbox-touch-target h-govuk-checkbox-touch-target",
40
+ "outline-none",
41
+ small && "-ml-govuk-2"
42
+ ),
43
+ ...props,
44
+ children: [
45
+ /* @__PURE__ */ jsx(
46
+ "span",
47
+ {
48
+ "aria-hidden": "true",
49
+ className: cn(
50
+ "absolute box-border",
51
+ small ? "top-govuk-checkbox-small-box-offset left-govuk-checkbox-small-box-offset w-govuk-checkbox-small-size h-govuk-checkbox-small-size" : "top-[calc(var(--spacing-govuk-checkbox-gutter)/2)] left-[calc(var(--spacing-govuk-checkbox-gutter)/2)] w-govuk-checkbox-size h-govuk-checkbox-size",
52
+ "border-2 border-current bg-transparent",
53
+ "govuk-checkbox-composed-shadow",
54
+ "group-focus/checkbox:border-4",
55
+ "group-focus/checkbox:govuk-checkbox-focus-shadow",
56
+ "group-focus/checkbox:outline-3 group-focus/checkbox:outline-transparent group-focus/checkbox:outline-offset-1",
57
+ small && "group-hover/item:govuk-checkbox-small-hover"
58
+ )
59
+ }
60
+ ),
61
+ /* @__PURE__ */ jsx(
62
+ Checkbox.Indicator,
63
+ {
64
+ keepMounted: true,
65
+ className: cn(
66
+ "absolute box-border",
67
+ small ? "top-govuk-checkbox-small-check-top left-govuk-checkbox-small-check-left w-govuk-checkbox-small-check-width h-govuk-checkbox-small-check-height govuk-checkmark-small" : "top-govuk-checkbox-check-top left-govuk-checkbox-check-left w-govuk-checkbox-check-width h-govuk-checkbox-check-height govuk-checkmark",
68
+ "opacity-0 data-checked:opacity-100"
69
+ )
70
+ }
71
+ )
72
+ ]
73
+ }
74
+ ),
75
+ /* @__PURE__ */ jsx(
76
+ "span",
77
+ {
78
+ id: labelId,
79
+ className: cn(
80
+ "self-center",
81
+ "py-govuk-checkbox-label-padding-y px-govuk-checkbox-label-padding-x",
82
+ "text-govuk-tag font-normal font-govuk",
83
+ small ? "pl-px max-w-[calc(100%-50px)]" : "max-w-[calc(100%-74px)]"
84
+ ),
85
+ children
86
+ }
87
+ )
88
+ ]
89
+ }
90
+ ),
91
+ hint && /* @__PURE__ */ jsx(
92
+ CheckboxesHint,
93
+ {
94
+ id: hintId,
95
+ className: cn(
96
+ small && "pl-[calc(var(--spacing-govuk-checkbox-touch-target)-var(--spacing-govuk-2))]"
97
+ ),
98
+ children: hint
99
+ }
100
+ )
101
+ ] });
102
+ };
103
+ var CheckboxesHint = ({ className, ...props }) => /* @__PURE__ */ jsx(
104
+ "span",
105
+ {
106
+ className: cn(
107
+ "block w-full",
108
+ "-mt-govuk-3 mb-govuk-2 last:mb-0",
109
+ "pr-govuk-checkbox-label-padding-x",
110
+ "pl-[calc(var(--spacing-govuk-checkbox-label-padding-x)+var(--spacing-govuk-checkbox-touch-target))]",
111
+ "text-govuk-tag font-normal font-govuk text-govuk-dark-grey",
112
+ className
113
+ ),
114
+ ...props
115
+ }
116
+ );
117
+ var CheckboxesDivider = ({
118
+ className,
119
+ children = "or",
120
+ small,
121
+ ...props
122
+ }) => /* @__PURE__ */ jsx(
123
+ "div",
124
+ {
125
+ className: cn(
126
+ small ? "w-govuk-checkbox-small-size mb-govuk-1" : "w-govuk-checkbox-size mb-govuk-2",
127
+ "text-govuk-tag font-normal font-govuk text-govuk-black",
128
+ "text-center",
129
+ className
130
+ ),
131
+ ...props,
132
+ children
133
+ }
134
+ );
135
+ var CheckboxesConditional = ({
136
+ className,
137
+ small,
138
+ ...props
139
+ }) => /* @__PURE__ */ jsx(
140
+ "div",
141
+ {
142
+ className: cn(
143
+ small ? "ml-govuk-2 pl-govuk-4" : "ml-govuk-checkbox-conditional-ml pl-govuk-checkbox-conditional-pl",
144
+ "mb-govuk-3 sm:mb-govuk-4",
145
+ "border-l-4 border-govuk-grey",
146
+ "*:last:mb-0",
147
+ className
148
+ ),
149
+ ...props
150
+ }
151
+ );
152
+
153
+ export { Checkboxes, CheckboxesConditional, CheckboxesDivider, CheckboxesHint, CheckboxesItem };
@@ -9,6 +9,12 @@ var useHydrated = () => useSyncExternalStore(
9
9
  () => true,
10
10
  () => false
11
11
  );
12
+ var inverseLinkStyles = [
13
+ "group-data-inverse/service-nav:text-white",
14
+ "group-data-inverse/service-nav:visited:text-white",
15
+ "group-data-inverse/service-nav:hover:text-white",
16
+ "group-data-inverse/service-nav:active:text-white"
17
+ ];
12
18
  var linkStyles = [
13
19
  "font-govuk cursor-pointer",
14
20
  "no-underline hover:underline active:underline",
@@ -20,14 +26,21 @@ var itemStyles = [
20
26
  "sm:my-0 sm:inline-block sm:py-govuk-3 sm:leading-govuk-service-nav",
21
27
  "sm:not-last:mr-govuk-6"
22
28
  ];
23
- var ServiceNavigation = ({ className, ...props }) => /* @__PURE__ */ jsx(
29
+ var ServiceNavigation = ({
30
+ className,
31
+ inverse,
32
+ ...props
33
+ }) => /* @__PURE__ */ jsx(
24
34
  "section",
25
35
  {
26
36
  "aria-label": "Service information",
37
+ "data-inverse": inverse || void 0,
27
38
  className: cn(
28
- "font-govuk text-govuk-body text-govuk-black",
29
- "border-b border-b-govuk-surface-border",
30
- "bg-govuk-surface",
39
+ "group/service-nav font-govuk text-govuk-body",
40
+ inverse ? "text-white bg-govuk-brand" : [
41
+ "text-govuk-black bg-govuk-surface",
42
+ "border-b border-b-govuk-surface-border"
43
+ ],
31
44
  className
32
45
  ),
33
46
  ...props
@@ -43,6 +56,8 @@ var ServiceNavigationContainer = ({
43
56
  "govuk-width-container",
44
57
  "flex flex-col items-start",
45
58
  "sm:flex-row sm:flex-wrap",
59
+ "group-data-inverse/service-nav:border-y",
60
+ "group-data-inverse/service-nav:border-govuk-surface-border",
46
61
  className
47
62
  ),
48
63
  ...props
@@ -64,7 +79,8 @@ var ServiceNavigationServiceName = ({
64
79
  className: cn(
65
80
  "text-govuk-black visited:text-govuk-black",
66
81
  "hover:text-govuk-black active:text-govuk-black",
67
- linkStyles
82
+ linkStyles,
83
+ inverseLinkStyles
68
84
  ),
69
85
  ...props,
70
86
  children
@@ -99,6 +115,7 @@ var ServiceNavigationNav = ({
99
115
  "my-govuk-2 p-0",
100
116
  "font-govuk text-govuk-body font-bold",
101
117
  "bg-transparent border-0 text-govuk-link cursor-pointer",
118
+ "group-data-inverse/service-nav:text-white",
102
119
  "focus:govuk-link-focus"
103
120
  ),
104
121
  onClick: () => setMenuOpen((prev) => !prev),
@@ -146,7 +163,7 @@ var ServiceNavigationItem = ({
146
163
  {
147
164
  className: cn(
148
165
  itemStyles,
149
- "border-govuk-link",
166
+ "border-govuk-link group-data-inverse/service-nav:border-current",
150
167
  active && [
151
168
  "max-sm:-ml-govuk-3 max-sm:pl-govuk-2 max-sm:border-l-govuk-standard",
152
169
  "sm:border-b-govuk-standard sm:pb-govuk-2"
@@ -167,11 +184,27 @@ var ServiceNavigationLink = ({
167
184
  "text-govuk-link visited:text-govuk-link",
168
185
  "hover:text-govuk-brand-hover active:text-govuk-black",
169
186
  linkStyles,
187
+ inverseLinkStyles,
170
188
  className
171
189
  ),
172
190
  ...props,
173
191
  children
174
192
  }
175
193
  );
194
+ var ServiceNavigationEnd = ({
195
+ className,
196
+ inline,
197
+ ...props
198
+ }) => /* @__PURE__ */ jsx(
199
+ "div",
200
+ {
201
+ className: cn(
202
+ inline ? "sm:ml-auto sm:pl-govuk-6" : "w-full",
203
+ "*:mt-govuk-1 *:mb-govuk-3 sm:*:mt-govuk-3",
204
+ className
205
+ ),
206
+ ...props
207
+ }
208
+ );
176
209
 
177
- export { ServiceNavigation, ServiceNavigationContainer, ServiceNavigationItem, ServiceNavigationLink, ServiceNavigationNav, ServiceNavigationServiceName };
210
+ export { ServiceNavigation, ServiceNavigationContainer, ServiceNavigationEnd, ServiceNavigationItem, ServiceNavigationLink, ServiceNavigationNav, ServiceNavigationServiceName };
@@ -133,7 +133,7 @@ var AccordionContent = ({ className, ...props }) => /* @__PURE__ */ jsx(
133
133
  Accordion$1.Panel,
134
134
  {
135
135
  className: cn(
136
- "pt-govuk-3 pb-govuk-6 sm:pb-govuk-8 [&[hidden]]:py-0 *:last:mb-0",
136
+ "pt-govuk-3 pb-govuk-6 sm:pb-govuk-8 [[hidden]]:py-0 *:last:mb-0",
137
137
  className
138
138
  ),
139
139
  ...props
@@ -1,5 +1,5 @@
1
1
  import { TextInput } from './chunk-VCJE5UO2.js';
2
- import { Button } from './chunk-ASBIQC77.js';
2
+ import { Button } from './chunk-IOAJ3OIQ.js';
3
3
  import { cn } from './chunk-GKHD33N6.js';
4
4
  import { useId, useState, useRef, useEffect } from 'react';
5
5
  import { flushSync } from 'react-dom';
@@ -30,7 +30,7 @@ var LanguageNavigationItem = ({
30
30
  "flex items-center",
31
31
  "not-last:after:block not-last:after:h-[1em] not-last:after:mx-govuk-2",
32
32
  "not-last:after:border-r not-last:after:border-govuk-mid-grey",
33
- "group-data-[inverse]/language:not-last:after:border-current",
33
+ "group-data-inverse/language:not-last:after:border-current",
34
34
  className
35
35
  ),
36
36
  ...props
@@ -54,9 +54,9 @@ var LanguageNavigationLink = ({
54
54
  "hover:govuk-link-underline-hover focus:govuk-link-focus",
55
55
  "text-govuk-link visited:text-govuk-visited",
56
56
  "hover:text-govuk-brand-hover active:text-govuk-black",
57
- "group-data-[inverse]/language:text-white",
58
- "group-data-[inverse]/language:visited:text-white",
59
- "group-data-[inverse]/language:hover:text-white",
57
+ "group-data-inverse/language:text-white",
58
+ "group-data-inverse/language:visited:text-white",
59
+ "group-data-inverse/language:hover:text-white",
60
60
  className
61
61
  ),
62
62
  ...props,
@@ -18,12 +18,12 @@ var buttonVariants = cva(
18
18
  "active:top-govuk-button-press",
19
19
  "focus:border-govuk-yellow focus:outline-3 focus:outline-transparent",
20
20
  "focus:shadow-govuk-clear focus:inset-ring-1 focus:inset-ring-govuk-yellow",
21
- "focus:not-[:active]:not-[:hover]:bg-govuk-yellow",
22
- "focus:not-[:active]:not-[:hover]:text-govuk-black",
23
- "focus:not-[:active]:not-[:hover]:shadow-govuk-yellow",
24
- "focus:not-[:active]:not-[:hover]:inset-ring-0",
25
- "focus:not-[:active]:not-[:hover]:border-govuk-yellow",
26
- "data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed data-[disabled]:active:top-0"
21
+ "focus:not-active:not-[:hover]:bg-govuk-yellow",
22
+ "focus:not-active:not-[:hover]:text-govuk-black",
23
+ "focus:not-active:not-[:hover]:shadow-govuk-yellow",
24
+ "focus:not-active:not-[:hover]:inset-ring-0",
25
+ "focus:not-active:not-[:hover]:border-govuk-yellow",
26
+ "data-disabled:opacity-50 data-disabled:cursor-not-allowed data-disabled:active:top-0"
27
27
  ],
28
28
  {
29
29
  variants: {
@@ -31,31 +31,31 @@ var buttonVariants = cva(
31
31
  default: [
32
32
  "bg-govuk-green text-white",
33
33
  "shadow-govuk-green",
34
- "hover:not-data-[disabled]:bg-govuk-green-hover",
34
+ "hover:not-data-disabled:bg-govuk-green-hover",
35
35
  "visited:text-white active:text-white"
36
36
  ],
37
37
  secondary: [
38
38
  "bg-govuk-light-grey text-govuk-black",
39
39
  "shadow-govuk-light-grey",
40
- "hover:not-data-[disabled]:bg-govuk-grey",
40
+ "hover:not-data-disabled:bg-govuk-grey",
41
41
  "visited:text-govuk-black active:text-govuk-black"
42
42
  ],
43
43
  warning: [
44
44
  "bg-govuk-red text-white",
45
45
  "shadow-govuk-red",
46
- "hover:not-data-[disabled]:bg-govuk-red-hover",
46
+ "hover:not-data-disabled:bg-govuk-red-hover",
47
47
  "visited:text-white active:text-white"
48
48
  ],
49
49
  inverse: [
50
50
  "bg-white text-govuk-brand",
51
51
  "shadow-govuk-inverse",
52
- "hover:not-data-[disabled]:bg-govuk-inverse-hover",
52
+ "hover:not-data-disabled:bg-govuk-inverse-hover",
53
53
  "visited:text-govuk-brand active:text-govuk-brand"
54
54
  ],
55
55
  start: [
56
56
  "bg-govuk-green text-white",
57
57
  "shadow-govuk-green",
58
- "hover:not-data-[disabled]:bg-govuk-green-hover",
58
+ "hover:not-data-disabled:bg-govuk-green-hover",
59
59
  "visited:text-white active:text-white",
60
60
  "font-bold text-govuk-start",
61
61
  "inline-flex items-center justify-center"
@@ -39,7 +39,7 @@ var BreadcrumbsListItem = ({
39
39
  /* @__PURE__ */ jsx(
40
40
  "svg",
41
41
  {
42
- className: "inline-block align-middle mx-govuk-2 -mt-px text-govuk-dark-grey group-data-[inverse]/breadcrumbs:text-current",
42
+ className: "inline-block align-middle mx-govuk-2 -mt-px text-govuk-dark-grey group-data-inverse/breadcrumbs:text-current",
43
43
  xmlns: "http://www.w3.org/2000/svg",
44
44
  width: "7",
45
45
  height: "11",
@@ -0,0 +1,175 @@
1
+ import { cn } from './chunk-GKHD33N6.js';
2
+ import { useId } from 'react';
3
+ import { RadioGroup } from '@base-ui/react/radio-group';
4
+ import { Radio } from '@base-ui/react/radio';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+
7
+ var Radios = ({ className, inline, ...props }) => /* @__PURE__ */ jsx(
8
+ RadioGroup,
9
+ {
10
+ className: cn(
11
+ inline && "sm:flex sm:flex-wrap sm:items-start sm:gap-x-govuk-4",
12
+ className
13
+ ),
14
+ ...props
15
+ }
16
+ );
17
+ var RadiosItem = ({
18
+ className,
19
+ children,
20
+ hint,
21
+ small,
22
+ "aria-describedby": ariaDescribedBy,
23
+ ...props
24
+ }) => {
25
+ const labelId = useId();
26
+ const hintId = useId();
27
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
28
+ /* @__PURE__ */ jsxs(
29
+ "label",
30
+ {
31
+ className: cn(
32
+ "flex flex-wrap items-start",
33
+ "relative",
34
+ small ? "group/item mb-0" : "mb-govuk-2 last:mb-0",
35
+ "cursor-pointer",
36
+ "has-data-disabled:opacity-50 has-data-disabled:cursor-not-allowed",
37
+ className
38
+ ),
39
+ children: [
40
+ /* @__PURE__ */ jsxs(
41
+ Radio.Root,
42
+ {
43
+ "aria-labelledby": labelId,
44
+ "aria-describedby": `${hint ? hintId : ""} ${ariaDescribedBy ?? ""}`.trim() || void 0,
45
+ className: cn(
46
+ "group/radio",
47
+ "relative flex-none",
48
+ "w-govuk-radio-touch-target h-govuk-radio-touch-target",
49
+ "outline-none",
50
+ small && "-ml-govuk-2"
51
+ ),
52
+ ...props,
53
+ children: [
54
+ /* @__PURE__ */ jsx(
55
+ "span",
56
+ {
57
+ "aria-hidden": "true",
58
+ className: cn(
59
+ "absolute box-border",
60
+ small ? "top-govuk-checkbox-small-box-offset left-govuk-checkbox-small-box-offset w-govuk-checkbox-small-size h-govuk-checkbox-small-size" : "top-[calc(var(--spacing-govuk-radio-gutter)/2)] left-[calc(var(--spacing-govuk-radio-gutter)/2)] w-govuk-radio-size h-govuk-radio-size",
61
+ "rounded-full",
62
+ "border-2 border-current bg-transparent",
63
+ "govuk-checkbox-composed-shadow",
64
+ "group-focus/radio:border-4",
65
+ "group-focus/radio:govuk-radio-focus-shadow",
66
+ "group-focus/radio:outline-govuk-radio-focus-width group-focus/radio:outline-transparent group-focus/radio:outline-offset-1",
67
+ small && "group-hover/item:govuk-checkbox-small-hover"
68
+ )
69
+ }
70
+ ),
71
+ /* @__PURE__ */ jsx(
72
+ Radio.Indicator,
73
+ {
74
+ keepMounted: true,
75
+ className: cn(
76
+ "absolute",
77
+ small ? [
78
+ "top-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-small-dot))]",
79
+ "left-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-small-dot))]",
80
+ "border-(length:--spacing-govuk-radio-small-dot)"
81
+ ] : [
82
+ "top-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-dot))]",
83
+ "left-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-dot))]",
84
+ "border-(length:--spacing-govuk-radio-dot)"
85
+ ],
86
+ "w-0 h-0",
87
+ "rounded-full",
88
+ "border-current",
89
+ "bg-current",
90
+ "opacity-0 data-checked:opacity-100"
91
+ )
92
+ }
93
+ )
94
+ ]
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsx(
98
+ "span",
99
+ {
100
+ id: labelId,
101
+ className: cn(
102
+ "self-center",
103
+ "py-govuk-button-pb px-govuk-radio-label-padding-x",
104
+ "text-govuk-tag font-normal font-govuk",
105
+ small ? "pl-px max-w-[calc(100%-50px)]" : "max-w-[calc(100%-74px)]"
106
+ ),
107
+ children
108
+ }
109
+ )
110
+ ]
111
+ }
112
+ ),
113
+ hint && /* @__PURE__ */ jsx(
114
+ RadiosHint,
115
+ {
116
+ id: hintId,
117
+ className: cn(
118
+ small && "pl-[calc(var(--spacing-govuk-radio-touch-target)-var(--spacing-govuk-2))]"
119
+ ),
120
+ children: hint
121
+ }
122
+ )
123
+ ] });
124
+ };
125
+ var RadiosHint = ({ className, ...props }) => /* @__PURE__ */ jsx(
126
+ "span",
127
+ {
128
+ className: cn(
129
+ "block w-full",
130
+ "-mt-govuk-3 mb-govuk-2 last:mb-0",
131
+ "pr-govuk-radio-label-padding-x",
132
+ "pl-[calc(var(--spacing-govuk-radio-label-padding-x)+var(--spacing-govuk-radio-touch-target))]",
133
+ "text-govuk-tag font-normal font-govuk text-govuk-dark-grey",
134
+ className
135
+ ),
136
+ ...props
137
+ }
138
+ );
139
+ var RadiosDivider = ({
140
+ className,
141
+ children = "or",
142
+ small,
143
+ ...props
144
+ }) => /* @__PURE__ */ jsx(
145
+ "div",
146
+ {
147
+ className: cn(
148
+ small ? "w-govuk-checkbox-small-size mb-govuk-1" : "w-govuk-radio-size mb-govuk-2",
149
+ "text-govuk-tag font-normal font-govuk text-govuk-black",
150
+ "text-center",
151
+ className
152
+ ),
153
+ ...props,
154
+ children
155
+ }
156
+ );
157
+ var RadiosConditional = ({
158
+ className,
159
+ small,
160
+ ...props
161
+ }) => /* @__PURE__ */ jsx(
162
+ "div",
163
+ {
164
+ className: cn(
165
+ small ? "ml-govuk-2 pl-govuk-4" : "ml-govuk-checkbox-conditional-ml pl-govuk-checkbox-conditional-pl",
166
+ "mb-govuk-3 sm:mb-govuk-4",
167
+ "border-l-4 border-govuk-grey",
168
+ "*:last:mb-0",
169
+ className
170
+ ),
171
+ ...props
172
+ }
173
+ );
174
+
175
+ export { Radios, RadiosConditional, RadiosDivider, RadiosHint, RadiosItem };