govuk-react 0.10.7 → 1.0.0-alpha.1

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 (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -52
  3. package/dist/components/accordion/index.d.ts +68 -0
  4. package/dist/components/accordion/index.js +104 -0
  5. package/dist/components/accordion/index.js.map +1 -0
  6. package/dist/components/back-link/index.d.ts +1 -0
  7. package/dist/components/back-link/index.js +2 -0
  8. package/dist/components/back-link/index.js.map +1 -0
  9. package/dist/components/body/index.d.ts +1 -0
  10. package/dist/components/body/index.js +2 -0
  11. package/dist/components/body/index.js.map +1 -0
  12. package/dist/components/breadcrumbs/index.d.ts +1 -0
  13. package/dist/components/breadcrumbs/index.js +2 -0
  14. package/dist/components/breadcrumbs/index.js.map +1 -0
  15. package/dist/components/button/index.d.ts +24 -0
  16. package/dist/components/button/index.js +17 -0
  17. package/dist/components/button/index.js.map +1 -0
  18. package/dist/components/caption/index.d.ts +1 -0
  19. package/dist/components/caption/index.js +2 -0
  20. package/dist/components/caption/index.js.map +1 -0
  21. package/dist/components/character-count/index.d.ts +36 -0
  22. package/dist/components/character-count/index.js +82 -0
  23. package/dist/components/character-count/index.js.map +1 -0
  24. package/dist/components/checkboxes/index.d.ts +49 -0
  25. package/dist/components/checkboxes/index.js +73 -0
  26. package/dist/components/checkboxes/index.js.map +1 -0
  27. package/dist/components/cookie-banner/index.d.ts +1 -0
  28. package/dist/components/cookie-banner/index.js +2 -0
  29. package/dist/components/cookie-banner/index.js.map +1 -0
  30. package/dist/components/date-input/index.d.ts +1 -0
  31. package/dist/components/date-input/index.js +2 -0
  32. package/dist/components/date-input/index.js.map +1 -0
  33. package/dist/components/details/index.d.ts +1 -0
  34. package/dist/components/details/index.js +2 -0
  35. package/dist/components/details/index.js.map +1 -0
  36. package/dist/components/document-footer-metadata/index.d.ts +35 -0
  37. package/dist/components/document-footer-metadata/index.js +36 -0
  38. package/dist/components/document-footer-metadata/index.js.map +1 -0
  39. package/dist/components/error-message/index.d.ts +1 -0
  40. package/dist/components/error-message/index.js +2 -0
  41. package/dist/components/error-message/index.js.map +1 -0
  42. package/dist/components/error-summary/index.d.ts +22 -0
  43. package/dist/components/error-summary/index.js +49 -0
  44. package/dist/components/error-summary/index.js.map +1 -0
  45. package/dist/components/exit-this-page/index.d.ts +33 -0
  46. package/dist/components/exit-this-page/index.js +66 -0
  47. package/dist/components/exit-this-page/index.js.map +1 -0
  48. package/dist/components/feedback/index.d.ts +1 -0
  49. package/dist/components/feedback/index.js +2 -0
  50. package/dist/components/feedback/index.js.map +1 -0
  51. package/dist/components/fieldset/index.d.ts +1 -0
  52. package/dist/components/fieldset/index.js +2 -0
  53. package/dist/components/fieldset/index.js.map +1 -0
  54. package/dist/components/file-upload/control.d.ts +6 -0
  55. package/dist/components/file-upload/control.js +9 -0
  56. package/dist/components/file-upload/control.js.map +1 -0
  57. package/dist/components/file-upload/enhanced.d.ts +45 -0
  58. package/dist/components/file-upload/enhanced.js +84 -0
  59. package/dist/components/file-upload/enhanced.js.map +1 -0
  60. package/dist/components/file-upload/index.d.ts +12 -0
  61. package/dist/components/file-upload/index.js +18 -0
  62. package/dist/components/file-upload/index.js.map +1 -0
  63. package/dist/components/footer/index.d.ts +1 -0
  64. package/dist/components/footer/index.js +2 -0
  65. package/dist/components/footer/index.js.map +1 -0
  66. package/dist/components/form-group/index.d.ts +1 -0
  67. package/dist/components/form-group/index.js +2 -0
  68. package/dist/components/form-group/index.js.map +1 -0
  69. package/dist/components/generic-header/index.d.ts +1 -0
  70. package/dist/components/generic-header/index.js +2 -0
  71. package/dist/components/generic-header/index.js.map +1 -0
  72. package/dist/components/grid-column/index.d.ts +1 -0
  73. package/dist/components/grid-column/index.js +2 -0
  74. package/dist/components/grid-column/index.js.map +1 -0
  75. package/dist/components/grid-row/index.d.ts +1 -0
  76. package/dist/components/grid-row/index.js +2 -0
  77. package/dist/components/grid-row/index.js.map +1 -0
  78. package/dist/components/header/index.d.ts +1 -0
  79. package/dist/components/header/index.js +2 -0
  80. package/dist/components/header/index.js.map +1 -0
  81. package/dist/components/heading/index.d.ts +1 -0
  82. package/dist/components/heading/index.js +2 -0
  83. package/dist/components/heading/index.js.map +1 -0
  84. package/dist/components/hint/index.d.ts +1 -0
  85. package/dist/components/hint/index.js +2 -0
  86. package/dist/components/hint/index.js.map +1 -0
  87. package/dist/components/input/index.d.ts +1 -0
  88. package/dist/components/input/index.js +2 -0
  89. package/dist/components/input/index.js.map +1 -0
  90. package/dist/components/inset-text/index.d.ts +1 -0
  91. package/dist/components/inset-text/index.js +2 -0
  92. package/dist/components/inset-text/index.js.map +1 -0
  93. package/dist/components/label/index.d.ts +1 -0
  94. package/dist/components/label/index.js +2 -0
  95. package/dist/components/label/index.js.map +1 -0
  96. package/dist/components/language-navigation/index.d.ts +1 -0
  97. package/dist/components/language-navigation/index.js +2 -0
  98. package/dist/components/language-navigation/index.js.map +1 -0
  99. package/dist/components/link/index.d.ts +1 -0
  100. package/dist/components/link/index.js +2 -0
  101. package/dist/components/link/index.js.map +1 -0
  102. package/dist/components/list/index.d.ts +1 -0
  103. package/dist/components/list/index.js +2 -0
  104. package/dist/components/list/index.js.map +1 -0
  105. package/dist/components/loading-box/index.d.ts +35 -0
  106. package/dist/components/loading-box/index.js +45 -0
  107. package/dist/components/loading-box/index.js.map +1 -0
  108. package/dist/components/main-wrapper/index.d.ts +1 -0
  109. package/dist/components/main-wrapper/index.js +2 -0
  110. package/dist/components/main-wrapper/index.js.map +1 -0
  111. package/dist/components/modal/index.d.ts +33 -0
  112. package/dist/components/modal/index.js +55 -0
  113. package/dist/components/modal/index.js.map +1 -0
  114. package/dist/components/notification-banner/index.d.ts +17 -0
  115. package/dist/components/notification-banner/index.js +44 -0
  116. package/dist/components/notification-banner/index.js.map +1 -0
  117. package/dist/components/page/index.d.ts +23 -0
  118. package/dist/components/page/index.js +22 -0
  119. package/dist/components/page/index.js.map +1 -0
  120. package/dist/components/pagination/index.d.ts +1 -0
  121. package/dist/components/pagination/index.js +2 -0
  122. package/dist/components/pagination/index.js.map +1 -0
  123. package/dist/components/panel/index.d.ts +1 -0
  124. package/dist/components/panel/index.js +2 -0
  125. package/dist/components/panel/index.js.map +1 -0
  126. package/dist/components/password-input/index.d.ts +26 -0
  127. package/dist/components/password-input/index.js +60 -0
  128. package/dist/components/password-input/index.js.map +1 -0
  129. package/dist/components/phase-banner/index.d.ts +1 -0
  130. package/dist/components/phase-banner/index.js +2 -0
  131. package/dist/components/phase-banner/index.js.map +1 -0
  132. package/dist/components/radios/index.d.ts +33 -0
  133. package/dist/components/radios/index.js +70 -0
  134. package/dist/components/radios/index.js.map +1 -0
  135. package/dist/components/related-items/index.d.ts +33 -0
  136. package/dist/components/related-items/index.js +45 -0
  137. package/dist/components/related-items/index.js.map +1 -0
  138. package/dist/components/search-box/index.d.ts +89 -0
  139. package/dist/components/search-box/index.js +136 -0
  140. package/dist/components/search-box/index.js.map +1 -0
  141. package/dist/components/section-break/index.d.ts +1 -0
  142. package/dist/components/section-break/index.js +2 -0
  143. package/dist/components/section-break/index.js.map +1 -0
  144. package/dist/components/select/index.d.ts +1 -0
  145. package/dist/components/select/index.js +2 -0
  146. package/dist/components/select/index.js.map +1 -0
  147. package/dist/components/service-navigation/index.d.ts +64 -0
  148. package/dist/components/service-navigation/index.js +131 -0
  149. package/dist/components/service-navigation/index.js.map +1 -0
  150. package/dist/components/skip-link/index.d.ts +12 -0
  151. package/dist/components/skip-link/index.js +16 -0
  152. package/dist/components/skip-link/index.js.map +1 -0
  153. package/dist/components/summary-list/index.d.ts +1 -0
  154. package/dist/components/summary-list/index.js +2 -0
  155. package/dist/components/summary-list/index.js.map +1 -0
  156. package/dist/components/table/index.d.ts +1 -0
  157. package/dist/components/table/index.js +2 -0
  158. package/dist/components/table/index.js.map +1 -0
  159. package/dist/components/tabs/index.d.ts +98 -0
  160. package/dist/components/tabs/index.js +105 -0
  161. package/dist/components/tabs/index.js.map +1 -0
  162. package/dist/components/tag/index.d.ts +1 -0
  163. package/dist/components/tag/index.js +2 -0
  164. package/dist/components/tag/index.js.map +1 -0
  165. package/dist/components/task-list/index.d.ts +1 -0
  166. package/dist/components/task-list/index.js +2 -0
  167. package/dist/components/task-list/index.js.map +1 -0
  168. package/dist/components/textarea/index.d.ts +1 -0
  169. package/dist/components/textarea/index.js +2 -0
  170. package/dist/components/textarea/index.js.map +1 -0
  171. package/dist/components/visually-hidden/index.d.ts +1 -0
  172. package/dist/components/visually-hidden/index.js +2 -0
  173. package/dist/components/visually-hidden/index.js.map +1 -0
  174. package/dist/components/warning-text/index.d.ts +1 -0
  175. package/dist/components/warning-text/index.js +2 -0
  176. package/dist/components/warning-text/index.js.map +1 -0
  177. package/dist/components/width-container/index.d.ts +1 -0
  178. package/dist/components/width-container/index.js +2 -0
  179. package/dist/components/width-container/index.js.map +1 -0
  180. package/dist/index.d.ts +58 -0
  181. package/dist/index.js +61 -0
  182. package/dist/index.js.map +1 -0
  183. package/dist/utils/join-ids.d.ts +2 -0
  184. package/dist/utils/join-ids.js +6 -0
  185. package/dist/utils/join-ids.js.map +1 -0
  186. package/package.json +38 -66
  187. package/dist/declarations/src/index.d.ts +0 -52
  188. package/dist/govuk-react.cjs.d.ts +0 -2
  189. package/dist/govuk-react.cjs.dev.js +0 -351
  190. package/dist/govuk-react.cjs.js +0 -7
  191. package/dist/govuk-react.cjs.prod.js +0 -351
  192. package/dist/govuk-react.esm.js +0 -51
  193. package/src/index.ts +0 -56
  194. package/src/test.tsx +0 -56
@@ -0,0 +1,55 @@
1
+ import * as React from 'react';
2
+ import { clsx } from 'clsx';
3
+ import * as Primitives from '@govuk-react/primitives/modal';
4
+ import { Button } from 'govuk-frontend-react/button';
5
+ /*
6
+ * A modal dialog on GOV.UK styles, with the behaviour from @govuk-react/primitives. govuk-frontend
7
+ * has no modal, so its look follows the dialogs that GOV.UK services already use, such as the
8
+ * HMRC timeout warning. Where the browser supports invoker commands, it is a true modal without
9
+ * JavaScript.
10
+ */
11
+ const name = 'govuk-react-modal';
12
+ /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
13
+ export const modalCss = `
14
+ .${name}{box-sizing:border-box;width:calc(100% - 30px);max-width:640px;max-height:calc(100% - 30px);padding:30px;border:5px solid var(--govuk-text-colour,#0b0c0c);background:var(--govuk-body-background-colour,#fff);color:var(--govuk-text-colour,#0b0c0c)}
15
+ .${name}:focus{outline:3px solid var(--govuk-focus-colour,#fd0);outline-offset:0}
16
+ .${name}::backdrop{background:rgb(11 12 12 / .8)}
17
+ .${name}>:last-child{margin-bottom:0}
18
+ @media (max-width:40.0525em){.${name}{padding:15px}}
19
+ `;
20
+ /** Holds the modal and the buttons that open and close it. */
21
+ export function Root({ children, ...props }) {
22
+ return (React.createElement(Primitives.Root, { ...props },
23
+ React.createElement("style", { href: name, precedence: "default" }, modalCss),
24
+ children));
25
+ }
26
+ /** A button that opens the modal. */
27
+ export function Trigger({ dialogId, ...props }) {
28
+ return (React.createElement(Primitives.Trigger, { dialogId: dialogId, asChild: true },
29
+ React.createElement(Button, { type: "button", ...props })));
30
+ }
31
+ /** A button that closes the modal. A secondary button, unless you pass another `variant`, or `undefined` for a primary one. */
32
+ export function Close({ dialogId, ...props }) {
33
+ return (React.createElement(Primitives.Close, { dialogId: dialogId, asChild: true },
34
+ React.createElement(Button, { type: "button", variant: "secondary", ...props })));
35
+ }
36
+ /** The modal dialog. Give it a Title. */
37
+ export function Content({ className, ...props }) {
38
+ return React.createElement(Primitives.Content, { className: clsx(name, className), ...props });
39
+ }
40
+ /** The modal's heading, which names it. */
41
+ export function Title({ className, ...props }) {
42
+ return React.createElement(Primitives.Title, { className: clsx('govuk-heading-m', className), ...props });
43
+ }
44
+ /** A button that opens a modal with a title, content and actions. */
45
+ export function Composite({ triggerText, title, closeText = 'Cancel', actions, children, ...props }) {
46
+ return (React.createElement(Root, { ...props },
47
+ React.createElement(Trigger, null, triggerText),
48
+ React.createElement(Content, null,
49
+ React.createElement(Title, null, title),
50
+ children,
51
+ React.createElement("div", { className: "govuk-button-group" },
52
+ actions,
53
+ React.createElement(Close, null, closeText)))));
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAoB,MAAM,6BAA6B,CAAC;AAEvE;;;;;GAKG;AAEH,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC,iFAAiF;AACjF,MAAM,CAAC,MAAM,QAAQ,GAAG;GACrB,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;gCACyB,IAAI;CACnC,CAAC;AAIF,8DAA8D;AAC9D,MAAM,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAa;IACpD,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,OAAK,KAAK;QACxB,+BAAO,IAAI,EAAE,IAAI,EAAE,UAAU,EAAC,SAAS,IACpC,QAAQ,CACH;QACP,QAAQ,CACO,CACnB,CAAC;AACJ,CAAC;AAID,qCAAqC;AACrC,MAAM,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAgB;IAC1D,OAAO,CACL,oBAAC,UAAU,CAAC,OAAO,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO;QAC7C,oBAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,KAAK,KAAK,GAAI,CAChB,CACtB,CAAC;AACJ,CAAC;AAID,+HAA+H;AAC/H,MAAM,UAAU,KAAK,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IACtD,OAAO,CACL,oBAAC,UAAU,CAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO;QAC3C,oBAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,WAAW,KAAK,KAAK,GAAI,CACtC,CACpB,CAAC;AACJ,CAAC;AAID,yCAAyC;AACzC,MAAM,UAAU,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAgB;IAC3D,OAAO,oBAAC,UAAU,CAAC,OAAO,IAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC;AAC7E,CAAC;AAID,2CAA2C;AAC3C,MAAM,UAAU,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAc;IACvD,OAAO,oBAAC,UAAU,CAAC,KAAK,IAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC;AACxF,CAAC;AAaD,qEAAqE;AACrE,MAAM,UAAU,SAAS,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IACjH,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,OAAO,QAAE,WAAW,CAAW;QAChC,oBAAC,OAAO;YACN,oBAAC,KAAK,QAAE,KAAK,CAAS;YACrB,QAAQ;YACT,6BAAK,SAAS,EAAC,oBAAoB;gBAChC,OAAO;gBACR,oBAAC,KAAK,QAAE,SAAS,CAAS,CACtB,CACE,CACL,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/modal';\nimport { Button, type ButtonProps } from 'govuk-frontend-react/button';\n\n/*\n * A modal dialog on GOV.UK styles, with the behaviour from @govuk-react/primitives. govuk-frontend\n * has no modal, so its look follows the dialogs that GOV.UK services already use, such as the\n * HMRC timeout warning. Where the browser supports invoker commands, it is a true modal without\n * JavaScript.\n */\n\nconst name = 'govuk-react-modal';\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */\nexport const modalCss = `\n.${name}{box-sizing:border-box;width:calc(100% - 30px);max-width:640px;max-height:calc(100% - 30px);padding:30px;border:5px solid var(--govuk-text-colour,#0b0c0c);background:var(--govuk-body-background-colour,#fff);color:var(--govuk-text-colour,#0b0c0c)}\n.${name}:focus{outline:3px solid var(--govuk-focus-colour,#fd0);outline-offset:0}\n.${name}::backdrop{background:rgb(11 12 12 / .8)}\n.${name}>:last-child{margin-bottom:0}\n@media (max-width:40.0525em){.${name}{padding:15px}}\n`;\n\nexport type RootProps = Primitives.RootProps;\n\n/** Holds the modal and the buttons that open and close it. */\nexport function Root({ children, ...props }: RootProps) {\n return (\n <Primitives.Root {...props}>\n <style href={name} precedence=\"default\">\n {modalCss}\n </style>\n {children}\n </Primitives.Root>\n );\n}\n\nexport type TriggerProps = Omit<ButtonProps, 'as' | 'href' | 'type'> & Pick<Primitives.TriggerProps, 'dialogId'>;\n\n/** A button that opens the modal. */\nexport function Trigger({ dialogId, ...props }: TriggerProps) {\n return (\n <Primitives.Trigger dialogId={dialogId} asChild>\n <Button type=\"button\" {...props} />\n </Primitives.Trigger>\n );\n}\n\nexport type CloseProps = TriggerProps;\n\n/** A button that closes the modal. A secondary button, unless you pass another `variant`, or `undefined` for a primary one. */\nexport function Close({ dialogId, ...props }: CloseProps) {\n return (\n <Primitives.Close dialogId={dialogId} asChild>\n <Button type=\"button\" variant=\"secondary\" {...props} />\n </Primitives.Close>\n );\n}\n\nexport type ContentProps = Omit<Primitives.ContentProps, 'asChild'>;\n\n/** The modal dialog. Give it a Title. */\nexport function Content({ className, ...props }: ContentProps) {\n return <Primitives.Content className={clsx(name, className)} {...props} />;\n}\n\nexport type TitleProps = Omit<Primitives.TitleProps, 'asChild'>;\n\n/** The modal's heading, which names it. */\nexport function Title({ className, ...props }: TitleProps) {\n return <Primitives.Title className={clsx('govuk-heading-m', className)} {...props} />;\n}\n\nexport type CompositeProps = Omit<RootProps, 'title'> & {\n /** The text of the button that opens the modal. */\n triggerText: ReactNode;\n /** The modal's heading. */\n title: ReactNode;\n /** The text of the button that closes the modal. Defaults to \"Cancel\". */\n closeText?: ReactNode;\n /** Other actions, such as a button that confirms, shown before the close button. */\n actions?: ReactNode;\n};\n\n/** A button that opens a modal with a title, content and actions. */\nexport function Composite({ triggerText, title, closeText = 'Cancel', actions, children, ...props }: CompositeProps) {\n return (\n <Root {...props}>\n <Trigger>{triggerText}</Trigger>\n <Content>\n <Title>{title}</Title>\n {children}\n <div className=\"govuk-button-group\">\n {actions}\n <Close>{closeText}</Close>\n </div>\n </Content>\n </Root>\n );\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import * as Markup from 'govuk-frontend-react/notification-banner';
3
+ export { Header, Title, Content, Heading, Link, type HeaderProps, type TitleProps, type ContentProps, type HeadingProps, type LinkProps, } from 'govuk-frontend-react/notification-banner';
4
+ export type RootProps = Markup.RootProps;
5
+ /**
6
+ * Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.
7
+ *
8
+ * @see https://design-system.service.gov.uk/components/notification-banner/
9
+ */
10
+ export declare function Root({ disableAutoFocus, ...props }: RootProps): React.JSX.Element;
11
+ export type CompositeProps = Markup.CompositeProps;
12
+ /**
13
+ * Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.
14
+ *
15
+ * @see https://design-system.service.gov.uk/components/notification-banner/
16
+ */
17
+ export declare function Composite({ title, titleId, titleHeadingLevel, heading, success, children, ...props }: CompositeProps): React.JSX.Element;
@@ -0,0 +1,44 @@
1
+ import * as React from 'react';
2
+ import * as AutoFocus from '@govuk-react/primitives/auto-focus';
3
+ import * as Markup from 'govuk-frontend-react/notification-banner';
4
+ /*
5
+ * govuk-frontend-react's NotificationBanner markup, with govuk-frontend's focus behaviour from
6
+ * @govuk-react/primitives. A success banner, or one with `role="alert"`, takes focus when it
7
+ * appears, and is rendered with `autofocus`, so it takes focus when the page loads even without
8
+ * JavaScript.
9
+ */
10
+ export { Header, Title, Content, Heading, Link, } from 'govuk-frontend-react/notification-banner';
11
+ /**
12
+ * Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.
13
+ *
14
+ * @see https://design-system.service.gov.uk/components/notification-banner/
15
+ */
16
+ export function Root({ disableAutoFocus, ...props }) {
17
+ var _a;
18
+ // As govuk-frontend: only an alert takes focus.
19
+ const disabled = Boolean(disableAutoFocus) || ((_a = props.role) !== null && _a !== void 0 ? _a : (props.success ? 'alert' : 'region')) !== 'alert';
20
+ return (React.createElement(AutoFocus.Root, { disabled: disabled },
21
+ React.createElement(AutoFocus.Target, { asChild: true, disabled: disabled },
22
+ React.createElement(Markup.Root, { disableAutoFocus: disableAutoFocus, ...props }))));
23
+ }
24
+ const hasContent = (node) => {
25
+ if (node === null || node === undefined || node === false || node === true || node === '')
26
+ return false;
27
+ if (Array.isArray(node))
28
+ return node.some(hasContent);
29
+ return true;
30
+ };
31
+ /**
32
+ * Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.
33
+ *
34
+ * @see https://design-system.service.gov.uk/components/notification-banner/
35
+ */
36
+ export function Composite({ title, titleId, titleHeadingLevel, heading, success, children, ...props }) {
37
+ return (React.createElement(Root, { success: success, ...(titleId && { 'aria-labelledby': titleId }), ...props },
38
+ React.createElement(Markup.Header, null,
39
+ React.createElement(Markup.Title, { headingLevel: titleHeadingLevel, ...(titleId && { id: titleId }) }, hasContent(title) ? title : success ? 'Success' : undefined)),
40
+ React.createElement(Markup.Content, null,
41
+ hasContent(heading) && React.createElement(Markup.Heading, null, heading),
42
+ children)));
43
+ }
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/notification-banner/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,SAAS,MAAM,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AC,IAAI,IAAC,OAAO,EAAE,OAAO,KAAM,CAAC,OAAO,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,KAAM,KAAK;QAChF,oBAAC,MAAM,CAAC,MAAM;YACZ,oBAAC,MAAM,CAAC,KAAK,IAAC,YAAY,EAAE,iBAAiB,KAAM,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,IAC5E,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAC/C,CACD;QAChB,oBAAC,MAAM,CAAC,OAAO;YACZ,UAAU,CAAC,OAAO,CAAC,IAAI,oBAAC,MAAM,CAAC,OAAO,QAAE,OAAO,CAAkB;YACjE,QAAQ,CACM,CACZ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport * as AutoFocus from '@govuk-react/primitives/auto-focus';\nimport * as Markup from 'govuk-frontend-react/notification-banner';\n\n/*\n * govuk-frontend-react's NotificationBanner markup, with govuk-frontend's focus behaviour from\n * @govuk-react/primitives. A success banner, or one with `role=\"alert\"`, takes focus when it\n * appears, and is rendered with `autofocus`, so it takes focus when the page loads even without\n * JavaScript.\n */\n\nexport {\n Header,\n Title,\n Content,\n Heading,\n Link,\n type HeaderProps,\n type TitleProps,\n type ContentProps,\n type HeadingProps,\n type LinkProps,\n} from 'govuk-frontend-react/notification-banner';\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.\n *\n * @see https://design-system.service.gov.uk/components/notification-banner/\n */\nexport function Root({ disableAutoFocus, ...props }: RootProps) {\n // As govuk-frontend: only an alert takes focus.\n const disabled = Boolean(disableAutoFocus) || (props.role ?? (props.success ? 'alert' : 'region')) !== 'alert';\n return (\n <AutoFocus.Root disabled={disabled}>\n <AutoFocus.Target asChild disabled={disabled}>\n <Markup.Root disableAutoFocus={disableAutoFocus} {...props} />\n </AutoFocus.Target>\n </AutoFocus.Root>\n );\n}\n\nexport type CompositeProps = Markup.CompositeProps;\n\nconst hasContent = (node: React.ReactNode): boolean => {\n if (node === null || node === undefined || node === false || node === true || node === '') return false;\n if (Array.isArray(node)) return node.some(hasContent);\n return true;\n};\n\n/**\n * Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.\n *\n * @see https://design-system.service.gov.uk/components/notification-banner/\n */\nexport function Composite({ title, titleId, titleHeadingLevel, heading, success, children, ...props }: CompositeProps) {\n return (\n <Root success={success} {...(titleId && { 'aria-labelledby': titleId })} {...props}>\n <Markup.Header>\n <Markup.Title headingLevel={titleHeadingLevel} {...(titleId && { id: titleId })}>\n {hasContent(title) ? title : success ? 'Success' : undefined}\n </Markup.Title>\n </Markup.Header>\n <Markup.Content>\n {hasContent(heading) && <Markup.Heading>{heading}</Markup.Heading>}\n {children}\n </Markup.Content>\n </Root>\n );\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ export type PageProps = {
3
+ /** Page contents, rendered inside the main wrapper. */
4
+ children?: React.ReactNode;
5
+ /** Id of the main wrapper, which the skip link points to. */
6
+ id?: string;
7
+ /** Page header, such as `Header.Composite` or `ServiceNavigation`. */
8
+ header?: React.ReactNode;
9
+ /** Page footer, such as `Footer.Composite`. */
10
+ footer?: React.ReactNode;
11
+ /** Content outside the main wrapper but inside the width container, such as a back link, breadcrumbs or phase banner. */
12
+ beforeChildren?: React.ReactNode;
13
+ /** Text for the skip link. */
14
+ skipLinkText?: React.ReactNode;
15
+ };
16
+ /**
17
+ * Lays out the body of a GOV.UK page: skip link, header and footer landmarks, width container and main wrapper.
18
+ * For custom layouts, compose `SkipLink`, `WidthContainer` and `MainWrapper` directly.
19
+ *
20
+ * - https://design-system.service.gov.uk/styles/page-template/
21
+ * - https://design-system.service.gov.uk/styles/layout/#page-wrappers
22
+ */
23
+ export declare function Page({ header, footer, children, id, beforeChildren, skipLinkText, }: PageProps): React.JSX.Element;
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import { SkipLink } from '../skip-link/index.js';
3
+ import { WidthContainer } from '../width-container/index.js';
4
+ import { MainWrapper } from '../main-wrapper/index.js';
5
+ import { Header as TemplateHeader, Footer as TemplateFooter } from 'govuk-frontend-react/template';
6
+ /**
7
+ * Lays out the body of a GOV.UK page: skip link, header and footer landmarks, width container and main wrapper.
8
+ * For custom layouts, compose `SkipLink`, `WidthContainer` and `MainWrapper` directly.
9
+ *
10
+ * - https://design-system.service.gov.uk/styles/page-template/
11
+ * - https://design-system.service.gov.uk/styles/layout/#page-wrappers
12
+ */
13
+ export function Page({ header, footer, children, id = 'main-content', beforeChildren, skipLinkText = 'Skip to main content', }) {
14
+ return (React.createElement(React.Fragment, null,
15
+ React.createElement(SkipLink, { href: `#${id}` }, skipLinkText),
16
+ header && React.createElement(TemplateHeader, null, header),
17
+ React.createElement(WidthContainer, null,
18
+ beforeChildren,
19
+ React.createElement(MainWrapper, { id: id }, children)),
20
+ footer && React.createElement(TemplateFooter, null, footer)));
21
+ }
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/page/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAiBnG;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,EAAE,GAAG,cAAc,EACnB,cAAc,EACd,YAAY,GAAG,sBAAsB,GAC3B;IACV,OAAO,CACL;QACE,oBAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,EAAE,EAAE,IAAG,YAAY,CAAY;QAClD,MAAM,IAAI,oBAAC,cAAc,QAAE,MAAM,CAAkB;QACpD,oBAAC,cAAc;YACZ,cAAc;YACf,oBAAC,WAAW,IAAC,EAAE,EAAE,EAAE,IAAG,QAAQ,CAAe,CAC9B;QAChB,MAAM,IAAI,oBAAC,cAAc,QAAE,MAAM,CAAkB,CACnD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { SkipLink } from '../skip-link/index.js';\nimport { WidthContainer } from '../width-container/index.js';\nimport { MainWrapper } from '../main-wrapper/index.js';\nimport { Header as TemplateHeader, Footer as TemplateFooter } from 'govuk-frontend-react/template';\n\nexport type PageProps = {\n /** Page contents, rendered inside the main wrapper. */\n children?: React.ReactNode;\n /** Id of the main wrapper, which the skip link points to. */\n id?: string;\n /** Page header, such as `Header.Composite` or `ServiceNavigation`. */\n header?: React.ReactNode;\n /** Page footer, such as `Footer.Composite`. */\n footer?: React.ReactNode;\n /** Content outside the main wrapper but inside the width container, such as a back link, breadcrumbs or phase banner. */\n beforeChildren?: React.ReactNode;\n /** Text for the skip link. */\n skipLinkText?: React.ReactNode;\n};\n\n/**\n * Lays out the body of a GOV.UK page: skip link, header and footer landmarks, width container and main wrapper.\n * For custom layouts, compose `SkipLink`, `WidthContainer` and `MainWrapper` directly.\n *\n * - https://design-system.service.gov.uk/styles/page-template/\n * - https://design-system.service.gov.uk/styles/layout/#page-wrappers\n */\nexport function Page({\n header,\n footer,\n children,\n id = 'main-content',\n beforeChildren,\n skipLinkText = 'Skip to main content',\n}: PageProps) {\n return (\n <>\n <SkipLink href={`#${id}`}>{skipLinkText}</SkipLink>\n {header && <TemplateHeader>{header}</TemplateHeader>}\n <WidthContainer>\n {beforeChildren}\n <MainWrapper id={id}>{children}</MainWrapper>\n </WidthContainer>\n {footer && <TemplateFooter>{footer}</TemplateFooter>}\n </>\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from 'govuk-frontend-react/pagination';
@@ -0,0 +1,2 @@
1
+ export * from 'govuk-frontend-react/pagination';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/pagination/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/pagination';\n"]}
@@ -0,0 +1 @@
1
+ export * from 'govuk-frontend-react/panel';
@@ -0,0 +1,2 @@
1
+ export * from 'govuk-frontend-react/panel';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/panel/index.tsx"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from 'govuk-frontend-react/panel';\n"]}
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import * as Primitives from '@govuk-react/primitives/password-input';
3
+ import * as Markup from 'govuk-frontend-react/password-input';
4
+ export type RootProps = Markup.RootProps;
5
+ /**
6
+ * Help users accessibly enter passwords.
7
+ *
8
+ * @see https://design-system.service.gov.uk/components/password-input/
9
+ */
10
+ export declare function Root({ showPasswordText, hidePasswordText, showPasswordAriaLabelText, hidePasswordAriaLabelText, passwordShownAnnouncementText, passwordHiddenAnnouncementText, ...props }: RootProps): React.JSX.Element;
11
+ export { Wrapper, type WrapperProps } from 'govuk-frontend-react/password-input';
12
+ export type InputProps = Markup.InputProps;
13
+ export declare function Input(props: InputProps): React.JSX.Element;
14
+ export type ToggleProps = Markup.ToggleProps;
15
+ /** The show and hide button. Hidden until JavaScript runs. */
16
+ export declare function Toggle(props: ToggleProps): React.JSX.Element;
17
+ export type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;
18
+ /** A visually hidden live region that announces when the password is shown or hidden. */
19
+ export declare function Status({ className, ...props }: StatusProps): React.JSX.Element;
20
+ export type FieldProps = Markup.FieldProps;
21
+ /**
22
+ * Help users accessibly enter passwords.
23
+ *
24
+ * @see https://design-system.service.gov.uk/components/password-input/
25
+ */
26
+ export declare function Field({ id: idProp, name, label, labelSize, labelIsPageHeading, hint, errorMessage, showPasswordText, hidePasswordText, showPasswordAriaLabelText, hidePasswordAriaLabelText, passwordShownAnnouncementText, passwordHiddenAnnouncementText, 'aria-describedby': describedBy, ...props }: FieldProps): React.JSX.Element;
@@ -0,0 +1,60 @@
1
+ import * as React from 'react';
2
+ import { clsx } from 'clsx';
3
+ import * as Primitives from '@govuk-react/primitives/password-input';
4
+ import * as Markup from 'govuk-frontend-react/password-input';
5
+ import { ErrorMessageComposite } from 'govuk-frontend-react/error-message';
6
+ import { Hint } from 'govuk-frontend-react/hint';
7
+ import { LabelComposite } from 'govuk-frontend-react/label';
8
+ import { joinIds } from '../../utils/join-ids.js';
9
+ /**
10
+ * Help users accessibly enter passwords.
11
+ *
12
+ * @see https://design-system.service.gov.uk/components/password-input/
13
+ */
14
+ export function Root({ showPasswordText, hidePasswordText, showPasswordAriaLabelText, hidePasswordAriaLabelText, passwordShownAnnouncementText, passwordHiddenAnnouncementText, ...props }) {
15
+ const text = {
16
+ showPasswordText,
17
+ hidePasswordText,
18
+ showPasswordAriaLabelText,
19
+ hidePasswordAriaLabelText,
20
+ passwordShownAnnouncementText,
21
+ passwordHiddenAnnouncementText,
22
+ };
23
+ return (React.createElement(Primitives.Root, { showText: showPasswordText, hideText: hidePasswordText, showLabel: showPasswordAriaLabelText, hideLabel: hidePasswordAriaLabelText, shownAnnouncement: passwordShownAnnouncementText, hiddenAnnouncement: passwordHiddenAnnouncementText },
24
+ React.createElement(Markup.Root, { ...text, ...props })));
25
+ }
26
+ export { Wrapper } from 'govuk-frontend-react/password-input';
27
+ export function Input(props) {
28
+ return (React.createElement(Primitives.Input, { asChild: true },
29
+ React.createElement(Markup.Input, { ...props })));
30
+ }
31
+ /** The show and hide button. Hidden until JavaScript runs. */
32
+ export function Toggle(props) {
33
+ return (React.createElement(Primitives.Toggle, { asChild: true },
34
+ React.createElement(Markup.Toggle, { ...props })));
35
+ }
36
+ /** A visually hidden live region that announces when the password is shown or hidden. */
37
+ export function Status({ className, ...props }) {
38
+ return (React.createElement(Primitives.Status, { className: clsx('govuk-password-input__sr-status', 'govuk-visually-hidden', className), ...props }));
39
+ }
40
+ const isSet = (node) => node !== undefined && node !== null && node !== false && node !== '';
41
+ /**
42
+ * Help users accessibly enter passwords.
43
+ *
44
+ * @see https://design-system.service.gov.uk/components/password-input/
45
+ */
46
+ export function Field({ id: idProp, name, label, labelSize, labelIsPageHeading, hint, errorMessage, showPasswordText, hidePasswordText, showPasswordAriaLabelText, hidePasswordAriaLabelText, passwordShownAnnouncementText, passwordHiddenAnnouncementText, 'aria-describedby': describedBy, ...props }) {
47
+ const id = idProp || name;
48
+ const hintId = isSet(hint) ? `${id}-hint` : undefined;
49
+ const errorId = isSet(errorMessage) ? `${id}-error` : undefined;
50
+ const ariaDescribedBy = joinIds(describedBy, hintId, errorId);
51
+ return (React.createElement(Root, { error: Boolean(errorId), showPasswordText: showPasswordText, hidePasswordText: hidePasswordText, showPasswordAriaLabelText: showPasswordAriaLabelText, hidePasswordAriaLabelText: hidePasswordAriaLabelText, passwordShownAnnouncementText: passwordShownAnnouncementText, passwordHiddenAnnouncementText: passwordHiddenAnnouncementText },
52
+ React.createElement(LabelComposite, { htmlFor: id, size: labelSize, isPageHeading: labelIsPageHeading }, label),
53
+ hintId && React.createElement(Hint, { id: hintId }, hint),
54
+ errorId && React.createElement(ErrorMessageComposite, { id: errorId }, errorMessage),
55
+ React.createElement(Markup.Wrapper, null,
56
+ React.createElement(Input, { id: id, name: name, error: Boolean(errorId), "aria-describedby": ariaDescribedBy, ...props }),
57
+ React.createElement(Status, null),
58
+ React.createElement(Toggle, { "aria-controls": id, "aria-label": showPasswordAriaLabelText }, showPasswordText))));
59
+ }
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version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OAAO,CACL,oBAAC,IAAI,IACH,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,yBAAyB,EAAE,yBAAyB,EACpD,yBAAyB,EAAE,yBAAyB,EACpD,6BAA6B,EAAE,6BAA6B,EAC5D,8BAA8B,EAAE,8BAA8B;QAE9D,oBAAC,cAAc,IAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,IAC5E,KAAK,CACS;QAChB,MAAM,IAAI,oBAAC,IAAI,IAAC,EAAE,EAAE,MAAM,IAAG,IAAI,CAAQ;QACzC,OAAO,IAAI,oBAAC,qBAAqB,IAAC,EAAE,EAAE,OAAO,IAAG,YAAY,CAAyB;QACtF,oBAAC,MAAM,CAAC,OAAO;YACb,oBAAC,KAAK,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAoB,eAAe,KAAM,KAAK,GAAI;YACpG,oBAAC,MAAM,OAAG;YACV,oBAAC,MAAM,qBAAgB,EAAE,gBAAc,yBAAyB,IAC7D,gBAAgB,CACV,CACM,CACZ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/password-input';\nimport * as Markup from 'govuk-frontend-react/password-input';\nimport { ErrorMessageComposite } from 'govuk-frontend-react/error-message';\nimport { Hint } from 'govuk-frontend-react/hint';\nimport { LabelComposite } from 'govuk-frontend-react/label';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's PasswordInput markup, with the show and hide button from\n * @govuk-react/primitives. Without JavaScript it is a password field with no button.\n */\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Help users accessibly enter passwords.\n *\n * @see https://design-system.service.gov.uk/components/password-input/\n */\nexport function Root({\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n ...props\n}: RootProps) {\n const text = {\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n };\n return (\n <Primitives.Root\n showText={showPasswordText}\n hideText={hidePasswordText}\n showLabel={showPasswordAriaLabelText}\n hideLabel={hidePasswordAriaLabelText}\n shownAnnouncement={passwordShownAnnouncementText}\n hiddenAnnouncement={passwordHiddenAnnouncementText}\n >\n <Markup.Root {...text} {...props} />\n </Primitives.Root>\n );\n}\n\nexport { Wrapper, type WrapperProps } from 'govuk-frontend-react/password-input';\n\nexport type InputProps = Markup.InputProps;\n\nexport function Input(props: InputProps) {\n return (\n <Primitives.Input asChild>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ToggleProps = Markup.ToggleProps;\n\n/** The show and hide button. Hidden until JavaScript runs. */\nexport function Toggle(props: ToggleProps) {\n return (\n <Primitives.Toggle asChild>\n <Markup.Toggle {...props} />\n </Primitives.Toggle>\n );\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** A visually hidden live region that announces when the password is shown or hidden. */\nexport function Status({ className, ...props }: StatusProps) {\n return (\n <Primitives.Status\n className={clsx('govuk-password-input__sr-status', 'govuk-visually-hidden', className)}\n {...props}\n />\n );\n}\n\nexport type FieldProps = Markup.FieldProps;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\n/**\n * Help users accessibly enter passwords.\n *\n * @see https://design-system.service.gov.uk/components/password-input/\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n 'aria-describedby': describedBy,\n ...props\n}: FieldProps) {\n const id = idProp || name;\n const hintId = isSet(hint) ? `${id}-hint` : undefined;\n const errorId = isSet(errorMessage) ? `${id}-error` : undefined;\n const ariaDescribedBy = joinIds(describedBy, hintId, errorId);\n\n return (\n <Root\n error={Boolean(errorId)}\n showPasswordText={showPasswordText}\n hidePasswordText={hidePasswordText}\n showPasswordAriaLabelText={showPasswordAriaLabelText}\n hidePasswordAriaLabelText={hidePasswordAriaLabelText}\n passwordShownAnnouncementText={passwordShownAnnouncementText}\n passwordHiddenAnnouncementText={passwordHiddenAnnouncementText}\n >\n <LabelComposite htmlFor={id} size={labelSize} isPageHeading={labelIsPageHeading}>\n {label}\n </LabelComposite>\n {hintId && <Hint id={hintId}>{hint}</Hint>}\n {errorId && <ErrorMessageComposite id={errorId}>{errorMessage}</ErrorMessageComposite>}\n <Markup.Wrapper>\n <Input id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n <Status />\n <Toggle aria-controls={id} aria-label={showPasswordAriaLabelText}>\n {showPasswordText}\n </Toggle>\n </Markup.Wrapper>\n </Root>\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from 'govuk-frontend-react/phase-banner';
@@ -0,0 +1,2 @@
1
+ export * from 'govuk-frontend-react/phase-banner';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/phase-banner/index.tsx"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/phase-banner';\n"]}
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import * as Markup from 'govuk-frontend-react/radios';
3
+ export { Item, Label, Hint, Divider, type ItemProps, type LabelProps, type HintProps, type DividerProps, } from 'govuk-frontend-react/radios';
4
+ /** Shows a reveal only while its radio is checked, before or without JavaScript. */
5
+ export declare const radiosCss: string;
6
+ export type RootProps = Markup.RootProps;
7
+ /**
8
+ * Let users select a single option from a list using the radios component.
9
+ *
10
+ * Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.
11
+ *
12
+ * @see https://design-system.service.gov.uk/components/radios/
13
+ */
14
+ export declare function Root(props: RootProps): React.JSX.Element;
15
+ export type InputProps = Markup.InputProps & {
16
+ /** The id of the `Conditional` this radio reveals. */
17
+ controls?: string;
18
+ };
19
+ export declare function Input({ controls, ...props }: InputProps): React.JSX.Element;
20
+ export type ConditionalProps = Markup.ConditionalProps;
21
+ /** Content revealed while its radio is checked, straight after its `Item`. Pass the radio's `checked` or `defaultChecked` as `checked`. */
22
+ export declare function Conditional(props: ConditionalProps): React.JSX.Element;
23
+ export type ItemCompositeProps = Markup.ItemCompositeProps;
24
+ export declare function ItemComposite({ id, label, hint, conditional, 'aria-describedby': describedBy, ...props }: ItemCompositeProps): React.JSX.Element;
25
+ export type FieldProps = Markup.FieldProps;
26
+ /**
27
+ * Let users select a single option from a list using the radios component.
28
+ *
29
+ * Children are `ItemComposite`s and `Divider`s.
30
+ *
31
+ * @see https://design-system.service.gov.uk/components/radios/
32
+ */
33
+ export declare function Field({ items, children, ...props }: FieldProps): React.JSX.Element;
@@ -0,0 +1,70 @@
1
+ import * as React from 'react';
2
+ import { Children } from 'react';
3
+ import * as Primitives from '@govuk-react/primitives/choices';
4
+ import * as Markup from 'govuk-frontend-react/radios';
5
+ import { joinIds } from '../../utils/join-ids.js';
6
+ /*
7
+ * govuk-frontend-react's Radios markup, with conditional reveals from @govuk-react/primitives.
8
+ * Without JavaScript, a reveal shows only while its radio is checked, where the browser supports
9
+ * `:has()`, and always where it doesn't, as in govuk-frontend.
10
+ */
11
+ export { Item, Label, Hint, Divider, } from 'govuk-frontend-react/radios';
12
+ /** Shows a reveal only while its radio is checked, before or without JavaScript. */
13
+ export const radiosCss = [
14
+ // Hides a reveal whose radio isn't checked.
15
+ '.govuk-radios__item:has(>.govuk-radios__input:not(:checked))+.govuk-radios__conditional{display:none}',
16
+ // Shows one whose radio is, over govuk-frontend's hidden class, until the element upgrades.
17
+ '.govuk-radios__item:has(>.govuk-radios__input:checked)+.govuk-radios__conditional{display:block}',
18
+ ].join('');
19
+ /** The element and styles around the radios, for `Root` and `Field`. */
20
+ function Behaviour({ children }) {
21
+ return (React.createElement(Primitives.Root, { upgradedClass: "govuk-frontend-supported", hiddenConditionalClass: "govuk-radios__conditional--hidden" },
22
+ React.createElement("style", { href: "govuk-react-radios", precedence: "default" }, radiosCss),
23
+ children));
24
+ }
25
+ /**
26
+ * Let users select a single option from a list using the radios component.
27
+ *
28
+ * Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.
29
+ *
30
+ * @see https://design-system.service.gov.uk/components/radios/
31
+ */
32
+ export function Root(props) {
33
+ return (React.createElement(Behaviour, null,
34
+ React.createElement(Markup.Root, { ...props })));
35
+ }
36
+ export function Input({ controls, ...props }) {
37
+ return (React.createElement(Primitives.Input, { asChild: true, controls: controls },
38
+ React.createElement(Markup.Input, { ...props })));
39
+ }
40
+ /** Content revealed while its radio is checked, straight after its `Item`. Pass the radio's `checked` or `defaultChecked` as `checked`. */
41
+ export function Conditional(props) {
42
+ return (React.createElement(Primitives.Conditional, { asChild: true },
43
+ React.createElement(Markup.Conditional, { ...props })));
44
+ }
45
+ const isSet = (node) => node !== undefined && node !== null && node !== false && node !== '';
46
+ export function ItemComposite({ id, label, hint, conditional, 'aria-describedby': describedBy, ...props }) {
47
+ var _a;
48
+ const hintId = isSet(hint) ? `${id}-item-hint` : undefined;
49
+ const conditionalId = isSet(conditional) ? `conditional-${id}` : undefined;
50
+ return (React.createElement(React.Fragment, null,
51
+ React.createElement(Markup.Item, null,
52
+ React.createElement(Input, { id: id, controls: conditionalId, "aria-describedby": joinIds(describedBy, hintId), ...props }),
53
+ React.createElement(Markup.Label, { htmlFor: id }, label),
54
+ hintId && React.createElement(Markup.Hint, { id: hintId }, hint)),
55
+ conditionalId && (React.createElement(Conditional, { id: conditionalId, checked: Boolean((_a = props.checked) !== null && _a !== void 0 ? _a : props.defaultChecked) }, conditional))));
56
+ }
57
+ /**
58
+ * Let users select a single option from a list using the radios component.
59
+ *
60
+ * Children are `ItemComposite`s and `Divider`s.
61
+ *
62
+ * @see https://design-system.service.gov.uk/components/radios/
63
+ */
64
+ export function Field({ items, children, ...props }) {
65
+ return (React.createElement(Behaviour, null,
66
+ React.createElement(Markup.Field, { ...props }, items
67
+ ? items.map((item, index) => 'divider' in item ? (React.createElement(Markup.Divider, { key: index }, item.divider)) : (React.createElement(ItemComposite, { key: index, ...item })))
68
+ : Children.toArray(children))));
69
+ }
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/radios/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;;;GAIG;AAEH,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,GAKR,MAAM,6BAA6B,CAAC;AAErC,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,4CAA4C;IAC5C,uGAAuG;IACvG,4FAA4F;IAC5F,kGAAkG;CACnG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEX,wEAAwE;AACxE,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAiC;IAC5D,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,aAAa,EAAC,0BAA0B,EACxC,sBAAsB,EAAC,mCAAmC;QAE1D,+BAAO,IAAI,EAAC,oBAAoB,EAAC,UAAU,EAAC,SAAS,IAClD,SAAS,CACJ;QACP,QAAQ,CACO,CACnB,CAAC;AACJ,CAA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,MAAM,CAAC,KAAM,KAAK,GAAI;YACrG,oBAAC,MAAM,CAAC,KAAK,IAAC,OAAO,EAAE,EAAE,IAAG,KAAK,CAAgB;YAChD,MAAM,IAAI,oBAAC,MAAM,CAAC,IAAI,IAAC,EAAE,EAAE,MAAM,IAAG,IAAI,CAAe,CAC5C;QACb,aAAa,IAAI,CAChB,oBAAC,WAAW,IAAC,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,cAAc,CAAC,IACpF,WAAW,CACA,CACf,CACA,CACJ,CAAC;AACJ,CAAC;AAID;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IAC7D,OAAO,CACL,oBAAC,SAAS;QACR,oBAAC,MAAM,CAAC,KAAK,OAAK,KAAK,IACpB,KAAK;YACJ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACxB,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,CAClB,oBAAC,MAAM,CAAC,OAAO,IAAC,GAAG,EAAE,KAAK,IAAG,IAAI,CAAC,OAAO,CAAkB,CAC5D,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,IAAC,GAAG,EAAE,KAAK,KAAM,IAAI,GAAI,CACxC,CACF;YACH,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CACjB,CACL,CACb,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { Children } from 'react';\nimport * as Primitives from '@govuk-react/primitives/choices';\nimport * as Markup from 'govuk-frontend-react/radios';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's Radios markup, with conditional reveals from @govuk-react/primitives.\n * Without JavaScript, a reveal shows only while its radio is checked, where the browser supports\n * `:has()`, and always where it doesn't, as in govuk-frontend.\n */\n\nexport {\n Item,\n Label,\n Hint,\n Divider,\n type ItemProps,\n type LabelProps,\n type HintProps,\n type DividerProps,\n} from 'govuk-frontend-react/radios';\n\n/** Shows a reveal only while its radio is checked, before or without JavaScript. */\nexport const radiosCss = [\n // Hides a reveal whose radio isn't checked.\n '.govuk-radios__item:has(>.govuk-radios__input:not(:checked))+.govuk-radios__conditional{display:none}',\n // Shows one whose radio is, over govuk-frontend's hidden class, until the element upgrades.\n '.govuk-radios__item:has(>.govuk-radios__input:checked)+.govuk-radios__conditional{display:block}',\n].join('');\n\n/** The element and styles around the radios, for `Root` and `Field`. */\nfunction Behaviour({ children }: { children: React.ReactNode }) {\n return (\n <Primitives.Root\n upgradedClass=\"govuk-frontend-supported\"\n hiddenConditionalClass=\"govuk-radios__conditional--hidden\"\n >\n <style href=\"govuk-react-radios\" precedence=\"default\">\n {radiosCss}\n </style>\n {children}\n </Primitives.Root>\n );\n}\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Let users select a single option from a list using the radios component.\n *\n * Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.\n *\n * @see https://design-system.service.gov.uk/components/radios/\n */\nexport function Root(props: RootProps) {\n return (\n <Behaviour>\n <Markup.Root {...props} />\n </Behaviour>\n );\n}\n\nexport type InputProps = Markup.InputProps & {\n /** The id of the `Conditional` this radio reveals. */\n controls?: string;\n};\n\nexport function Input({ controls, ...props }: InputProps) {\n return (\n <Primitives.Input asChild controls={controls}>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ConditionalProps = Markup.ConditionalProps;\n\n/** Content revealed while its radio is checked, straight after its `Item`. Pass the radio's `checked` or `defaultChecked` as `checked`. */\nexport function Conditional(props: ConditionalProps) {\n return (\n <Primitives.Conditional asChild>\n <Markup.Conditional {...props} />\n </Primitives.Conditional>\n );\n}\n\nexport type ItemCompositeProps = Markup.ItemCompositeProps;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\nexport function ItemComposite({\n id,\n label,\n hint,\n conditional,\n 'aria-describedby': describedBy,\n ...props\n}: ItemCompositeProps) {\n const hintId = isSet(hint) ? `${id}-item-hint` : undefined;\n const conditionalId = isSet(conditional) ? `conditional-${id}` : undefined;\n return (\n <>\n <Markup.Item>\n <Input id={id} controls={conditionalId} aria-describedby={joinIds(describedBy, hintId)} {...props} />\n <Markup.Label htmlFor={id}>{label}</Markup.Label>\n {hintId && <Markup.Hint id={hintId}>{hint}</Markup.Hint>}\n </Markup.Item>\n {conditionalId && (\n <Conditional id={conditionalId} checked={Boolean(props.checked ?? props.defaultChecked)}>\n {conditional}\n </Conditional>\n )}\n </>\n );\n}\n\nexport type FieldProps = Markup.FieldProps;\n\n/**\n * Let users select a single option from a list using the radios component.\n *\n * Children are `ItemComposite`s and `Divider`s.\n *\n * @see https://design-system.service.gov.uk/components/radios/\n */\nexport function Field({ items, children, ...props }: FieldProps) {\n return (\n <Behaviour>\n <Markup.Field {...props}>\n {items\n ? items.map((item, index) =>\n 'divider' in item ? (\n <Markup.Divider key={index}>{item.divider}</Markup.Divider>\n ) : (\n <ItemComposite key={index} {...item} />\n )\n )\n : Children.toArray(children)}\n </Markup.Field>\n </Behaviour>\n );\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import type { ComponentProps, ReactNode } from 'react';
3
+ /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
4
+ export declare const relatedItemsCss = ".govuk-react-related-items{border-top:2px solid var(--govuk-brand-colour,#1d70b8);padding-top:10px}";
5
+ export type RootProps = ComponentProps<'div'>;
6
+ /** Related content, such as topics, guidance and collections. */
7
+ export declare function Root({ className, children, ...props }: RootProps): React.JSX.Element;
8
+ export type HeadingProps = ComponentProps<'h2'>;
9
+ export declare function Heading({ className, children, ...props }: HeadingProps): React.JSX.Element;
10
+ export type SectionProps = ComponentProps<'nav'>;
11
+ export declare function Section(props: SectionProps): React.JSX.Element;
12
+ export type SectionHeadingProps = ComponentProps<'h3'>;
13
+ export declare function SectionHeading({ className, children, ...props }: SectionHeadingProps): React.JSX.Element;
14
+ export type ListProps = ComponentProps<'ul'>;
15
+ export declare function List({ className, ...props }: ListProps): React.JSX.Element;
16
+ export type ItemProps = ComponentProps<'li'>;
17
+ export declare function Item(props: ItemProps): React.JSX.Element;
18
+ export type SectionCompositeProps = Omit<SectionProps, 'title'> & {
19
+ /** The section heading, such as “Travel abroad”. Also labels the navigation landmark. */
20
+ title: ReactNode;
21
+ };
22
+ /** A labelled navigation section with a heading and a list. Children are `Item`s. */
23
+ export declare function SectionComposite({ title, children, ...props }: SectionCompositeProps): React.JSX.Element;
24
+ export type CompositeProps = Omit<RootProps, 'title'> & {
25
+ /** The main heading. */
26
+ title?: ReactNode;
27
+ };
28
+ /**
29
+ * Related content, including topics, guidance and collections. Children are `SectionComposite`s.
30
+ *
31
+ * @see https://components.publishing.service.gov.uk/component-guide/related_navigation
32
+ */
33
+ export declare function Composite({ title, children, ...props }: CompositeProps): React.JSX.Element;
@@ -0,0 +1,45 @@
1
+ import * as React from 'react';
2
+ import { useId } from 'react';
3
+ import { clsx } from 'clsx';
4
+ const name = 'govuk-react-related-items';
5
+ /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
6
+ export const relatedItemsCss = `.${name}{border-top:2px solid var(--govuk-brand-colour,#1d70b8);padding-top:10px}`;
7
+ /** Related content, such as topics, guidance and collections. */
8
+ export function Root({ className, children, ...props }) {
9
+ return (React.createElement("div", { className: clsx(name, className), ...props },
10
+ React.createElement("style", { href: name, precedence: "default" }, relatedItemsCss),
11
+ children));
12
+ }
13
+ export function Heading({ className, children, ...props }) {
14
+ return (React.createElement("h2", { className: clsx('govuk-heading-s', className), ...props }, children));
15
+ }
16
+ export function Section(props) {
17
+ return React.createElement("nav", { ...props });
18
+ }
19
+ export function SectionHeading({ className, children, ...props }) {
20
+ return (React.createElement("h3", { className: clsx('govuk-body-s', 'govuk-!-font-weight-bold', 'govuk-!-margin-bottom-2', className), ...props }, children));
21
+ }
22
+ export function List({ className, ...props }) {
23
+ return React.createElement("ul", { className: clsx('govuk-list', 'govuk-body-s', className), ...props });
24
+ }
25
+ export function Item(props) {
26
+ return React.createElement("li", { ...props });
27
+ }
28
+ /** A labelled navigation section with a heading and a list. Children are `Item`s. */
29
+ export function SectionComposite({ title, children, ...props }) {
30
+ const headingId = useId();
31
+ return (React.createElement(Section, { "aria-labelledby": headingId, ...props },
32
+ React.createElement(SectionHeading, { id: headingId }, title),
33
+ React.createElement(List, null, children)));
34
+ }
35
+ /**
36
+ * Related content, including topics, guidance and collections. Children are `SectionComposite`s.
37
+ *
38
+ * @see https://components.publishing.service.gov.uk/component-guide/related_navigation
39
+ */
40
+ export function Composite({ title = 'Related content', children, ...props }) {
41
+ return (React.createElement(Root, { ...props },
42
+ React.createElement(Heading, null, title),
43
+ children));
44
+ }
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/related-items/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,IAAI,2EAA2E,CAAC;AAInH,iEAAiE;AACjE,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAa;IAC/D,OAAO,CACL,6BAAK,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,KAAM,KAAK;QAC9C,+BAAO,IAAI,EAAE,IAAI,EAAE,UAAU,EAAC,SAAS,IACpC,eAAe,CACV;QACP,QAAQ,CACL,CACP,CAAC;AACJ,CAAC;AAID,MAAM,UAAU,OAAO,CAAC,EAAE,SAAS,EAAE,Q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,oBAAC,OAAO,QAAE,KAAK,CAAW;QACzB,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useId } from 'react';\nimport { clsx } from 'clsx';\n\nconst name = 'govuk-react-related-items';\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */\nexport const relatedItemsCss = `.${name}{border-top:2px solid var(--govuk-brand-colour,#1d70b8);padding-top:10px}`;\n\nexport type RootProps = ComponentProps<'div'>;\n\n/** Related content, such as topics, guidance and collections. */\nexport function Root({ className, children, ...props }: RootProps) {\n return (\n <div className={clsx(name, className)} {...props}>\n <style href={name} precedence=\"default\">\n {relatedItemsCss}\n </style>\n {children}\n </div>\n );\n}\n\nexport type HeadingProps = ComponentProps<'h2'>;\n\nexport function Heading({ className, children, ...props }: HeadingProps) {\n return (\n <h2 className={clsx('govuk-heading-s', className)} {...props}>\n {children}\n </h2>\n );\n}\n\nexport type SectionProps = ComponentProps<'nav'>;\n\nexport function Section(props: SectionProps) {\n return <nav {...props} />;\n}\n\nexport type SectionHeadingProps = ComponentProps<'h3'>;\n\nexport function SectionHeading({ className, children, ...props }: SectionHeadingProps) {\n return (\n <h3 className={clsx('govuk-body-s', 'govuk-!-font-weight-bold', 'govuk-!-margin-bottom-2', className)} {...props}>\n {children}\n </h3>\n );\n}\n\nexport type ListProps = ComponentProps<'ul'>;\n\nexport function List({ className, ...props }: ListProps) {\n return <ul className={clsx('govuk-list', 'govuk-body-s', className)} {...props} />;\n}\n\nexport type ItemProps = ComponentProps<'li'>;\n\nexport function Item(props: ItemProps) {\n return <li {...props} />;\n}\n\nexport type SectionCompositeProps = Omit<SectionProps, 'title'> & {\n /** The section heading, such as “Travel abroad”. Also labels the navigation landmark. */\n title: ReactNode;\n};\n\n/** A labelled navigation section with a heading and a list. Children are `Item`s. */\nexport function SectionComposite({ title, children, ...props }: SectionCompositeProps) {\n const headingId = useId();\n return (\n <Section aria-labelledby={headingId} {...props}>\n <SectionHeading id={headingId}>{title}</SectionHeading>\n <List>{children}</List>\n </Section>\n );\n}\n\nexport type CompositeProps = Omit<RootProps, 'title'> & {\n /** The main heading. */\n title?: ReactNode;\n};\n\n/**\n * Related content, including topics, guidance and collections. Children are `SectionComposite`s.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/related_navigation\n */\nexport function Composite({ title = 'Related content', children, ...props }: CompositeProps) {\n return (\n <Root {...props}>\n <Heading>{title}</Heading>\n {children}\n </Root>\n );\n}\n"]}