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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Alasdair McLeay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # govuk-react
2
2
 
3
- An implementation of the [GOV.UK Design System](https://govuk-design-system-production.cloudapps.digital) in [React](https://reactjs.org) using [CSSinJS](https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660) using Object notation (with [styled-components](https://www.styled-components.com/docs/advanced#style-objects)).
3
+ An implementation of the [GOV.UK Design System](https://design-system.service.gov.uk) in [React](https://react.dev), built on [govuk-frontend-react](https://github.com/govuk-react/govuk-frontend-react) and styled by govuk-frontend's CSS.
4
4
 
5
5
  [![codecov](https://codecov.io/gh/govuk-react/govuk-react/branch/master/graph/badge.svg)](https://codecov.io/gh/govuk-react/govuk-react)
6
6
  [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/govuk-react)
@@ -17,62 +17,78 @@ We aim to track the following projects (in priority order) as to which component
17
17
  This project is being or has been used by:
18
18
 
19
19
  - [Connected Open Government Statistics](https://github.com/GSS-Cogs/chart-builder) [2](https://github.com/GSS-Cogs/dd-cms)
20
+ - [Data to Insight](https://github.com/data-to-insight/quality-lac-data-beta)
20
21
  - [Department for Education](https://github.com/DFE-Digital/meeting-timer)
21
22
  - [Department for Environment, Food & Rural Affairs](https://github.com/atoscerebro/defra-wtp) [2](https://github.com/DEFRA/eutd-mmo-cc-external-frontend)
22
23
  - [Department for International Trade](https://github.com/uktrade/data-science-frontend) [2](https://github.com/uktrade/data-hub-frontend) [3](https://github.com/uktrade/statement-of-works) [4](https://github.com/uktrade/data-hub-components)
23
24
  - [Department of Business, Energy and Industrial Strategy](https://github.com/UKGovernmentBEIS/beis-cosmetics-spa)
24
- - [Department of Health](https://github.com/DepartmentOfHealth-htbhf/htbhf-management-web-ui-spike)
25
+ - [Department for Energy Security and Net Zero](https://github.com/Integrated-Corporate-Services/desnz-syeia-frontend-beta)
26
+ - [Department of Health and Social Care](https://github.com/DepartmentOfHealth-htbhf/htbhf-management-web-ui-spike) [2](https://github.com/dhsc-govuk/FingertipsNext) [3](https://github.com/dhsc-govuk/HealthyBabies) [4](https://github.com/dhsc-govuk/gamblinglevy)
25
27
  - [Department for Environment, Food and Rural Affairs](https://github.com/DEFRA/eutd-mmo-cc-external-frontend)
26
- - [Department for Transport](https://github.com/fares-data-build-tool/fdbt-admin)
28
+ - [Department for Transport](https://github.com/fares-data-build-tool/fdbt-admin) [2](https://github.com/department-for-transport-BODS/create-disruptions-data) [3](https://github.com/department-for-transport-BODS/publish-devolved-bus-registration-data)
29
+ - [Driver and Vehicle Licensing Agency](https://github.com/dvla/lab-gen-ui)
27
30
  - [Food Standards Agency](https://github.com/FoodStandardsAgency/register-a-food-business-healthcheck-dashboard) [2](https://github.com/FSA-Civica/govuk-react/tree/slice-and-dice-packages/base)
28
31
  - [HM Courts & Tribunals Service](https://github.com/hmcts/mytime-frontend) [2](https://github.com/hmcts/rse-next-prototype)
29
32
  - [HM Land Registry](https://github.com/LandRegistry/title-token)
30
33
  - [HM Passport Office](https://github.com/UKHomeOffice/lev-react-components)
31
- - [HM Prison and Probation Services](https://github.com/ministryofjustice/prisonstaffhub) [2](https://github.com/ministryofjustice/prison-services-feedback-and-support)
34
+ - [HM Prison and Probation Services](https://github.com/ministryofjustice/prisonstaffhub) [2](https://github.com/ministryofjustice/prison-services-feedback-and-support) [3](https://github.com/ministryofjustice/digital-prison-services)
32
35
  - [Home Office](https://github.com/UKHomeOffice/system-register) [2]
33
36
  - [Made Tech](https://github.com/madetech/govuk-react-form) [2](https://github.com/madetech/academy20-zingtech-frontend)
34
37
  - [Ministry of Justice](https://github.com/ministryofjustice/manage-key-workers) [2](https://github.com/ministryofjustice/bichard7-next-ui)
35
38
  - [London Borough of Hackney](https://github.com/LBHackney-IT/document-evidence-store-frontend)
36
39
  - [Public Health England/UK Health Security Agency](https://web.archive.org/web/20220216110415if_/https://get-home-lateral-flow-testing-kit.service.gov.uk/static/js/2.dad2ad18.chunk.js.map)
37
40
  - [Skills Funding Agency](https://github.com/SkillsFundingAgency/CFS-Frontend) [2](https://github.com/SkillsFundingAgency/das-qna-config)
41
+ - [UK Research and Innovation](https://github.com/ukriorg/ukripoc-application) [2](https://github.com/ukriorg/ukripoc-opportunity) [3](https://github.com/ukriorg/ukripoc-front-door)
38
42
 
39
43
  The project is currently maintained for free by a small number of volunteers. If you would like to contribute, help maintain or sponsor this project, please get in touch via [Discussions](https://github.com/govuk-react/govuk-react/discussions) or [Twitter](https://twitter.com/penx).
40
44
 
41
45
  ## Usage
42
46
 
43
47
  ```sh
44
- npm install govuk-react styled-components @types/styled-components --save
48
+ npm install govuk-react govuk-frontend
49
+ ```
50
+
51
+ Load govuk-frontend's CSS once in your app:
52
+
53
+ ```js
54
+ import 'govuk-frontend/dist/govuk/govuk-frontend.min.css';
45
55
  ```
46
56
 
47
57
  ```jsx
48
- import { Button } from 'govuk-react'
58
+ import { Button } from 'govuk-react';
49
59
 
50
- const MyComponent = ({title}) => (<div>
51
- <h1>{title}</h1>
52
- <Button />
53
- </div>)
60
+ const MyComponent = ({ title }) => (
61
+ <div>
62
+ <h1>{title}</h1>
63
+ <Button>Save and continue</Button>
64
+ </div>
65
+ );
54
66
  ```
55
67
 
56
68
  See the [Storybook](https://govuk-react.github.io/govuk-react) for examples of all available components.
57
69
 
58
70
  Also see the [Example Application](packages/example-application/src) for basic usage.
59
71
 
60
- ## Using Link with a Router Link
72
+ ## Fonts and images
73
+
74
+ govuk-frontend's CSS loads its fonts and images from `/assets`. Serve `node_modules/govuk-frontend/dist/govuk/assets` at `/assets`, or copy its `fonts` and `images` folders and `manifest.json` into your app's `assets` folder. See govuk-frontend's guide to [importing font and images assets](https://frontend.design-system.service.gov.uk/import-font-and-images-assets/).
75
+
76
+ "If your service is on the service.gov.uk subdomain you must use the GDS Transport font."
61
77
 
62
- We provide a Link component which creates an element styled as a GDS link. As we are using styled-components it is possible to apply that style to an existing component using the `as` prop. Other props will be passed through.
78
+ "If your service is publicly available on a subdomain other than service.gov.uk, use an alternative typeface." See the Design System's [typeface guidance](https://design-system.service.gov.uk/styles/typeface/) and [using GOV.UK Frontend without GOV.UK branding](https://frontend.design-system.service.gov.uk/using-govuk-frontend-without-govuk-branding/), which sets `$govuk-font-family` with govuk-frontend's Sass API.
79
+
80
+ ## Using Link with a Router Link
63
81
 
64
- For example;
82
+ `Link`, `BackLink` and the navigation link parts take `asChild`, which applies their classes to your router link instead of rendering an `a`:
65
83
 
66
84
  ```jsx
67
- import { BrowserRouter, Link as RouterLink } from 'react-router';
68
- import { Link } from '@govuk-react/link';
85
+ import { Link as RouterLink } from 'react-router';
86
+ import { Link } from 'govuk-react/link';
69
87
 
70
88
  const MyComponent = () => (
71
- <nav>
72
- <BrowserRouter>
73
- <Link as={RouterLink} to="https://example.com">example</Link>
74
- </BrowserRouter>
75
- </nav>
89
+ <Link asChild>
90
+ <RouterLink to="/page">Page</RouterLink>
91
+ </Link>
76
92
  );
77
93
  ```
78
94
 
@@ -80,45 +96,22 @@ const MyComponent = () => (
80
96
 
81
97
  Use of these components assumes the following from the peer project:
82
98
 
83
- - The govuk-react `GlobalStyle` component is included on all pages.
84
- - The GDS Transport font face is included ([for gov.uk domains only](https://www.gov.uk/service-manual/design/making-your-service-look-like-govuk))
85
- - Optionally, either [normalize.css](https://necolas.github.io/normalize.css/) or [sanitize.css](https://csstools.github.io/sanitize.css/) is used as a CSS reset. We don't test for this, so please raise an issue if you find any problems with compatibility.
86
- - Other than the reset, no other styles affecting generic elements (without classes, IDs etc) are present in the CSS.
99
+ - `govuk-frontend` is installed and its CSS (`govuk-frontend/dist/govuk/govuk-frontend.min.css`) is loaded.
100
+ - govuk-frontend's font and image assets are served at `/assets` (see [Fonts and images](#fonts-and-images)).
101
+ - No other styles affecting generic elements (without classes, IDs etc) are present in the CSS.
87
102
 
88
- ## Why CSS-in-JS?
103
+ ## Imports
89
104
 
90
- See [A Unified Styling Language](https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660).
91
-
92
- This project is part of a larger initiative to componetise large scale React applications. Using CSSinJS allows us to include styles inside a module bundle that can be published (using `npm publish`) and consumed by a peer application, without putting dependencies on the peer application to implement a specific CSS build system.
93
-
94
- ## Why not use GDS styles/classes directly
95
-
96
- 1. We want to be free to write different DOM structure and/or CSS that is more in keeping with a React and bem-ish architecture. (e.g. in React you often don't need to specify IDs for field inputs, and can wrap inputs with labels so that they are automatically associated. We want to leave the decision of whether to use input IDs to the parent project. GDS styles don't wrap inputs with labels and require IDs and for attributes).
97
- 2. We want a parent project to not have to worry about a specific build system (e.g. for handling `import styles.css`, particularly if you want universal support) or including certain CSS files. We want a simple `npm install govuk-react` to be enough to get govuk styled components on to your page, irrespective of your build system.
98
- 3. We want to distribute React applications as modules that have self contained styles. CSS in JS allows all styles to be contained in distributable JS modules that can be ported across projects.
99
-
100
- ## Why is this a monorepo?
101
-
102
- Components are published to npm independently. This means users have the ability to upgrade govuk-react and still use older components.
103
-
104
- This is particularly relevant in a large application where:
105
-
106
- - some code is reliant on a component that has either been deprecated or had breaking changes
107
- - you aren't able to refactor the existing code, e.g. it is a large job or managed by another team
108
- - you don't want to hold back from upgrading to the newest version of govuk-react
109
-
110
- e.g. for DateField, you import it separately as follows:
105
+ Import from the package root, or from a component's own subpath:
111
106
 
112
107
  ```js
113
- import { H1, Paragraph } from 'govuk-react';
114
- import DateField from '@govuk-react/date-field';
108
+ import { Body, Heading } from 'govuk-react';
109
+ import * as DateInput from 'govuk-react/date-input';
115
110
  ```
116
111
 
117
- Then in your package.json, you can update govuk-react, but specify the older version of '@govuk-react/date-field'.
118
-
119
- ## About the GDS font
112
+ ## Migrating to 1.0
120
113
 
121
- Unfortunately the GDS transport font has a relatively restrictive license [described on the gov.uk blog](https://designnotes.blog.gov.uk/2015/03/11/can-i-use-the-gov-uk-fonts/). We are investigating rendering an elegant alternative before falling back to Arial on [issue 272](https://github.com/govuk-react/govuk-react/issues/272).
114
+ See [MIGRATION.md](MIGRATION.md).
122
115
 
123
116
  ## Related sites and projects
124
117
 
@@ -0,0 +1,68 @@
1
+ import * as React from 'react';
2
+ import type { ReactNode } from 'react';
3
+ import * as Primitives from '@govuk-react/primitives/accordion';
4
+ import * as Markup from 'govuk-frontend-react/accordion';
5
+ export type RootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {
6
+ /** The open sections' values, to control them once hydrated. */
7
+ value?: string[];
8
+ /** The sections open at first. */
9
+ defaultValue?: string[];
10
+ /** Called with the open sections' values when the user opens or closes a section. */
11
+ onValueChange?: (value: string[]) => void;
12
+ };
13
+ /**
14
+ * The accordion component lets users show and hide sections of related content on a page.
15
+ *
16
+ * @see https://design-system.service.gov.uk/components/accordion/
17
+ */
18
+ export declare function Root({ value, defaultValue, onValueChange, rememberExpanded, hideAllSectionsText, hideSectionText, hideSectionAriaLabelText, showAllSectionsText, showSectionText, showSectionAriaLabelText, ...props }: RootProps): React.JSX.Element;
19
+ export type ControlsProps = Omit<Primitives.ControlsProps, 'asChild' | 'children'>;
20
+ /** The "Show all sections" button, at the top of the accordion. Hidden until JavaScript runs. */
21
+ export declare function Controls({ className, ...props }: ControlsProps): React.JSX.Element;
22
+ export type SectionProps = Markup.SectionProps & {
23
+ /** Identifies the section in the accordion's `value`. */
24
+ value: string;
25
+ };
26
+ export declare function Section({ value, expanded, ...props }: SectionProps): React.JSX.Element;
27
+ export { SectionHeader, SectionHeading, type SectionHeaderProps, type SectionHeadingProps, } from 'govuk-frontend-react/accordion';
28
+ export type SectionButtonProps = Markup.SectionButtonProps & {
29
+ /** The section's summary line, which the button also shows once JavaScript runs. */
30
+ summary?: ReactNode;
31
+ };
32
+ /**
33
+ * The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a
34
+ * button that shows and hides the section, holding the heading and `summary`.
35
+ */
36
+ export declare function SectionButton({ summary, children, ...props }: SectionButtonProps): React.JSX.Element;
37
+ export type SectionSummaryProps = Markup.SectionSummaryProps;
38
+ /** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */
39
+ export declare function SectionSummary(props: SectionSummaryProps): React.JSX.Element;
40
+ export type SectionContentProps = Markup.SectionContentProps;
41
+ /** The section's content. Give it an id, which the button's `aria-controls` names. */
42
+ export declare function SectionContent(props: SectionContentProps): React.JSX.Element;
43
+ export type SectionCompositeProps = Omit<Markup.SectionCompositeProps, 'expanded'> & {
44
+ /** Identifies the section in the accordion's `value`. Defaults to its content's id. */
45
+ value?: string;
46
+ /** Sets whether the section should be expanded when the page loads for the first time. Defaults to whether the accordion's value includes it. */
47
+ expanded?: boolean;
48
+ };
49
+ export declare function SectionComposite({ accordionId, index, heading, summary, headingLevel, value, children, ...props }: SectionCompositeProps): React.JSX.Element;
50
+ export type CompositeProps = Omit<RootProps, 'id' | 'children'> & Pick<Markup.SectionHeadingProps, 'headingLevel'> & {
51
+ /** Must be unique across the domain of your service if `rememberExpanded` is `true` (as the expanded state of individual instances of the component persists across page loads using [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)). Used as an `id` in the HTML for the accordion as a whole, and also as a prefix for the `id`s of the section contents and the buttons that open them, so that those `id`s can be the target of `aria-control` attributes. */
52
+ id: string;
53
+ } & ({
54
+ children?: ReactNode;
55
+ sections?: never;
56
+ } | {
57
+ children?: never;
58
+ /** Prefer children, which memoise and re-render better. */
59
+ sections: Omit<SectionCompositeProps, 'accordionId' | 'index' | 'headingLevel'>[];
60
+ });
61
+ /**
62
+ * The accordion component lets users show and hide sections of related content on a page.
63
+ *
64
+ * Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.
65
+ *
66
+ * @see https://design-system.service.gov.uk/components/accordion/
67
+ */
68
+ export declare function Composite({ id, headingLevel, sections, children, ...props }: CompositeProps): React.JSX.Element;
@@ -0,0 +1,104 @@
1
+ import * as React from 'react';
2
+ import { createContext, useContext } from 'react';
3
+ import { clsx } from 'clsx';
4
+ import * as Primitives from '@govuk-react/primitives/accordion';
5
+ import * as Markup from 'govuk-frontend-react/accordion';
6
+ /*
7
+ * govuk-frontend-react's Accordion markup, with the behaviour from @govuk-react/primitives. As in
8
+ * govuk-frontend, every section is open without JavaScript. Each section also renders the button
9
+ * govuk-frontend's script would build, hidden until the element upgrades, so React never has its
10
+ * markup moved.
11
+ */
12
+ // Fills in defaults only: in an island without a Root, pass `defaultExpanded` to Section.
13
+ const AccordionContext = createContext({});
14
+ /**
15
+ * The accordion component lets users show and hide sections of related content on a page.
16
+ *
17
+ * @see https://design-system.service.gov.uk/components/accordion/
18
+ */
19
+ export function Root({ value, defaultValue, onValueChange, rememberExpanded, hideAllSectionsText, hideSectionText, hideSectionAriaLabelText, showAllSectionsText, showSectionText, showSectionAriaLabelText, ...props }) {
20
+ return (React.createElement(AccordionContext.Provider, { value: { open: value !== null && value !== void 0 ? value : defaultValue } },
21
+ React.createElement(Primitives.Root, { value: value, defaultValue: defaultValue, onValueChange: onValueChange, rememberExpanded: rememberExpanded, hideAllSectionsText: hideAllSectionsText, hideSectionText: hideSectionText, hideSectionLabel: hideSectionAriaLabelText, showAllSectionsText: showAllSectionsText, showSectionText: showSectionText, showSectionLabel: showSectionAriaLabelText,
22
+ // govuk-frontend styles the accordion under `govuk-frontend-supported`, which its JavaScript adds to the body.
23
+ upgradedClass: "govuk-frontend-supported", expandedSectionClass: "govuk-accordion__section--expanded", collapsedIconClass: "govuk-accordion-nav__chevron--down" },
24
+ React.createElement(Markup.Root, { ...props }))));
25
+ }
26
+ /** The "Show all sections" button, at the top of the accordion. Hidden until JavaScript runs. */
27
+ export function Controls({ className, ...props }) {
28
+ return (React.createElement(Primitives.Controls, { className: clsx('govuk-accordion__controls', className), ...props },
29
+ React.createElement(Primitives.ShowAll, { className: "govuk-accordion__show-all", "aria-expanded": "false" },
30
+ React.createElement(Primitives.Icon, { className: "govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down" }),
31
+ React.createElement(Primitives.ShowAllText, { className: "govuk-accordion__show-all-text" }, "Show all sections"))));
32
+ }
33
+ export function Section({ value, expanded, ...props }) {
34
+ var _a, _b;
35
+ const context = useContext(AccordionContext);
36
+ const isExpanded = (_b = expanded !== null && expanded !== void 0 ? expanded : (_a = context.open) === null || _a === void 0 ? void 0 : _a.includes(value)) !== null && _b !== void 0 ? _b : false;
37
+ return (React.createElement(Primitives.Section, { value: value, defaultExpanded: isExpanded, asChild: true },
38
+ React.createElement(Markup.Section, { expanded: isExpanded, ...props })));
39
+ }
40
+ export { SectionHeader, SectionHeading, } from 'govuk-frontend-react/accordion';
41
+ const divider = React.createElement("span", { className: "govuk-visually-hidden govuk-accordion__section-heading-divider" }, ", ");
42
+ /**
43
+ * The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a
44
+ * button that shows and hides the section, holding the heading and `summary`.
45
+ */
46
+ export function SectionButton({ summary, children, ...props }) {
47
+ return (React.createElement(React.Fragment, null,
48
+ React.createElement(Primitives.Fallback, { asChild: true },
49
+ React.createElement(Markup.SectionButton, { ...props }, children)),
50
+ React.createElement(Primitives.Trigger, { className: "govuk-accordion__section-button" },
51
+ React.createElement("span", { className: "govuk-accordion__section-heading-text" },
52
+ React.createElement(Primitives.Label, { className: "govuk-accordion__section-heading-text-focus" }, children)),
53
+ divider,
54
+ hasContent(summary) && (React.createElement(React.Fragment, null,
55
+ React.createElement("span", { className: "govuk-accordion__section-summary govuk-body" },
56
+ React.createElement(Primitives.Label, { className: "govuk-accordion__section-summary-focus" }, summary)),
57
+ divider)),
58
+ React.createElement("span", { className: "govuk-accordion__section-toggle", "data-nosnippet": "" },
59
+ React.createElement("span", { className: "govuk-accordion__section-toggle-focus" },
60
+ React.createElement(Primitives.Icon, { className: "govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down" }),
61
+ React.createElement(Primitives.ToggleText, { className: "govuk-accordion__section-toggle-text" }, "Show"))))));
62
+ }
63
+ /** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */
64
+ export function SectionSummary(props) {
65
+ return (React.createElement(Primitives.Fallback, { asChild: true },
66
+ React.createElement(Markup.SectionSummary, { ...props })));
67
+ }
68
+ /** The section's content. Give it an id, which the button's `aria-controls` names. */
69
+ export function SectionContent(props) {
70
+ return (React.createElement(Primitives.Content, { asChild: true },
71
+ React.createElement(Markup.SectionContent, { ...props })));
72
+ }
73
+ export function SectionComposite({ accordionId, index, heading, summary, headingLevel, value, children, ...props }) {
74
+ const contentId = `${accordionId}-content-${index}`;
75
+ return (React.createElement(Section, { value: value !== null && value !== void 0 ? value : contentId, ...props },
76
+ React.createElement(Markup.SectionHeader, null,
77
+ React.createElement(Markup.SectionHeading, { headingLevel: headingLevel },
78
+ React.createElement(SectionButton, { id: `${accordionId}-heading-${index}`, summary: summary }, heading)),
79
+ hasContent(summary) && React.createElement(SectionSummary, { id: `${accordionId}-summary-${index}` }, summary)),
80
+ React.createElement(SectionContent, { id: contentId }, children)));
81
+ }
82
+ /**
83
+ * The accordion component lets users show and hide sections of related content on a page.
84
+ *
85
+ * Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.
86
+ *
87
+ * @see https://design-system.service.gov.uk/components/accordion/
88
+ */
89
+ export function Composite({ id, headingLevel, sections, children, ...props }) {
90
+ return (React.createElement(Root, { id: id, ...props },
91
+ React.createElement(Controls, null),
92
+ sections
93
+ ? sections.map((section, index) => (React.createElement(SectionComposite, { key: index, accordionId: id, index: index + 1, headingLevel: headingLevel, ...section })))
94
+ : children));
95
+ }
96
+ // As govuk-frontend-react decides whether there is a summary.
97
+ function hasContent(node) {
98
+ if (node === null || node === undefined || node === false || node === true || node === '')
99
+ return false;
100
+ if (Array.isArray(node))
101
+ return node.some(hasContent);
102
+ return true;
103
+ }
104
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/accordion/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AAEzD;;;;;GAKG;AAEH,0FAA0F;AAC1F,MAAM,gBAAgB,GAAG,aAAa,CAAsB,EAAE,CAAC,CAAC;AAWhE;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,GAAG,KAAK,EACE;IACV,OAAO,CACL,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,YAAY,EAAE;QAC/D,oBAAC,UAAU,CAAC,IAAI,IACd,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,wBAAwB,EAC1C,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,gBA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,QAAQ,CACP,CACR,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,SAAS,UAAU,CAAC,IAAe;IACjC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACxG,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as React from 'react';\nimport { createContext, useContext } from 'react';\nimport type { ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/accordion';\nimport * as Markup from 'govuk-frontend-react/accordion';\n\n/*\n * govuk-frontend-react's Accordion markup, with the behaviour from @govuk-react/primitives. As in\n * govuk-frontend, every section is open without JavaScript. Each section also renders the button\n * govuk-frontend's script would build, hidden until the element upgrades, so React never has its\n * markup moved.\n */\n\n// Fills in defaults only: in an island without a Root, pass `defaultExpanded` to Section.\nconst AccordionContext = createContext<{ open?: string[] }>({});\n\nexport type RootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {\n /** The open sections' values, to control them once hydrated. */\n value?: string[];\n /** The sections open at first. */\n defaultValue?: string[];\n /** Called with the open sections' values when the user opens or closes a section. */\n onValueChange?: (value: string[]) => void;\n};\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Root({\n value,\n defaultValue,\n onValueChange,\n rememberExpanded,\n hideAllSectionsText,\n hideSectionText,\n hideSectionAriaLabelText,\n showAllSectionsText,\n showSectionText,\n showSectionAriaLabelText,\n ...props\n}: RootProps) {\n return (\n <AccordionContext.Provider value={{ open: value ?? defaultValue }}>\n <Primitives.Root\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n rememberExpanded={rememberExpanded}\n hideAllSectionsText={hideAllSectionsText}\n hideSectionText={hideSectionText}\n hideSectionLabel={hideSectionAriaLabelText}\n showAllSectionsText={showAllSectionsText}\n showSectionText={showSectionText}\n showSectionLabel={showSectionAriaLabelText}\n // govuk-frontend styles the accordion under `govuk-frontend-supported`, which its JavaScript adds to the body.\n upgradedClass=\"govuk-frontend-supported\"\n expandedSectionClass=\"govuk-accordion__section--expanded\"\n collapsedIconClass=\"govuk-accordion-nav__chevron--down\"\n >\n <Markup.Root {...props} />\n </Primitives.Root>\n </AccordionContext.Provider>\n );\n}\n\nexport type ControlsProps = Omit<Primitives.ControlsProps, 'asChild' | 'children'>;\n\n/** The \"Show all sections\" button, at the top of the accordion. Hidden until JavaScript runs. */\nexport function Controls({ className, ...props }: ControlsProps) {\n return (\n <Primitives.Controls className={clsx('govuk-accordion__controls', className)} {...props}>\n <Primitives.ShowAll className=\"govuk-accordion__show-all\" aria-expanded=\"false\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ShowAllText className=\"govuk-accordion__show-all-text\">Show all sections</Primitives.ShowAllText>\n </Primitives.ShowAll>\n </Primitives.Controls>\n );\n}\n\nexport type SectionProps = Markup.SectionProps & {\n /** Identifies the section in the accordion's `value`. */\n value: string;\n};\n\nexport function Section({ value, expanded, ...props }: SectionProps) {\n const context = useContext(AccordionContext);\n const isExpanded = expanded ?? context.open?.includes(value) ?? false;\n return (\n <Primitives.Section value={value} defaultExpanded={isExpanded} asChild>\n <Markup.Section expanded={isExpanded} {...props} />\n </Primitives.Section>\n );\n}\n\nexport {\n SectionHeader,\n SectionHeading,\n type SectionHeaderProps,\n type SectionHeadingProps,\n} from 'govuk-frontend-react/accordion';\n\nconst divider = <span className=\"govuk-visually-hidden govuk-accordion__section-heading-divider\">, </span>;\n\nexport type SectionButtonProps = Markup.SectionButtonProps & {\n /** The section's summary line, which the button also shows once JavaScript runs. */\n summary?: ReactNode;\n};\n\n/**\n * The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a\n * button that shows and hides the section, holding the heading and `summary`.\n */\nexport function SectionButton({ summary, children, ...props }: SectionButtonProps) {\n return (\n <>\n <Primitives.Fallback asChild>\n <Markup.SectionButton {...props}>{children}</Markup.SectionButton>\n </Primitives.Fallback>\n <Primitives.Trigger className=\"govuk-accordion__section-button\">\n <span className=\"govuk-accordion__section-heading-text\">\n <Primitives.Label className=\"govuk-accordion__section-heading-text-focus\">{children}</Primitives.Label>\n </span>\n {divider}\n {hasContent(summary) && (\n <>\n <span className=\"govuk-accordion__section-summary govuk-body\">\n <Primitives.Label className=\"govuk-accordion__section-summary-focus\">{summary}</Primitives.Label>\n </span>\n {divider}\n </>\n )}\n <span className=\"govuk-accordion__section-toggle\" data-nosnippet=\"\">\n <span className=\"govuk-accordion__section-toggle-focus\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ToggleText className=\"govuk-accordion__section-toggle-text\">Show</Primitives.ToggleText>\n </span>\n </span>\n </Primitives.Trigger>\n </>\n );\n}\n\nexport type SectionSummaryProps = Markup.SectionSummaryProps;\n\n/** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */\nexport function SectionSummary(props: SectionSummaryProps) {\n return (\n <Primitives.Fallback asChild>\n <Markup.SectionSummary {...props} />\n </Primitives.Fallback>\n );\n}\n\nexport type SectionContentProps = Markup.SectionContentProps;\n\n/** The section's content. Give it an id, which the button's `aria-controls` names. */\nexport function SectionContent(props: SectionContentProps) {\n return (\n <Primitives.Content asChild>\n <Markup.SectionContent {...props} />\n </Primitives.Content>\n );\n}\n\nexport type SectionCompositeProps = Omit<Markup.SectionCompositeProps, 'expanded'> & {\n /** Identifies the section in the accordion's `value`. Defaults to its content's id. */\n value?: string;\n /** Sets whether the section should be expanded when the page loads for the first time. Defaults to whether the accordion's value includes it. */\n expanded?: boolean;\n};\n\nexport function SectionComposite({\n accordionId,\n index,\n heading,\n summary,\n headingLevel,\n value,\n children,\n ...props\n}: SectionCompositeProps) {\n const contentId = `${accordionId}-content-${index}`;\n return (\n <Section value={value ?? contentId} {...props}>\n <Markup.SectionHeader>\n <Markup.SectionHeading headingLevel={headingLevel}>\n <SectionButton id={`${accordionId}-heading-${index}`} summary={summary}>\n {heading}\n </SectionButton>\n </Markup.SectionHeading>\n {hasContent(summary) && <SectionSummary id={`${accordionId}-summary-${index}`}>{summary}</SectionSummary>}\n </Markup.SectionHeader>\n <SectionContent id={contentId}>{children}</SectionContent>\n </Section>\n );\n}\n\nexport type CompositeProps = Omit<RootProps, 'id' | 'children'> &\n Pick<Markup.SectionHeadingProps, 'headingLevel'> & {\n /** Must be unique across the domain of your service if `rememberExpanded` is `true` (as the expanded state of individual instances of the component persists across page loads using [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)). Used as an `id` in the HTML for the accordion as a whole, and also as a prefix for the `id`s of the section contents and the buttons that open them, so that those `id`s can be the target of `aria-control` attributes. */\n id: string;\n } & (\n | { children?: ReactNode; sections?: never }\n | {\n children?: never;\n /** Prefer children, which memoise and re-render better. */\n sections: Omit<SectionCompositeProps, 'accordionId' | 'index' | 'headingLevel'>[];\n }\n );\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Composite({ id, headingLevel, sections, children, ...props }: CompositeProps) {\n return (\n <Root id={id} {...props}>\n <Controls />\n {sections\n ? sections.map((section, index) => (\n <SectionComposite key={index} accordionId={id} index={index + 1} headingLevel={headingLevel} {...section} />\n ))\n : children}\n </Root>\n );\n}\n\n// As govuk-frontend-react decides whether there is a summary.\nfunction hasContent(node: 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"]}
@@ -0,0 +1 @@
1
+ export { BackLink, type BackLinkProps } from 'govuk-frontend-react/back-link';
@@ -0,0 +1,2 @@
1
+ export { BackLink } from 'govuk-frontend-react/back-link';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/back-link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,gCAAgC,CAAC","sourcesContent":["export { BackLink, type BackLinkProps } from 'govuk-frontend-react/back-link';\n"]}
@@ -0,0 +1 @@
1
+ export { Body, type BodyProps } from 'govuk-frontend-react/body';
@@ -0,0 +1,2 @@
1
+ export { Body } from 'govuk-frontend-react/body';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/body/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,2BAA2B,CAAC","sourcesContent":["export { Body, type BodyProps } from 'govuk-frontend-react/body';\n"]}
@@ -0,0 +1 @@
1
+ export * from 'govuk-frontend-react/breadcrumbs';
@@ -0,0 +1,2 @@
1
+ export * from 'govuk-frontend-react/breadcrumbs';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/breadcrumbs/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/breadcrumbs';\n"]}
@@ -0,0 +1,24 @@
1
+ import type { ElementType, ReactNode } from 'react';
2
+ import { type ButtonLinkProps, type ButtonProps } from 'govuk-frontend-react/button';
3
+ export { StartButtonContent, StartButtonIcon } from 'govuk-frontend-react/button';
4
+ export type { ButtonLinkProps, ButtonProps, ButtonVariant, StartButtonIconProps } from 'govuk-frontend-react/button';
5
+ /**
6
+ * Use the button component to help users carry out an action.
7
+ *
8
+ * As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and
9
+ * Space activates a link button.
10
+ *
11
+ * @see https://design-system.service.gov.uk/components/button/
12
+ */
13
+ export declare function Button(props: ButtonLinkProps): ReactNode;
14
+ export declare function Button<As extends ElementType = 'button'>(props: ButtonProps<As>): ReactNode;
15
+ /**
16
+ * Use a start button for the main call to action on your service's start page.
17
+ *
18
+ * As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and
19
+ * Space activates a link button.
20
+ *
21
+ * @see https://design-system.service.gov.uk/components/button/#start-buttons
22
+ */
23
+ export declare function StartButton(props: Omit<ButtonLinkProps, 'start'>): ReactNode;
24
+ export declare function StartButton<As extends ElementType = 'button'>(props: Omit<ButtonProps<As>, 'start'>): ReactNode;
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import * as Primitives from '@govuk-react/primitives/button';
3
+ import { Button as MarkupButton, StartButton as MarkupStartButton, } from 'govuk-frontend-react/button';
4
+ export { StartButtonContent, StartButtonIcon } from 'govuk-frontend-react/button';
5
+ export function Button(props) {
6
+ return (
7
+ // Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.
8
+ React.createElement(Primitives.Root, { asChild: true, preventDoubleClick: props.href ? undefined : props.preventDoubleClick },
9
+ React.createElement(MarkupButton, { ...props })));
10
+ }
11
+ export function StartButton(props) {
12
+ return (
13
+ // Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.
14
+ React.createElement(Primitives.Root, { asChild: true, preventDoubleClick: props.href ? undefined : props.preventDoubleClick },
15
+ React.createElement(MarkupStartButton, { ...props })));
16
+ }
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,UAAU,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,WAAW,IAAI,iBAAiB,GAGjC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAalF,MAAM,UAAU,MAAM,CAAC,KAA+B;IACpD,OAAO;IACL,wGAAwG;IACxG,oBAAC,UAAU,CAAC,IAAI,IAAC,OAAO,QAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB;QAC5F,oBAAC,YAAY,OAAK,KAAK,GAAI,CACX,CACnB,CAAC;AACJ,CAAC;AAYD,MAAM,UAAU,WAAW,CAAC,KAA8C;IACxE,OAAO;IACL,wGAAwG;IACxG,oBAAC,UAAU,CAAC,IAAI,IAAC,OAAO,QAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB;QAC5F,oBAAC,iBAAiB,OAAK,KAAK,GAAI,CAChB,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ElementType, ReactNode } from 'react';\nimport * as Primitives from '@govuk-react/primitives/button';\nimport {\n Button as MarkupButton,\n StartButton as MarkupStartButton,\n type ButtonLinkProps,\n type ButtonProps,\n} from 'govuk-frontend-react/button';\n\nexport { StartButtonContent, StartButtonIcon } from 'govuk-frontend-react/button';\nexport type { ButtonLinkProps, ButtonProps, ButtonVariant, StartButtonIconProps } from 'govuk-frontend-react/button';\n\n/**\n * Use the button component to help users carry out an action.\n *\n * As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and\n * Space activates a link button.\n *\n * @see https://design-system.service.gov.uk/components/button/\n */\nexport function Button(props: ButtonLinkProps): ReactNode;\nexport function Button<As extends ElementType = 'button'>(props: ButtonProps<As>): ReactNode;\nexport function Button(props: ButtonProps<ElementType>) {\n return (\n // Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.\n <Primitives.Root asChild preventDoubleClick={props.href ? undefined : props.preventDoubleClick}>\n <MarkupButton {...props} />\n </Primitives.Root>\n );\n}\n\n/**\n * Use a start button for the main call to action on your service's start page.\n *\n * As in govuk-frontend, with `preventDoubleClick` a second click within a second is ignored, and\n * Space activates a link button.\n *\n * @see https://design-system.service.gov.uk/components/button/#start-buttons\n */\nexport function StartButton(props: Omit<ButtonLinkProps, 'start'>): ReactNode;\nexport function StartButton<As extends ElementType = 'button'>(props: Omit<ButtonProps<As>, 'start'>): ReactNode;\nexport function StartButton(props: Omit<ButtonProps<ElementType>, 'start'>) {\n return (\n // Covers `as` components too, which govuk-frontend-react doesn't mark. Links can't be double submitted.\n <Primitives.Root asChild preventDoubleClick={props.href ? undefined : props.preventDoubleClick}>\n <MarkupStartButton {...props} />\n </Primitives.Root>\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ export { Caption, type CaptionProps } from 'govuk-frontend-react/caption';
@@ -0,0 +1,2 @@
1
+ export { Caption } from 'govuk-frontend-react/caption';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/caption/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAqB,MAAM,8BAA8B,CAAC","sourcesContent":["export { Caption, type CaptionProps } from 'govuk-frontend-react/caption';\n"]}
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import * as Primitives from '@govuk-react/primitives/character-count';
3
+ import * as Markup from 'govuk-frontend-react/character-count';
4
+ export type RootProps = Markup.RootProps;
5
+ /**
6
+ * Tell users how many characters or words they can enter into a textarea.
7
+ *
8
+ * Wrap `Textarea`, `Message`, `Status` and `ScreenReaderStatus`, with the label, hint and error
9
+ * message.
10
+ *
11
+ * @see https://design-system.service.gov.uk/components/character-count/
12
+ */
13
+ export declare function Root({ maxLength, maxWords, threshold, countType, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, error, ...props }: RootProps): React.JSX.Element;
14
+ export type TextareaProps = Markup.TextareaProps;
15
+ /** The field. */
16
+ export declare function Textarea(props: TextareaProps): React.JSX.Element;
17
+ export type MessageProps = Markup.MessageProps;
18
+ /**
19
+ * The description, such as "You can enter up to 200 characters". Shown without JavaScript, and
20
+ * visually hidden once the count shows. Give it the field's id followed by `-info`, and add that to
21
+ * the field's `aria-describedby`.
22
+ */
23
+ export declare function Message(props: MessageProps): React.JSX.Element;
24
+ export type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;
25
+ /** The visible count, after `Message`. Shown once JavaScript runs. */
26
+ export declare function Status({ className, ...props }: StatusProps): React.JSX.Element;
27
+ export type ScreenReaderStatusProps = Omit<Primitives.ScreenReaderStatusProps, 'asChild'>;
28
+ /** The count for screen readers, after `Status`, once the user pauses typing. */
29
+ export declare function ScreenReaderStatus({ className, ...props }: ScreenReaderStatusProps): React.JSX.Element;
30
+ export type FieldProps = Markup.FieldProps;
31
+ /**
32
+ * Tell users how many characters or words they can enter into a textarea.
33
+ *
34
+ * @see https://design-system.service.gov.uk/components/character-count/
35
+ */
36
+ export declare function Field({ id: idProp, name, label, labelSize, labelIsPageHeading, hint, errorMessage, maxLength, maxWords, threshold, countType, textareaDescriptionText, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, 'aria-describedby': describedBy, ...props }: FieldProps): React.JSX.Element;