whitehall-ui 2.0.0 → 2.1.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 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` · `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,139 @@
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
+ "aria-describedby": ariaDescribedBy,
22
+ ...props
23
+ }) => {
24
+ const labelId = useId();
25
+ const hintId = useId();
26
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
27
+ /* @__PURE__ */ jsxs(
28
+ "label",
29
+ {
30
+ className: cn(
31
+ "flex flex-wrap items-start",
32
+ "relative",
33
+ "mb-govuk-2 last:mb-0",
34
+ "cursor-pointer",
35
+ "has-data-[disabled]:opacity-50 has-data-[disabled]:cursor-not-allowed",
36
+ className
37
+ ),
38
+ children: [
39
+ /* @__PURE__ */ jsxs(
40
+ Radio.Root,
41
+ {
42
+ "aria-labelledby": labelId,
43
+ "aria-describedby": `${hint ? hintId : ""} ${ariaDescribedBy ?? ""}`.trim() || void 0,
44
+ className: cn(
45
+ "group/radio",
46
+ "relative flex-none",
47
+ "w-govuk-radio-touch-target h-govuk-radio-touch-target",
48
+ "outline-none"
49
+ ),
50
+ ...props,
51
+ children: [
52
+ /* @__PURE__ */ jsx(
53
+ "span",
54
+ {
55
+ "aria-hidden": "true",
56
+ className: cn(
57
+ "absolute box-border",
58
+ "top-[calc(var(--spacing-govuk-radio-gutter)/2)] left-[calc(var(--spacing-govuk-radio-gutter)/2)]",
59
+ "w-govuk-radio-size h-govuk-radio-size",
60
+ "rounded-full",
61
+ "border-2 border-current bg-transparent",
62
+ "group-focus/radio:border-4",
63
+ "group-focus/radio:shadow-[0_0_0_var(--spacing-govuk-radio-focus-width)_var(--color-govuk-yellow)]",
64
+ "group-focus/radio:outline-govuk-radio-focus-width group-focus/radio:outline-transparent group-focus/radio:outline-offset-1"
65
+ )
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsx(
69
+ Radio.Indicator,
70
+ {
71
+ keepMounted: true,
72
+ className: cn(
73
+ "absolute",
74
+ "top-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-dot))]",
75
+ "left-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-dot))]",
76
+ "w-0 h-0",
77
+ "rounded-full",
78
+ "border-(length:--spacing-govuk-radio-dot) border-current",
79
+ "bg-current",
80
+ "opacity-0 data-checked:opacity-100"
81
+ )
82
+ }
83
+ )
84
+ ]
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsx(
88
+ "span",
89
+ {
90
+ id: labelId,
91
+ className: cn(
92
+ "self-center",
93
+ "py-govuk-button-pb px-govuk-radio-label-padding-x",
94
+ "text-govuk-tag font-normal font-govuk",
95
+ "max-w-[calc(100%-74px)]"
96
+ ),
97
+ children
98
+ }
99
+ )
100
+ ]
101
+ }
102
+ ),
103
+ hint && /* @__PURE__ */ jsx(RadiosHint, { id: hintId, children: hint })
104
+ ] });
105
+ };
106
+ var RadiosHint = ({ className, ...props }) => /* @__PURE__ */ jsx(
107
+ "span",
108
+ {
109
+ className: cn(
110
+ "block w-full",
111
+ "-mt-govuk-3 mb-govuk-2 last:mb-0",
112
+ "pr-govuk-radio-label-padding-x",
113
+ "pl-[calc(var(--spacing-govuk-radio-label-padding-x)+var(--spacing-govuk-radio-touch-target))]",
114
+ "text-govuk-tag font-normal font-govuk text-govuk-dark-grey",
115
+ className
116
+ ),
117
+ ...props
118
+ }
119
+ );
120
+ var RadiosDivider = ({
121
+ className,
122
+ children = "or",
123
+ ...props
124
+ }) => /* @__PURE__ */ jsx(
125
+ "div",
126
+ {
127
+ className: cn(
128
+ "w-govuk-radio-size",
129
+ "mb-govuk-2",
130
+ "text-govuk-tag font-normal font-govuk text-govuk-black",
131
+ "text-center",
132
+ className
133
+ ),
134
+ ...props,
135
+ children
136
+ }
137
+ );
138
+
139
+ export { Radios, RadiosDivider, RadiosHint, RadiosItem };
@@ -0,0 +1,152 @@
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
+ ...props
138
+ }) => /* @__PURE__ */ jsx(
139
+ "div",
140
+ {
141
+ className: cn(
142
+ "ml-govuk-checkbox-conditional-ml pl-govuk-checkbox-conditional-pl",
143
+ "mb-govuk-3 sm:mb-govuk-4",
144
+ "border-l-4 border-govuk-grey",
145
+ "*:last:mb-0",
146
+ className
147
+ ),
148
+ ...props
149
+ }
150
+ );
151
+
152
+ export { Checkboxes, CheckboxesConditional, CheckboxesDivider, CheckboxesHint, CheckboxesItem };
@@ -0,0 +1,100 @@
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 = ({ className, children, ...props }) => {
51
+ const { hintId, statusId } = use(TaskListItemContext);
52
+ return /* @__PURE__ */ jsx(
53
+ "a",
54
+ {
55
+ "aria-describedby": `${hintId} ${statusId}`.trim() || void 0,
56
+ className: cn(
57
+ "text-govuk-link underline govuk-link-underline",
58
+ "visited:text-govuk-visited active:text-govuk-black",
59
+ "hover:text-govuk-brand-hover hover:govuk-link-underline-hover",
60
+ "focus:govuk-link-focus",
61
+ "after:block after:absolute after:inset-0",
62
+ className
63
+ ),
64
+ ...props,
65
+ children
66
+ }
67
+ );
68
+ };
69
+ var TaskListHint = ({ className, ...props }) => {
70
+ const { hintId } = use(TaskListItemContext);
71
+ return /* @__PURE__ */ jsx(
72
+ "div",
73
+ {
74
+ className: cn("mt-govuk-1 text-govuk-dark-grey", className),
75
+ ...props,
76
+ id: hintId || props.id
77
+ }
78
+ );
79
+ };
80
+ var TaskListStatus = ({
81
+ className,
82
+ cannotStartYet,
83
+ ...props
84
+ }) => {
85
+ const { statusId } = use(TaskListItemContext);
86
+ return /* @__PURE__ */ jsx(
87
+ "div",
88
+ {
89
+ className: cn(
90
+ "table-cell pl-govuk-2 text-right align-top",
91
+ cannotStartYet ? "text-govuk-dark-grey" : "text-govuk-black",
92
+ className
93
+ ),
94
+ ...props,
95
+ id: statusId || props.id
96
+ }
97
+ );
98
+ };
99
+
100
+ export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus };
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ export { SummaryList, SummaryListActions, SummaryListCard, SummaryListCardAction
5
5
  export { Table, TableBody, TableCaption, TableCell, TableContainer, TableHead, TableHeader, TableRow, tableCaptionVariants } from './chunk-7IOR7UNU.js';
6
6
  export { Tabs, TabsList, TabsPanel, TabsTab } from './chunk-N5PY3VZH.js';
7
7
  export { Tag, tagVariants } from './chunk-VRGDQ3SF.js';
8
- export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus } from './chunk-YF6EZ57H.js';
8
+ export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus } from './chunk-YMQVN3MH.js';
9
9
  export { Link, linkVariants } from './chunk-HBLVAX45.js';
10
10
  export { NotificationBanner, NotificationBannerContent, NotificationBannerHeader, NotificationBannerHeading, NotificationBannerLink, NotificationBannerTitle } from './chunk-KXQGZLMK.js';
11
11
  export { NextArrow, Pagination, PaginationEllipsis, PaginationItem, PaginationLink, PaginationLinkLabel, PaginationLinkTitle, PaginationList, PaginationNext, PaginationPrevious, PrevArrow } from './chunk-6WLHJ5MN.js';
@@ -13,7 +13,7 @@ export { Panel, PanelActions, PanelBody, PanelTitle } from './chunk-CBT6WCJ7.js'
13
13
  export { PasswordInput } from './chunk-OQILIT3B.js';
14
14
  export { TextInput, textInputVariants } from './chunk-VCJE5UO2.js';
15
15
  export { PhaseBanner, PhaseBannerContent, PhaseBannerTag, PhaseBannerText } from './chunk-ZAKQHDVD.js';
16
- export { Radios, RadiosDivider, RadiosHint, RadiosItem } from './chunk-4GQRYMDK.js';
16
+ export { Radios, RadiosDivider, RadiosHint, RadiosItem } from './chunk-3NOO2YUQ.js';
17
17
  export { Select, selectVariants } from './chunk-UXOJELVU.js';
18
18
  export { FileUpload, fileUploadButtonVariants } from './chunk-7Q2C5RB7.js';
19
19
  export { Footer, FooterContainer, FooterContentLicence, FooterCrown, FooterHeading, FooterInlineList, FooterInlineListItem, FooterLicenceLogo, FooterLink, FooterList, FooterListItem, FooterMeta, FooterMetaItem, FooterNavigation, FooterSection, FooterSectionBreak } from './chunk-ZJB7BBTN.js';
@@ -37,5 +37,5 @@ export { Breadcrumbs, BreadcrumbsLink, BreadcrumbsList, BreadcrumbsListItem } fr
37
37
  export { Button, buttonVariants } from './chunk-ASBIQC77.js';
38
38
  export { CharacterCount, CharacterCountMessage } from './chunk-TAVSU2XB.js';
39
39
  export { Textarea, textareaVariants } from './chunk-EDOSCND4.js';
40
- export { Checkboxes, CheckboxesConditional, CheckboxesDivider, CheckboxesHint, CheckboxesItem } from './chunk-JCERRZV6.js';
40
+ export { Checkboxes, CheckboxesConditional, CheckboxesDivider, CheckboxesHint, CheckboxesItem } from './chunk-JU7A7KQI.js';
41
41
  export { cn, mergeRefs } from './chunk-GKHD33N6.js';
@@ -6,9 +6,10 @@ type CheckboxesProps = React.ComponentProps<typeof CheckboxGroup>;
6
6
  declare const Checkboxes: (props: CheckboxesProps) => react.JSX.Element;
7
7
  interface CheckboxesItemProps extends Omit<React.ComponentProps<typeof Checkbox.Root>, 'className'> {
8
8
  className?: string;
9
+ hint?: React.ReactNode;
9
10
  small?: boolean;
10
11
  }
11
- declare const CheckboxesItem: ({ className, children, small, ...props }: CheckboxesItemProps) => react.JSX.Element;
12
+ declare const CheckboxesItem: ({ className, children, hint, "aria-describedby": ariaDescribedBy, small, ...props }: CheckboxesItemProps) => react.JSX.Element;
12
13
  type CheckboxesHintProps = React.ComponentProps<'span'>;
13
14
  declare const CheckboxesHint: ({ className, ...props }: CheckboxesHintProps) => react.JSX.Element;
14
15
  interface CheckboxesDividerProps extends React.ComponentProps<'div'> {
@@ -1,2 +1,2 @@
1
- export { Checkboxes, CheckboxesConditional, CheckboxesDivider, CheckboxesHint, CheckboxesItem } from '../chunk-JCERRZV6.js';
1
+ export { Checkboxes, CheckboxesConditional, CheckboxesDivider, CheckboxesHint, CheckboxesItem } from '../chunk-JU7A7KQI.js';
2
2
  import '../chunk-GKHD33N6.js';
@@ -9,8 +9,9 @@ interface RadiosProps extends Omit<React.ComponentProps<typeof RadioGroup>, 'cla
9
9
  declare const Radios: ({ className, inline, ...props }: RadiosProps) => react.JSX.Element;
10
10
  interface RadiosItemProps extends Omit<React.ComponentProps<typeof Radio.Root>, 'className'> {
11
11
  className?: string;
12
+ hint?: React.ReactNode;
12
13
  }
13
- declare const RadiosItem: ({ className, children, ...props }: RadiosItemProps) => react.JSX.Element;
14
+ declare const RadiosItem: ({ className, children, hint, "aria-describedby": ariaDescribedBy, ...props }: RadiosItemProps) => react.JSX.Element;
14
15
  type RadiosHintProps = React.ComponentProps<'span'>;
15
16
  declare const RadiosHint: ({ className, ...props }: RadiosHintProps) => react.JSX.Element;
16
17
  type RadiosDividerProps = React.ComponentProps<'div'>;
package/dist/ui/radios.js CHANGED
@@ -1,2 +1,2 @@
1
- export { Radios, RadiosDivider, RadiosHint, RadiosItem } from '../chunk-4GQRYMDK.js';
1
+ export { Radios, RadiosDivider, RadiosHint, RadiosItem } from '../chunk-3NOO2YUQ.js';
2
2
  import '../chunk-GKHD33N6.js';
@@ -1,2 +1,2 @@
1
- export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus } from '../chunk-YF6EZ57H.js';
1
+ export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus } from '../chunk-YMQVN3MH.js';
2
2
  import '../chunk-GKHD33N6.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whitehall-ui",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "description": "GOV.UK Design System component library for React 19 + Tailwind CSS 4. Available as an npm package and a shadcn-compatible registry.",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  * `@import "tailwindcss"`:
10
10
  *
11
11
  * @import "tailwindcss";
12
- * @import "@/theme/govuk-tokens.css";
12
+ * @import "./styles/govuk-tokens.css"; (path relative to src/index.css)
13
13
  *
14
14
  * ------------------------------------------------------------------------- */
15
15
 
@@ -1,128 +0,0 @@
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 } 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 = ({ className, children, ...props }) => {
18
- const labelId = useId();
19
- return /* @__PURE__ */ jsxs(
20
- "label",
21
- {
22
- className: cn(
23
- "flex flex-wrap items-start",
24
- "relative",
25
- "mb-govuk-2 last:mb-0",
26
- "cursor-pointer",
27
- "has-data-[disabled]:opacity-50 has-data-[disabled]:cursor-not-allowed",
28
- className
29
- ),
30
- children: [
31
- /* @__PURE__ */ jsxs(
32
- Radio.Root,
33
- {
34
- "aria-labelledby": labelId,
35
- className: cn(
36
- "group/radio",
37
- "relative flex-none",
38
- "w-govuk-radio-touch-target h-govuk-radio-touch-target",
39
- "outline-none"
40
- ),
41
- ...props,
42
- children: [
43
- /* @__PURE__ */ jsx(
44
- "span",
45
- {
46
- "aria-hidden": "true",
47
- className: cn(
48
- "absolute box-border",
49
- "top-[calc(var(--spacing-govuk-radio-gutter)/2)] left-[calc(var(--spacing-govuk-radio-gutter)/2)]",
50
- "w-govuk-radio-size h-govuk-radio-size",
51
- "rounded-full",
52
- "border-2 border-current bg-transparent",
53
- "group-focus/radio:border-4",
54
- "group-focus/radio:shadow-[0_0_0_var(--spacing-govuk-radio-focus-width)_var(--color-govuk-yellow)]",
55
- "group-focus/radio:outline-govuk-radio-focus-width group-focus/radio:outline-transparent group-focus/radio:outline-offset-1"
56
- )
57
- }
58
- ),
59
- /* @__PURE__ */ jsx(
60
- Radio.Indicator,
61
- {
62
- keepMounted: true,
63
- className: cn(
64
- "absolute",
65
- "top-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-dot))]",
66
- "left-[calc(var(--spacing-govuk-radio-touch-target)/2-var(--spacing-govuk-radio-dot))]",
67
- "w-0 h-0",
68
- "rounded-full",
69
- "border-(length:--spacing-govuk-radio-dot) border-current",
70
- "bg-current",
71
- "opacity-0 data-checked:opacity-100"
72
- )
73
- }
74
- )
75
- ]
76
- }
77
- ),
78
- /* @__PURE__ */ jsx(
79
- "span",
80
- {
81
- id: labelId,
82
- className: cn(
83
- "self-center",
84
- "py-govuk-button-pb px-govuk-radio-label-padding-x",
85
- "text-govuk-tag font-normal font-govuk",
86
- "max-w-[calc(100%-74px)]"
87
- ),
88
- children
89
- }
90
- )
91
- ]
92
- }
93
- );
94
- };
95
- var RadiosHint = ({ className, ...props }) => /* @__PURE__ */ jsx(
96
- "span",
97
- {
98
- className: cn(
99
- "block w-full",
100
- "-mt-govuk-3 mb-govuk-2 last:mb-0",
101
- "pr-govuk-radio-label-padding-x",
102
- "pl-[calc(var(--spacing-govuk-radio-label-padding-x)+var(--spacing-govuk-radio-touch-target))]",
103
- "text-govuk-tag font-normal font-govuk text-govuk-dark-grey",
104
- className
105
- ),
106
- ...props
107
- }
108
- );
109
- var RadiosDivider = ({
110
- className,
111
- children = "or",
112
- ...props
113
- }) => /* @__PURE__ */ jsx(
114
- "div",
115
- {
116
- className: cn(
117
- "w-govuk-radio-size",
118
- "mb-govuk-2",
119
- "text-govuk-tag font-normal font-govuk text-govuk-black",
120
- "text-center",
121
- className
122
- ),
123
- ...props,
124
- children
125
- }
126
- );
127
-
128
- export { Radios, RadiosDivider, RadiosHint, RadiosItem };
@@ -1,136 +0,0 @@
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 } from 'react/jsx-runtime';
6
-
7
- var Checkboxes = (props) => /* @__PURE__ */ jsx(CheckboxGroup, { ...props });
8
- var CheckboxesItem = ({
9
- className,
10
- children,
11
- small,
12
- ...props
13
- }) => {
14
- const labelId = useId();
15
- return /* @__PURE__ */ jsxs(
16
- "label",
17
- {
18
- className: cn(
19
- "flex flex-wrap items-start",
20
- "relative",
21
- small ? "group/item mb-0" : "mb-govuk-2 last:mb-0",
22
- "cursor-pointer touch-manipulation",
23
- "has-data-[disabled]:opacity-50 has-data-[disabled]:cursor-not-allowed",
24
- className
25
- ),
26
- children: [
27
- /* @__PURE__ */ jsxs(
28
- Checkbox.Root,
29
- {
30
- "aria-labelledby": labelId,
31
- className: cn(
32
- "group/checkbox",
33
- "relative flex-none",
34
- "w-govuk-checkbox-touch-target h-govuk-checkbox-touch-target",
35
- "outline-none",
36
- small && "-ml-govuk-2"
37
- ),
38
- ...props,
39
- children: [
40
- /* @__PURE__ */ jsx(
41
- "span",
42
- {
43
- "aria-hidden": "true",
44
- className: cn(
45
- "absolute box-border",
46
- 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",
47
- "border-2 border-current bg-transparent",
48
- "govuk-checkbox-composed-shadow",
49
- "group-focus/checkbox:border-4",
50
- "group-focus/checkbox:govuk-checkbox-focus-shadow",
51
- "group-focus/checkbox:outline-3 group-focus/checkbox:outline-transparent group-focus/checkbox:outline-offset-1",
52
- small && "group-hover/item:govuk-checkbox-small-hover"
53
- )
54
- }
55
- ),
56
- /* @__PURE__ */ jsx(
57
- Checkbox.Indicator,
58
- {
59
- keepMounted: true,
60
- className: cn(
61
- "absolute box-border",
62
- 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",
63
- "opacity-0 data-checked:opacity-100"
64
- )
65
- }
66
- )
67
- ]
68
- }
69
- ),
70
- /* @__PURE__ */ jsx(
71
- "span",
72
- {
73
- id: labelId,
74
- className: cn(
75
- "self-center",
76
- "py-govuk-checkbox-label-padding-y px-govuk-checkbox-label-padding-x",
77
- "text-govuk-tag font-normal font-govuk",
78
- small ? "pl-px max-w-[calc(100%-50px)]" : "max-w-[calc(100%-74px)]"
79
- ),
80
- children
81
- }
82
- )
83
- ]
84
- }
85
- );
86
- };
87
- var CheckboxesHint = ({ className, ...props }) => /* @__PURE__ */ jsx(
88
- "span",
89
- {
90
- className: cn(
91
- "block w-full",
92
- "-mt-govuk-3 mb-govuk-2 last:mb-0",
93
- "pr-govuk-checkbox-label-padding-x",
94
- "pl-[calc(var(--spacing-govuk-checkbox-label-padding-x)+var(--spacing-govuk-checkbox-touch-target))]",
95
- "text-govuk-tag font-normal font-govuk text-govuk-dark-grey",
96
- className
97
- ),
98
- ...props
99
- }
100
- );
101
- var CheckboxesDivider = ({
102
- className,
103
- children = "or",
104
- small,
105
- ...props
106
- }) => /* @__PURE__ */ jsx(
107
- "div",
108
- {
109
- className: cn(
110
- small ? "w-govuk-checkbox-small-size mb-govuk-1" : "w-govuk-checkbox-size mb-govuk-2",
111
- "text-govuk-tag font-normal font-govuk text-govuk-black",
112
- "text-center",
113
- className
114
- ),
115
- ...props,
116
- children
117
- }
118
- );
119
- var CheckboxesConditional = ({
120
- className,
121
- ...props
122
- }) => /* @__PURE__ */ jsx(
123
- "div",
124
- {
125
- className: cn(
126
- "ml-govuk-checkbox-conditional-ml pl-govuk-checkbox-conditional-pl",
127
- "mb-govuk-3 sm:mb-govuk-4",
128
- "border-l-4 border-govuk-grey",
129
- "*:last:mb-0",
130
- className
131
- ),
132
- ...props
133
- }
134
- );
135
-
136
- export { Checkboxes, CheckboxesConditional, CheckboxesDivider, CheckboxesHint, CheckboxesItem };
@@ -1,77 +0,0 @@
1
- import { cn } from './chunk-GKHD33N6.js';
2
- import { jsx } from 'react/jsx-runtime';
3
-
4
- var TaskList = ({ className, ...props }) => /* @__PURE__ */ jsx(
5
- "ul",
6
- {
7
- className: cn(
8
- "font-govuk text-govuk-body text-govuk-black",
9
- "mt-0 mb-govuk-r6 p-0 list-none",
10
- className
11
- ),
12
- ...props
13
- }
14
- );
15
- var TaskListItem = ({ className, hasLink, ...props }) => /* @__PURE__ */ jsx(
16
- "li",
17
- {
18
- className: cn(
19
- "table relative w-full mb-0",
20
- "py-govuk-2",
21
- "border-b border-govuk-mid-grey",
22
- "first:border-t first:border-t-govuk-mid-grey",
23
- hasLink && "hover:bg-govuk-light-grey",
24
- className
25
- ),
26
- ...props
27
- }
28
- );
29
- var TaskListNameAndHint = ({
30
- className,
31
- ...props
32
- }) => /* @__PURE__ */ jsx(
33
- "div",
34
- {
35
- className: cn("table-cell align-top text-govuk-black", className),
36
- ...props
37
- }
38
- );
39
- var TaskListLink = ({ className, children, ...props }) => /* @__PURE__ */ jsx(
40
- "a",
41
- {
42
- className: cn(
43
- "text-govuk-link underline govuk-link-underline",
44
- "visited:text-govuk-visited active:text-govuk-black",
45
- "hover:text-govuk-brand-hover hover:govuk-link-underline-hover",
46
- "focus:govuk-link-focus",
47
- "after:block after:absolute after:inset-0",
48
- className
49
- ),
50
- ...props,
51
- children
52
- }
53
- );
54
- var TaskListHint = ({ className, ...props }) => /* @__PURE__ */ jsx(
55
- "div",
56
- {
57
- className: cn("mt-govuk-1 text-govuk-dark-grey", className),
58
- ...props
59
- }
60
- );
61
- var TaskListStatus = ({
62
- className,
63
- cannotStartYet,
64
- ...props
65
- }) => /* @__PURE__ */ jsx(
66
- "div",
67
- {
68
- className: cn(
69
- "table-cell pl-govuk-2 text-right align-top",
70
- cannotStartYet ? "text-govuk-dark-grey" : "text-govuk-black",
71
- className
72
- ),
73
- ...props
74
- }
75
- );
76
-
77
- export { TaskList, TaskListHint, TaskListItem, TaskListLink, TaskListNameAndHint, TaskListStatus };