@scottish-government/designsystem-react 0.12.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (490) hide show
  1. package/.storybook/main.ts +6 -6
  2. package/.storybook/sgdsArgTypes.ts +107 -43
  3. package/CHANGELOG.md +49 -0
  4. package/LICENSE.txt +21 -0
  5. package/README.md +3 -0
  6. package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.d.ts +3 -2
  7. package/dist/common/AbstractNotificationBanner/AbstractNotificationBanner.jsx +8 -7
  8. package/dist/common/AbstractNotificationBanner/types.d.ts +13 -0
  9. package/dist/common/AbstractNotificationBanner/types.js +2 -0
  10. package/dist/common/ActionLink/ActionLink.d.ts +2 -1
  11. package/dist/common/ActionLink/types.d.ts +7 -0
  12. package/dist/common/ActionLink/types.js +2 -0
  13. package/dist/common/ConditionalWrapper/ConditionalWrapper.d.ts +2 -1
  14. package/dist/common/ConditionalWrapper/ConditionalWrapper.jsx +4 -2
  15. package/dist/common/ConditionalWrapper/types.d.ts +4 -0
  16. package/dist/common/ConditionalWrapper/types.js +2 -0
  17. package/dist/common/FileIcon/FileIcon.d.ts +2 -1
  18. package/dist/common/FileIcon/types.d.ts +6 -0
  19. package/dist/common/FileIcon/types.js +2 -0
  20. package/dist/common/HintText/HintText.d.ts +2 -1
  21. package/dist/common/HintText/HintText.jsx +3 -3
  22. package/dist/common/HintText/types.d.ts +4 -0
  23. package/dist/common/HintText/types.js +2 -0
  24. package/dist/common/Icon/Icon.d.ts +2 -1
  25. package/dist/common/Icon/Icon.jsx +3 -2
  26. package/dist/common/Icon/types.d.ts +8 -0
  27. package/dist/common/Icon/types.js +2 -0
  28. package/dist/common/ScreenReaderText/ScreenReaderText.d.ts +1 -1
  29. package/dist/common/WrapperTag/WrapperTag.d.ts +385 -1
  30. package/dist/common/WrapperTag/WrapperTag.jsx +5 -2
  31. package/dist/common/WrapperTag/types.d.ts +3 -0
  32. package/dist/common/WrapperTag/types.js +2 -0
  33. package/dist/components/Accordion/Accordion.d.ts +3 -2
  34. package/dist/components/Accordion/Accordion.jsx +12 -11
  35. package/dist/components/Accordion/types.d.ts +11 -0
  36. package/dist/components/Accordion/types.js +2 -0
  37. package/dist/components/AspectBox/AspectBox.d.ts +2 -1
  38. package/dist/components/AspectBox/AspectBox.jsx +3 -9
  39. package/dist/components/AspectBox/types.d.ts +3 -0
  40. package/dist/components/AspectBox/types.js +2 -0
  41. package/dist/components/BackToTop/BackToTop.d.ts +2 -1
  42. package/dist/components/BackToTop/BackToTop.jsx +4 -3
  43. package/dist/components/BackToTop/types.d.ts +3 -0
  44. package/dist/components/BackToTop/types.js +2 -0
  45. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -2
  46. package/dist/components/Breadcrumbs/Breadcrumbs.jsx +6 -2
  47. package/dist/components/Breadcrumbs/types.d.ts +5 -0
  48. package/dist/components/Breadcrumbs/types.js +2 -0
  49. package/dist/components/Button/Button.d.ts +2 -1
  50. package/dist/components/Button/Button.jsx +4 -3
  51. package/dist/components/Button/ButtonGroup.d.ts +2 -1
  52. package/dist/components/Button/ButtonGroup.jsx +9 -4
  53. package/dist/components/Button/types.d.ts +20 -0
  54. package/dist/components/Button/types.js +2 -0
  55. package/dist/components/Card/Card.d.ts +34 -0
  56. package/dist/components/Card/Card.jsx +118 -0
  57. package/dist/components/Card/index.d.ts +1 -0
  58. package/dist/components/Card/index.js +8 -0
  59. package/dist/components/Card/types.d.ts +26 -0
  60. package/dist/components/Card/types.js +2 -0
  61. package/dist/components/CategoryItem/CategoryItem.d.ts +2 -1
  62. package/dist/components/CategoryItem/CategoryItem.jsx +8 -5
  63. package/dist/components/CategoryItem/types.d.ts +9 -0
  64. package/dist/components/CategoryItem/types.js +2 -0
  65. package/dist/components/CategoryList/CategoryList.d.ts +2 -1
  66. package/dist/components/CategoryList/CategoryList.jsx +3 -2
  67. package/dist/components/CategoryList/types.d.ts +5 -0
  68. package/dist/components/CategoryList/types.js +2 -0
  69. package/dist/components/Checkbox/Checkbox.d.ts +2 -1
  70. package/dist/components/Checkbox/Checkbox.jsx +4 -3
  71. package/dist/components/Checkbox/CheckboxGroup.d.ts +2 -1
  72. package/dist/components/Checkbox/CheckboxGroup.jsx +5 -4
  73. package/dist/components/Checkbox/types.d.ts +7 -0
  74. package/dist/components/Checkbox/types.js +2 -0
  75. package/dist/components/ConfirmationMessage/ConfirmationMessage.d.ts +2 -1
  76. package/dist/components/ConfirmationMessage/ConfirmationMessage.jsx +3 -2
  77. package/dist/components/ConfirmationMessage/types.d.ts +6 -0
  78. package/dist/components/ConfirmationMessage/types.js +2 -0
  79. package/dist/components/ContentsNav/ContentsNav.d.ts +3 -2
  80. package/dist/components/ContentsNav/ContentsNav.jsx +7 -5
  81. package/dist/components/ContentsNav/types.d.ts +9 -0
  82. package/dist/components/ContentsNav/types.js +2 -0
  83. package/dist/components/CookieBanner/CookieBanner.d.ts +3 -2
  84. package/dist/components/CookieBanner/CookieBanner.jsx +13 -3
  85. package/dist/components/DatePicker/DatePicker.d.ts +2 -1
  86. package/dist/components/DatePicker/DatePicker.jsx +7 -7
  87. package/dist/components/DatePicker/types.d.ts +18 -0
  88. package/dist/components/DatePicker/types.js +2 -0
  89. package/dist/components/Details/Details.d.ts +2 -1
  90. package/dist/components/Details/Details.jsx +6 -2
  91. package/dist/components/Details/types.d.ts +4 -0
  92. package/dist/components/Details/types.js +2 -0
  93. package/dist/components/ErrorMessage/ErrorMessage.d.ts +2 -1
  94. package/dist/components/ErrorMessage/ErrorMessage.jsx +6 -2
  95. package/dist/components/ErrorMessage/types.d.ts +3 -0
  96. package/dist/components/ErrorMessage/types.js +2 -0
  97. package/dist/components/ErrorSummary/ErrorSummary.d.ts +3 -2
  98. package/dist/components/ErrorSummary/ErrorSummary.jsx +6 -2
  99. package/dist/components/ErrorSummary/types.d.ts +8 -0
  100. package/dist/components/ErrorSummary/types.js +2 -0
  101. package/dist/components/FeatureHeader/FeatureHeader.d.ts +7 -5
  102. package/dist/components/FeatureHeader/FeatureHeader.jsx +87 -50
  103. package/dist/components/FeatureHeader/types.d.ts +12 -0
  104. package/dist/components/FeatureHeader/types.js +2 -0
  105. package/dist/components/FileDownload/FileDownload.d.ts +2 -1
  106. package/dist/components/FileDownload/FileDownload.jsx +4 -3
  107. package/dist/components/FileDownload/types.d.ts +10 -0
  108. package/dist/components/FileDownload/types.js +2 -0
  109. package/dist/components/HideThisPage/HideThisPage.d.ts +2 -1
  110. package/dist/components/HideThisPage/HideThisPage.jsx +5 -4
  111. package/dist/components/HideThisPage/types.d.ts +3 -0
  112. package/dist/components/HideThisPage/types.js +2 -0
  113. package/dist/components/InsetText/InsetText.d.ts +1 -1
  114. package/dist/components/InsetText/InsetText.jsx +6 -2
  115. package/dist/components/NotificationBanner/NotificationBanner.d.ts +3 -2
  116. package/dist/components/NotificationBanner/NotificationBanner.jsx +5 -4
  117. package/dist/components/NotificationPanel/NotificationPanel.d.ts +2 -1
  118. package/dist/components/NotificationPanel/NotificationPanel.jsx +3 -2
  119. package/dist/components/NotificationPanel/types.d.ts +6 -0
  120. package/dist/components/NotificationPanel/types.js +2 -0
  121. package/dist/components/NotificationTag/NotificationTag.d.ts +6 -0
  122. package/dist/components/NotificationTag/NotificationTag.jsx +20 -0
  123. package/dist/components/NotificationTag/index.d.ts +1 -0
  124. package/dist/components/NotificationTag/index.js +8 -0
  125. package/dist/components/NotificationTag/types.d.ts +5 -0
  126. package/dist/components/NotificationTag/types.js +2 -0
  127. package/dist/components/PageHeader/PageHeader.d.ts +2 -1
  128. package/dist/components/PageHeader/PageHeader.jsx +6 -2
  129. package/dist/components/PageHeader/types.d.ts +5 -0
  130. package/dist/components/PageHeader/types.js +2 -0
  131. package/dist/components/PageMetadata/PageMetadata.d.ts +3 -2
  132. package/dist/components/PageMetadata/PageMetadata.jsx +8 -4
  133. package/dist/components/PageMetadata/types.d.ts +6 -0
  134. package/dist/components/PageMetadata/types.js +2 -0
  135. package/dist/components/Pagination/Pagination.d.ts +3 -2
  136. package/dist/components/Pagination/Pagination.jsx +7 -5
  137. package/dist/components/Pagination/types.d.ts +18 -0
  138. package/dist/components/Pagination/types.js +2 -0
  139. package/dist/components/PhaseBanner/PhaseBanner.d.ts +2 -1
  140. package/dist/components/PhaseBanner/PhaseBanner.jsx +3 -2
  141. package/dist/components/PhaseBanner/types.d.ts +3 -0
  142. package/dist/components/PhaseBanner/types.js +2 -0
  143. package/dist/components/Question/Question.d.ts +2 -1
  144. package/dist/components/Question/Question.jsx +4 -3
  145. package/dist/components/Question/types.d.ts +9 -0
  146. package/dist/components/Question/types.js +2 -0
  147. package/dist/components/RadioButton/RadioButton.d.ts +2 -1
  148. package/dist/components/RadioButton/RadioButton.jsx +4 -3
  149. package/dist/components/RadioButton/RadioGroup.d.ts +2 -1
  150. package/dist/components/RadioButton/RadioGroup.jsx +3 -2
  151. package/dist/components/RadioButton/types.d.ts +10 -0
  152. package/dist/components/RadioButton/types.js +2 -0
  153. package/dist/components/SearchFacets/SearchFacets.d.ts +4 -3
  154. package/dist/components/SearchFacets/SearchFacets.jsx +3 -2
  155. package/dist/components/SearchFacets/types.d.ts +12 -0
  156. package/dist/components/SearchFacets/types.js +2 -0
  157. package/dist/components/SearchFilters/SearchFilters.d.ts +5 -4
  158. package/dist/components/SearchFilters/types.d.ts +12 -0
  159. package/dist/components/SearchFilters/types.js +2 -0
  160. package/dist/components/SearchResult/SearchResult.d.ts +8 -11
  161. package/dist/components/SearchResult/SearchResult.jsx +6 -7
  162. package/dist/components/SearchResult/types.d.ts +11 -0
  163. package/dist/components/SearchResult/types.js +2 -0
  164. package/dist/components/SearchSort/SearchSort.d.ts +2 -1
  165. package/dist/components/SearchSort/SearchSort.jsx +3 -2
  166. package/dist/components/SearchSort/types.d.ts +7 -0
  167. package/dist/components/SearchSort/types.js +2 -0
  168. package/dist/components/Select/Select.d.ts +2 -1
  169. package/dist/components/Select/Select.jsx +4 -3
  170. package/dist/components/Select/types.d.ts +6 -0
  171. package/dist/components/Select/types.js +2 -0
  172. package/dist/components/SequentialNavigation/SequentialNavigation.d.ts +4 -3
  173. package/dist/components/SequentialNavigation/SequentialNavigation.jsx +10 -6
  174. package/dist/components/SequentialNavigation/types.d.ts +10 -0
  175. package/dist/components/SequentialNavigation/types.js +2 -0
  176. package/dist/components/SideNavigation/SideNavigation.d.ts +4 -3
  177. package/dist/components/SideNavigation/SideNavigation.jsx +10 -7
  178. package/dist/components/SideNavigation/types.d.ts +13 -0
  179. package/dist/components/SideNavigation/types.js +2 -0
  180. package/dist/components/SiteFooter/SiteFooter.d.ts +6 -5
  181. package/dist/components/SiteFooter/SiteFooter.jsx +4 -3
  182. package/dist/components/SiteFooter/types.d.ts +16 -0
  183. package/dist/components/SiteFooter/types.js +2 -0
  184. package/dist/components/SiteHeader/SiteHeader.d.ts +6 -5
  185. package/dist/components/SiteHeader/SiteHeader.jsx +1 -1
  186. package/dist/components/SiteHeader/types.d.ts +20 -0
  187. package/dist/components/SiteHeader/types.js +2 -0
  188. package/dist/components/SiteNavigation/SiteNavigation.d.ts +3 -2
  189. package/dist/components/SiteNavigation/SiteNavigation.jsx +12 -4
  190. package/dist/components/SiteNavigation/types.d.ts +9 -0
  191. package/dist/components/SiteNavigation/types.js +2 -0
  192. package/dist/components/SiteSearch/SiteSearch.d.ts +2 -1
  193. package/dist/components/SiteSearch/SiteSearch.jsx +12 -11
  194. package/dist/components/SiteSearch/types.d.ts +17 -0
  195. package/dist/components/SiteSearch/types.js +2 -0
  196. package/dist/components/SkipLinks/SkipLinks.d.ts +3 -2
  197. package/dist/components/SkipLinks/SkipLinks.jsx +4 -4
  198. package/dist/components/SkipLinks/types.d.ts +8 -0
  199. package/dist/components/SkipLinks/types.js +2 -0
  200. package/dist/components/SummaryCard/SummaryCard.d.ts +4 -2
  201. package/dist/components/SummaryCard/SummaryCard.jsx +5 -4
  202. package/dist/components/SummaryCard/types.d.ts +5 -0
  203. package/dist/components/SummaryCard/types.js +2 -0
  204. package/dist/components/SummaryList/SummaryList.d.ts +6 -4
  205. package/dist/components/SummaryList/SummaryList.jsx +5 -4
  206. package/dist/components/SummaryList/types.d.ts +6 -0
  207. package/dist/components/SummaryList/types.js +2 -0
  208. package/dist/components/Table/Table.d.ts +2 -1
  209. package/dist/components/Table/Table.jsx +5 -4
  210. package/dist/components/Table/types.d.ts +6 -0
  211. package/dist/components/Table/types.js +2 -0
  212. package/dist/components/Tabs/Tabs.d.ts +3 -2
  213. package/dist/components/Tabs/Tabs.jsx +6 -5
  214. package/dist/components/Tabs/types.d.ts +16 -0
  215. package/dist/components/Tabs/types.js +2 -0
  216. package/dist/components/Tag/Tag.d.ts +2 -1
  217. package/dist/components/Tag/Tag.jsx +7 -3
  218. package/dist/components/Tag/types.d.ts +4 -0
  219. package/dist/components/Tag/types.js +2 -0
  220. package/dist/components/TaskList/TaskList.d.ts +4 -3
  221. package/dist/components/TaskList/TaskList.jsx +11 -8
  222. package/dist/components/TaskList/types.d.ts +17 -0
  223. package/dist/components/TaskList/types.js +2 -0
  224. package/dist/components/TextInput/TextInput.d.ts +2 -1
  225. package/dist/components/TextInput/TextInput.jsx +10 -9
  226. package/dist/components/TextInput/types.d.ts +11 -0
  227. package/dist/components/TextInput/types.js +2 -0
  228. package/dist/components/Textarea/Textarea.d.ts +2 -1
  229. package/dist/components/Textarea/Textarea.jsx +6 -5
  230. package/dist/components/WarningText/WarningText.d.ts +1 -1
  231. package/dist/components/WarningText/WarningText.jsx +6 -2
  232. package/dist/hooks/useTracking/useTracking.js +0 -1
  233. package/eslint.config.mjs +32 -0
  234. package/package.json +12 -5
  235. package/src/common/AbstractNotificationBanner/AbstractNotificationBanner.tsx +13 -10
  236. package/src/common/AbstractNotificationBanner/types.ts +15 -0
  237. package/src/common/ActionLink/ActionLink.tsx +3 -1
  238. package/src/common/ActionLink/types.ts +8 -0
  239. package/src/common/ConditionalWrapper/ConditionalWrapper.tsx +10 -2
  240. package/src/common/ConditionalWrapper/types.ts +4 -0
  241. package/src/common/FileIcon/FileIcon.tsx +2 -1
  242. package/src/common/FileIcon/types.ts +7 -0
  243. package/src/common/HintText/HintText.test.tsx +3 -15
  244. package/src/common/HintText/HintText.tsx +4 -4
  245. package/src/common/HintText/types.ts +4 -0
  246. package/src/common/Icon/Icon.tsx +5 -3
  247. package/src/common/Icon/types.ts +9 -0
  248. package/src/common/ScreenReaderText/ScreenReaderText.tsx +1 -1
  249. package/src/common/WrapperTag/WrapperTag.tsx +5 -3
  250. package/src/common/WrapperTag/types.ts +3 -0
  251. package/src/components/Accordion/Accordion.Item.stories.tsx +1 -5
  252. package/src/components/Accordion/Accordion.stories.tsx +5 -5
  253. package/src/components/Accordion/Accordion.test.tsx +11 -0
  254. package/src/components/Accordion/Accordion.tsx +15 -13
  255. package/src/components/Accordion/types.ts +13 -0
  256. package/src/components/AspectBox/AspectBox.stories.tsx +1 -2
  257. package/src/components/AspectBox/AspectBox.tsx +8 -14
  258. package/src/components/AspectBox/types.ts +3 -0
  259. package/src/components/BackToTop/BackToTop.test.tsx +21 -1
  260. package/src/components/BackToTop/BackToTop.tsx +6 -4
  261. package/src/components/BackToTop/types.ts +3 -0
  262. package/src/components/Breadcrumbs/Breadcrumbs.tsx +7 -4
  263. package/src/components/Breadcrumbs/types.ts +6 -0
  264. package/src/components/Button/Button.tsx +6 -4
  265. package/src/components/Button/ButtonGroup.stories.tsx +22 -0
  266. package/src/components/Button/ButtonGroup.test.tsx +21 -0
  267. package/src/components/Button/ButtonGroup.tsx +9 -4
  268. package/src/components/Button/types.ts +22 -0
  269. package/src/components/Card/Card.stories.tsx +446 -0
  270. package/src/components/Card/Card.test.tsx +282 -0
  271. package/src/components/Card/Card.tsx +208 -0
  272. package/src/components/Card/index.ts +1 -0
  273. package/src/components/Card/types.ts +30 -0
  274. package/src/components/CategoryItem/CategoryItem.tsx +10 -6
  275. package/src/components/CategoryItem/types.ts +10 -0
  276. package/src/components/CategoryList/CategoryList.tsx +7 -4
  277. package/src/components/CategoryList/types.ts +5 -0
  278. package/src/components/Checkbox/Checkbox.stories.tsx +3 -3
  279. package/src/components/Checkbox/Checkbox.test.tsx +30 -0
  280. package/src/components/Checkbox/Checkbox.tsx +8 -7
  281. package/src/components/Checkbox/CheckboxGroup.test.tsx +10 -0
  282. package/src/components/Checkbox/CheckboxGroup.tsx +7 -6
  283. package/src/components/Checkbox/types.ts +9 -0
  284. package/src/components/ConfirmationMessage/ConfirmationMessage.tsx +5 -3
  285. package/src/components/ConfirmationMessage/types.ts +7 -0
  286. package/src/components/ContentsNav/ContentsNav.stories.tsx +5 -1
  287. package/src/components/ContentsNav/ContentsNav.tsx +11 -7
  288. package/src/components/ContentsNav/types.ts +11 -0
  289. package/src/components/CookieBanner/CookieBanner.Buttons.stories.tsx +3 -3
  290. package/src/components/CookieBanner/CookieBanner.stories.tsx +6 -6
  291. package/src/components/CookieBanner/CookieBanner.test.tsx +24 -1
  292. package/src/components/CookieBanner/CookieBanner.tsx +16 -5
  293. package/src/components/DatePicker/DatePicker.test.tsx +52 -19
  294. package/src/components/DatePicker/DatePicker.tsx +8 -8
  295. package/src/components/DatePicker/types.ts +19 -0
  296. package/src/components/Details/Details.stories.tsx +1 -1
  297. package/src/components/Details/Details.tsx +6 -3
  298. package/src/components/Details/types.ts +4 -0
  299. package/src/components/ErrorMessage/ErrorMessage.tsx +6 -3
  300. package/src/components/ErrorMessage/types.ts +3 -0
  301. package/src/components/ErrorSummary/ErrorSummary.test.tsx +1 -1
  302. package/src/components/ErrorSummary/ErrorSummary.tsx +6 -4
  303. package/src/components/ErrorSummary/types.ts +11 -0
  304. package/src/components/FeatureHeader/FeatureHeader.stories.tsx +186 -23
  305. package/src/components/FeatureHeader/FeatureHeader.test.tsx +298 -0
  306. package/src/components/FeatureHeader/FeatureHeader.tsx +83 -58
  307. package/src/components/FeatureHeader/types.ts +13 -0
  308. package/src/components/FileDownload/FileDownload.test.tsx +1 -5
  309. package/src/components/FileDownload/FileDownload.tsx +6 -4
  310. package/src/components/FileDownload/types.ts +11 -0
  311. package/src/components/HideThisPage/HideThisPage.test.tsx +12 -1
  312. package/src/components/HideThisPage/HideThisPage.tsx +7 -5
  313. package/src/components/HideThisPage/types.ts +3 -0
  314. package/src/components/InsetText/InsetText.tsx +5 -3
  315. package/src/components/NotificationBanner/NotificationBanner.stories.tsx +2 -2
  316. package/src/components/NotificationBanner/NotificationBanner.test.tsx +10 -0
  317. package/src/components/NotificationBanner/NotificationBanner.tsx +8 -6
  318. package/src/components/NotificationPanel/NotificationPanel.tsx +5 -3
  319. package/src/components/NotificationPanel/types.ts +7 -0
  320. package/src/components/NotificationTag/NotificationTag.stories.tsx +68 -0
  321. package/src/components/NotificationTag/NotificationTag.test.tsx +70 -0
  322. package/src/components/NotificationTag/NotificationTag.tsx +32 -0
  323. package/src/components/NotificationTag/index.ts +1 -0
  324. package/src/components/NotificationTag/types.ts +5 -0
  325. package/src/components/PageHeader/PageHeader.tsx +6 -3
  326. package/src/components/PageHeader/types.ts +5 -0
  327. package/src/components/PageMetadata/PageMetadata.stories.tsx +1 -1
  328. package/src/components/PageMetadata/PageMetadata.tsx +10 -7
  329. package/src/components/PageMetadata/types.ts +7 -0
  330. package/src/components/Pagination/Pagination.test.tsx +20 -0
  331. package/src/components/Pagination/Pagination.tsx +12 -8
  332. package/src/components/Pagination/types.ts +20 -0
  333. package/src/components/PhaseBanner/PhaseBanner.stories.tsx +1 -4
  334. package/src/components/PhaseBanner/PhaseBanner.tsx +5 -3
  335. package/src/components/PhaseBanner/types.ts +3 -0
  336. package/src/components/Question/Question.tsx +6 -4
  337. package/src/components/Question/types.ts +9 -0
  338. package/src/components/RadioButton/RadioButton.test.tsx +30 -0
  339. package/src/components/RadioButton/RadioButton.tsx +8 -7
  340. package/src/components/RadioButton/RadioGroup.tsx +5 -3
  341. package/src/components/RadioButton/types.ts +12 -0
  342. package/src/components/SearchFacets/SearchFacets.Group.stories.tsx +2 -3
  343. package/src/components/SearchFacets/SearchFacets.stories.tsx +2 -2
  344. package/src/components/SearchFacets/SearchFacets.tsx +10 -8
  345. package/src/components/SearchFacets/types.ts +14 -0
  346. package/src/components/SearchFilters/SearchFilters.Panel.stories.tsx +18 -7
  347. package/src/components/SearchFilters/SearchFilters.stories.tsx +1 -1
  348. package/src/components/SearchFilters/SearchFilters.tsx +4 -3
  349. package/src/components/SearchFilters/types.ts +14 -0
  350. package/src/components/SearchResult/SearchResult.stories.tsx +23 -23
  351. package/src/components/SearchResult/SearchResult.test.tsx +5 -4
  352. package/src/components/SearchResult/SearchResult.tsx +15 -15
  353. package/src/components/SearchResult/types.ts +13 -0
  354. package/src/components/SearchSort/SearchSort.stories.tsx +2 -1
  355. package/src/components/SearchSort/SearchSort.tsx +5 -3
  356. package/src/components/SearchSort/types.ts +7 -0
  357. package/src/components/Select/Select.test.tsx +42 -0
  358. package/src/components/Select/Select.tsx +8 -6
  359. package/src/components/Select/types.ts +7 -0
  360. package/src/components/SequentialNavigation/SequentialNavigation.tsx +13 -10
  361. package/src/components/SequentialNavigation/types.ts +12 -0
  362. package/src/components/SideNavigation/SideNavigation.test.tsx +24 -0
  363. package/src/components/SideNavigation/SideNavigation.tsx +14 -10
  364. package/src/components/SideNavigation/types.ts +16 -0
  365. package/src/components/SiteFooter/SiteFooter.tsx +10 -8
  366. package/src/components/SiteFooter/types.ts +20 -0
  367. package/src/components/SiteHeader/SiteHeader.stories.tsx +4 -3
  368. package/src/components/SiteHeader/SiteHeader.test.tsx +29 -16
  369. package/src/components/SiteHeader/SiteHeader.tsx +10 -9
  370. package/src/components/SiteHeader/types.ts +22 -0
  371. package/src/components/SiteNavigation/SiteNavigation.test.tsx +16 -1
  372. package/src/components/SiteNavigation/SiteNavigation.tsx +13 -6
  373. package/src/components/SiteNavigation/types.ts +11 -0
  374. package/src/components/SiteSearch/SiteSearch.stories.tsx +4 -2
  375. package/src/components/SiteSearch/SiteSearch.test.tsx +22 -0
  376. package/src/components/SiteSearch/SiteSearch.tsx +15 -13
  377. package/src/components/SiteSearch/types.ts +19 -0
  378. package/src/components/SkipLinks/SkipLinks.stories.tsx +3 -3
  379. package/src/components/SkipLinks/SkipLinks.tsx +7 -7
  380. package/src/components/SkipLinks/types.ts +9 -0
  381. package/src/components/SummaryCard/SummaryCard.test.tsx +0 -11
  382. package/src/components/SummaryCard/SummaryCard.tsx +9 -6
  383. package/src/components/SummaryCard/types.ts +6 -0
  384. package/src/components/SummaryList/SummaryList.Item.stories.tsx +5 -5
  385. package/src/components/SummaryList/SummaryList.stories.tsx +1 -1
  386. package/src/components/SummaryList/SummaryList.test.tsx +1 -6
  387. package/src/components/SummaryList/SummaryList.tsx +11 -9
  388. package/src/components/SummaryList/types.ts +7 -0
  389. package/src/components/Table/Table.test.tsx +36 -0
  390. package/src/components/Table/Table.tsx +7 -5
  391. package/src/components/Table/types.ts +6 -0
  392. package/src/components/Tabs/Tabs.Item.stories.tsx +7 -7
  393. package/src/components/Tabs/Tabs.stories.tsx +3 -3
  394. package/src/components/Tabs/Tabs.test.tsx +14 -0
  395. package/src/components/Tabs/Tabs.tsx +12 -9
  396. package/src/components/Tabs/types.ts +19 -0
  397. package/src/components/Tag/Tag.tsx +7 -4
  398. package/src/components/Tag/types.ts +5 -0
  399. package/src/components/TaskList/TaskList.Group.stories.tsx +0 -5
  400. package/src/components/TaskList/TaskList.stories.tsx +0 -1
  401. package/src/components/TaskList/TaskList.tsx +17 -13
  402. package/src/components/TaskList/types.ts +20 -0
  403. package/src/components/TextInput/TextInput.test.tsx +53 -1
  404. package/src/components/TextInput/TextInput.tsx +17 -12
  405. package/src/components/TextInput/types.ts +12 -0
  406. package/src/components/Textarea/Textarea.test.tsx +53 -1
  407. package/src/components/Textarea/Textarea.tsx +10 -8
  408. package/src/components/WarningText/WarningText.tsx +5 -3
  409. package/src/hooks/useTracking/useTracking.test.tsx +5 -7
  410. package/src/hooks/useTracking/useTracking.ts +0 -1
  411. package/src/images/icons/arrow_upward.tsx +10 -10
  412. package/src/images/icons/calendar_today.tsx +10 -10
  413. package/src/images/icons/cancel.tsx +8 -8
  414. package/src/images/icons/check_circle.tsx +10 -10
  415. package/src/images/icons/chevron_left.tsx +10 -10
  416. package/src/images/icons/chevron_right.tsx +10 -10
  417. package/src/images/icons/close.tsx +10 -10
  418. package/src/images/icons/description.tsx +10 -10
  419. package/src/images/icons/double_chevron_left.tsx +8 -8
  420. package/src/images/icons/double_chevron_right.tsx +8 -8
  421. package/src/images/icons/error.tsx +10 -10
  422. package/src/images/icons/expand_less.tsx +10 -10
  423. package/src/images/icons/expand_more.tsx +10 -10
  424. package/src/images/icons/list.tsx +13 -13
  425. package/src/images/icons/menu.tsx +10 -10
  426. package/src/images/icons/priority_high.tsx +11 -11
  427. package/src/images/icons/search.tsx +10 -10
  428. package/src/shared-types.ts +40 -0
  429. package/static/images/illustration.svg +502 -0
  430. package/tsconfig.json +0 -3
  431. package/vite.config.ts +6 -1
  432. package/@types/common/AbstractNotificationBanner.d.ts +0 -17
  433. package/@types/common/ActionLink.d.ts +0 -8
  434. package/@types/common/ConditionalWrapper.d.ts +0 -6
  435. package/@types/common/FileIcon.d.ts +0 -7
  436. package/@types/common/HintText.d.ts +0 -6
  437. package/@types/common/Icon.d.ts +0 -9
  438. package/@types/common/ScreenReaderText.d.ts +0 -4
  439. package/@types/common/WrapperTag.d.ts +0 -5
  440. package/@types/components/Accordion.d.ts +0 -15
  441. package/@types/components/AspectBox.d.ts +0 -5
  442. package/@types/components/BackToTop.d.ts +0 -5
  443. package/@types/components/Breadcrumbs.d.ts +0 -11
  444. package/@types/components/Button.d.ts +0 -17
  445. package/@types/components/ButtonGroup.d.ts +0 -5
  446. package/@types/components/CategoryItem.d.ts +0 -10
  447. package/@types/components/CategoryList.d.ts +0 -7
  448. package/@types/components/Checkbox.d.ts +0 -11
  449. package/@types/components/ConfirmationMessage.d.ts +0 -7
  450. package/@types/components/ContentsNav.d.ts +0 -13
  451. package/@types/components/DatePicker.d.ts +0 -20
  452. package/@types/components/Details.d.ts +0 -6
  453. package/@types/components/ErrorMessage.d.ts +0 -5
  454. package/@types/components/ErrorSummary.d.ts +0 -12
  455. package/@types/components/FileDownload.d.ts +0 -11
  456. package/@types/components/HideThisPage.d.ts +0 -5
  457. package/@types/components/InsetText.d.ts +0 -5
  458. package/@types/components/Metadata.d.ts +0 -11
  459. package/@types/components/NotificationPanel.d.ts +0 -7
  460. package/@types/components/PageHeader.d.ts +0 -7
  461. package/@types/components/Pagination.d.ts +0 -22
  462. package/@types/components/PhaseBanner.d.ts +0 -5
  463. package/@types/components/Question.d.ts +0 -11
  464. package/@types/components/RadioButton.d.ts +0 -14
  465. package/@types/components/SearchFacets.d.ts +0 -18
  466. package/@types/components/SearchFilters.d.ts +0 -14
  467. package/@types/components/SearchResult.d.ts +0 -30
  468. package/@types/components/SearchSort.d.ts +0 -9
  469. package/@types/components/Select.d.ts +0 -7
  470. package/@types/components/SequentialNavigation.d.ts +0 -14
  471. package/@types/components/SideNavigation.d.ts +0 -18
  472. package/@types/components/SiteFooter.d.ts +0 -25
  473. package/@types/components/SiteHeader.d.ts +0 -20
  474. package/@types/components/SiteNavigation.d.ts +0 -13
  475. package/@types/components/SiteSearch.d.ts +0 -14
  476. package/@types/components/SkipLinks.d.ts +0 -13
  477. package/@types/components/SummaryCard.d.ts +0 -6
  478. package/@types/components/SummaryList.d.ts +0 -14
  479. package/@types/components/Table.d.ts +0 -8
  480. package/@types/components/Tabs.d.ts +0 -21
  481. package/@types/components/Tag.d.ts +0 -5
  482. package/@types/components/TaskList.d.ts +0 -22
  483. package/@types/components/TextInput.d.ts +0 -12
  484. package/@types/components/Textarea.d.ts +0 -4
  485. package/@types/components/WarningText.d.ts +0 -5
  486. package/@types/global.d.ts +0 -1
  487. package/@types/sgds.d.ts +0 -49
  488. package/dist/index.d.ts +0 -4
  489. package/dist/index.js +0 -40
  490. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,20 @@
1
+ import { LinkComponent } from "../../shared-types";
2
+
3
+ export interface SiteFooterLinkProps extends React.AllHTMLAttributes<HTMLLIElement> {
4
+ href?: string;
5
+ linkComponent?: LinkComponent;
6
+ }
7
+
8
+ export interface SiteFooterLicenseProps extends React.AllHTMLAttributes<HTMLDivElement> {
9
+ href?: string;
10
+ logoSrc?: string;
11
+ }
12
+
13
+ export interface SiteFooterOrgProps extends React.AllHTMLAttributes<HTMLDivElement> {
14
+ href?: string;
15
+ title: string;
16
+ }
17
+
18
+ export interface SiteFooterProps extends React.AllHTMLAttributes<HTMLElement> {
19
+ className?: string;
20
+ }
@@ -17,6 +17,7 @@ const meta = {
17
17
  <SiteHeader.Brand
18
18
  homeUrl="/"
19
19
  siteTitle="Design System React"
20
+ key="1"
20
21
  >
21
22
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 206.7 30.7">
22
23
  <title>The Scottish Government</title>
@@ -26,7 +27,7 @@ const meta = {
26
27
  <path fill="#333e48" d="M205.1 12.8c.8 0 1.3-.2 1.6-.5l-.4-1.3c-.1.2-.4.3-.8.3-.5 0-.8-.4-.8-1V6.1h1.6V4.6h-1.6V2.3H203v2.2h-1.3V6h1.3v4.7c0 1.4.7 2.1 2.1 2.1m-4.7-.2V6.9c0-1.7-.9-2.6-2.6-2.6-1.3 0-2.3.7-2.9 1.3v-1h-1.8v8.1h1.8V7c.4-.5 1.2-1.1 2.1-1.1 1 0 1.6.4 1.6 1.7v5.1h1.8zm-10.5-4.7h-4.5c.1-1 .8-2.1 2.3-2.1 1.5 0 2.1 1.2 2.2 2.1m-2.2 4.9c1.3 0 2.5-.4 3.3-1.2l-.8-1.2c-.6.6-1.5.9-2.3.9-1.5 0-2.4-1-2.6-2.2h6.2v-.4c0-2.5-1.5-4.4-4-4.4a4 4 0 0 0-4.1 4.2c.1 2.6 1.9 4.3 4.3 4.3m-5.9-.2V6.8c0-1.6-.9-2.4-2.3-2.4-1.2 0-2.3.8-2.7 1.5-.3-.9-1-1.5-2.2-1.5-1.2 0-2.3.8-2.6 1.3V4.6h-1.8v8.1h1.8V7c.4-.5 1.1-1.1 1.9-1.1 1 0 1.3.6 1.3 1.5v5.3h1.8V7c.4-.5 1.1-1.1 1.9-1.1 1 0 1.3.6 1.3 1.5v5.3h1.6zm-13.9 0V6.9c0-1.7-.9-2.6-2.6-2.6-1.3 0-2.3.7-2.9 1.3v-1h-1.8v8.1h1.8V7c.4-.5 1.2-1.1 2.1-1.1 1 0 1.6.4 1.6 1.7v5.1h1.8zm-11.1 0V7.1c.4-.6 1.3-1.1 2.1-1.1h.5V4.4c-1 0-2 .6-2.6 1.4V4.6H155v8.1h1.8zm-5.1-4.7h-4.5c.1-1 .8-2.1 2.3-2.1 1.5 0 2.1 1.2 2.2 2.1m-2.2 4.9c1.3 0 2.5-.4 3.3-1.2l-.8-1.2c-.6.6-1.5.9-2.3.9-1.5 0-2.4-1-2.6-2.2h6.2v-.4c0-2.5-1.5-4.4-4-4.4a4 4 0 0 0-4.1 4.2c.1 2.6 1.9 4.3 4.3 4.3m-7.8-.2 3.3-8.1h-1.9l-2.4 6.1-2.4-6.1h-1.9l3.3 8.1h2zm-9.7-1.3c-1.5 0-2.3-1.3-2.3-2.7 0-1.4.8-2.7 2.3-2.7 1.5 0 2.3 1.3 2.3 2.7 0 1.4-.8 2.7-2.3 2.7m0 1.5c2.6 0 4.1-1.9 4.1-4.2 0-2.3-1.6-4.2-4.1-4.2s-4.1 1.9-4.1 4.2a4 4 0 0 0 4.1 4.2m-10.7 0c3.5 0 5.6-2.4 5.6-6.2h-6.1v1.7h4a3.2 3.2 0 0 1-3.3 2.7c-2.2 0-3.8-1.7-3.8-4 0-2.4 1.6-4 3.8-4 1.2 0 2.3.7 2.9 1.5l1.6-.9a5.2 5.2 0 0 0-4.5-2.3 5.7 5.7 0 0 0-5.9 5.8c0 3.5 2.7 5.7 5.7 5.7m-11.5-.2V6.9c0-1.7-.9-2.6-2.6-2.6-1.3 0-2.3.7-2.8 1.3V1.5h-1.8v11.2h1.8V7c.4-.5 1.2-1.1 2.1-1.1 1 0 1.6.4 1.6 1.6v5.1h1.7zm-12.2.2c2.2 0 3.4-1.1 3.4-2.5 0-3.2-4.9-2.1-4.9-3.6 0-.6.6-1 1.5-1 1 0 1.9.4 2.4 1l.7-1.2a4.8 4.8 0 0 0-3.1-1.1c-2 0-3.2 1.1-3.2 2.4 0 3.1 4.9 2 4.9 3.6 0 .6-.6 1.1-1.6 1.1a4 4 0 0 1-2.7-1.1l-.8 1.3c.8.7 2 1.1 3.4 1.1m-5-8.2h-1.8v8.1h1.8V4.6zm-.9-1c.6 0 1.1-.5 1.1-1.1 0-.6-.5-1.1-1.1-1.1-.6 0-1.1.5-1.1 1.1 0 .6.5 1.1 1.1 1.1M88 12.8c.8 0 1.3-.2 1.6-.5l-.4-1.3c-.1.2-.4.3-.8.3-.5 0-.8-.4-.8-1V6.1h1.6V4.6h-1.6V2.3h-1.8v2.2h-1.3V6h1.3v4.7c.1 1.4.8 2.1 2.2 2.1m-5.6 0c.8 0 1.3-.2 1.6-.5l-.4-1.3c-.1.2-.4.3-.8.3-.5 0-.8-.4-.8-1V6.1h1.6V4.6H82V2.3h-1.8v2.2h-1.3V6h1.3v4.7c.1 1.4.8 2.1 2.2 2.1m-8.3-1.5c-1.5 0-2.3-1.3-2.3-2.7 0-1.4.8-2.7 2.3-2.7 1.5 0 2.3 1.3 2.3 2.7 0 1.4-.8 2.7-2.3 2.7m0 1.5c2.6 0 4.1-1.9 4.1-4.2 0-2.3-1.6-4.2-4.1-4.2-2.6 0-4.1 1.9-4.1 4.2a4 4 0 0 0 4.1 4.2m-8.1 0c1.6 0 2.5-.7 3.1-1.4L68 10.3c-.5.6-1.1 1-1.9 1-1.5 0-2.4-1.1-2.4-2.7s1-2.7 2.4-2.7c.8 0 1.4.3 1.9.9l1.2-1.1c-.6-.7-1.6-1.3-3.2-1.3a4.1 4.1 0 0 0-4.2 4.2c.1 2.4 1.8 4.2 4.2 4.2m-9.7 0c3 0 4.3-1.6 4.3-3.5 0-4.1-6.5-2.9-6.5-4.9.1-.8.8-1.4 1.9-1.4 1.2 0 2.4.4 3.2 1.3l1.1-1.5c-1-1-2.4-1.6-4.2-1.6-2.5 0-4.1 1.4-4.1 3.3 0 4.1 6.5 2.6 6.5 5 0 .8-.6 1.5-2.2 1.5s-2.8-.7-3.5-1.6l-1.1 1.5a6 6 0 0 0 4.6 1.9"/>
27
28
  </svg>
28
29
  </SiteHeader.Brand>,
29
- <SiteHeader.Navigation>
30
+ <SiteHeader.Navigation key="2">
30
31
  <SiteNavigation>
31
32
  <SiteNavigation.Item href="#about">
32
33
  About
@@ -51,10 +52,10 @@ const meta = {
51
52
  </SiteNavigation.Item>
52
53
  </SiteNavigation>
53
54
  </SiteHeader.Navigation>,
54
- <SiteHeader.Search>
55
+ <SiteHeader.Search key="3">
55
56
  <SiteSearch id="site-header-search" />
56
57
  </SiteHeader.Search>,
57
- <SiteHeader.Phase>
58
+ <SiteHeader.Phase key="4">
58
59
  <PhaseBanner phaseName="Beta">
59
60
  This is a new service. Your{' '}
60
61
  <a href="#feedback">
@@ -5,6 +5,17 @@ import SiteNavigation from '../SiteNavigation';
5
5
  import SiteSearch from '../SiteSearch';
6
6
  import PhaseBanner from '../PhaseBanner';
7
7
 
8
+ const NAVIGATION_ITEMS = (
9
+ <>
10
+ <SiteNavigation.Item href="#about">About</SiteNavigation.Item>
11
+ <SiteNavigation.Item href="#get-started">Get started</SiteNavigation.Item>
12
+ <SiteNavigation.Item href="#styles">Styles</SiteNavigation.Item>
13
+ <SiteNavigation.Item href="#components" isCurrent>Components</SiteNavigation.Item>
14
+ <SiteNavigation.Item href="#patterns">Patterns</SiteNavigation.Item>
15
+ <SiteNavigation.Item href="#guidance">Guidance</SiteNavigation.Item>
16
+ </>
17
+ );
18
+
8
19
  test('site header renders correctly (maximal, testing markup structure)', () => {
9
20
  render(
10
21
  <SiteHeader>
@@ -13,12 +24,7 @@ test('site header renders correctly (maximal, testing markup structure)', () =>
13
24
  </SiteHeader.Brand>
14
25
  <SiteHeader.Navigation>
15
26
  <SiteNavigation>
16
- <SiteNavigation.Item href="#about">About</SiteNavigation.Item>
17
- <SiteNavigation.Item href="#get-started">Get started</SiteNavigation.Item>
18
- <SiteNavigation.Item href="#styles">Styles</SiteNavigation.Item>
19
- <SiteNavigation.Item href="#components" current>Components</SiteNavigation.Item>
20
- <SiteNavigation.Item href="#patterns">Patterns</SiteNavigation.Item>
21
- <SiteNavigation.Item href="#guidance">Guidance</SiteNavigation.Item>
27
+ {NAVIGATION_ITEMS}
22
28
  </SiteNavigation>
23
29
  </SiteHeader.Navigation>
24
30
  <SiteHeader.Search>
@@ -155,16 +161,7 @@ test('site header logo link link with custom element', () => {
155
161
  });
156
162
 
157
163
  test('site header with site navigation', () => {
158
- const NAVIGATION_ITEMS = (
159
- <>
160
- <SiteNavigation.Item href="#about">About</SiteNavigation.Item>
161
- <SiteNavigation.Item href="#get-started">Get started</SiteNavigation.Item>
162
- <SiteNavigation.Item href="#styles">Styles</SiteNavigation.Item>
163
- <SiteNavigation.Item href="#components" current>Components</SiteNavigation.Item>
164
- <SiteNavigation.Item href="#patterns">Patterns</SiteNavigation.Item>
165
- <SiteNavigation.Item href="#guidance">Guidance</SiteNavigation.Item>
166
- </>
167
- );
164
+
168
165
 
169
166
  render(
170
167
  <>
@@ -240,6 +237,22 @@ test('site header with phase banner', () => {
240
237
  expect(siteHeaderPhaseBanner?.innerHTML).toEqual(phaseBannerReference.innerHTML);
241
238
  });
242
239
 
240
+ test('instantiating/initialising DS component script', () => {
241
+ render(
242
+ <SiteHeader>
243
+ <SiteHeader.Navigation>
244
+ <SiteNavigation>
245
+ {NAVIGATION_ITEMS}
246
+ </SiteNavigation>
247
+ </SiteHeader.Navigation>
248
+ </SiteHeader>
249
+ );
250
+
251
+ const mobileNav = screen.getAllByRole('navigation')[0];
252
+ expect(mobileNav).toHaveClass('js-initialised');
253
+ expect(mobileNav).toHaveClass('js-instantiated');
254
+ });
255
+
243
256
  test('passing additional props', () => {
244
257
  render(
245
258
  <SiteHeader data-test="foo" />
@@ -1,16 +1,16 @@
1
1
  import React, { Children, useEffect, useRef } from 'react';
2
2
  import Icon from '../../common/Icon';
3
3
  import SiteNavigation from '../SiteNavigation';
4
-
5
- // @ts-ignore
6
4
  import DSMobileMenu from '@scottish-government/design-system/src/components/site-navigation/site-navigation';
5
+ import { SiteHeaderBrandProps, SiteHeaderProps } from './types';
6
+ import { SiteNavigationProps } from '../SiteNavigation/types';
7
7
 
8
8
  const Brand = ({
9
9
  children,
10
10
  homeUrl = '/',
11
11
  linkComponent,
12
12
  siteTitle
13
- }: SGDS.Component.SiteHeader.Brand) => {
13
+ }: SiteHeaderBrandProps) => {
14
14
  function processChildren(children: React.ReactNode) {
15
15
  const image = React.cloneElement(children as React.ReactElement<HTMLImageElement>, { className: 'ds_site-branding__logo-image' });
16
16
 
@@ -36,26 +36,26 @@ const Brand = ({
36
36
 
37
37
  const Navigation = ({
38
38
  children
39
- }: any) => {
39
+ }: React.AllHTMLAttributes<HTMLElement>) => {
40
40
  return children;
41
41
  }
42
42
 
43
43
  const Phase = ({
44
44
  children
45
- }: any) => {
45
+ }: React.AllHTMLAttributes<HTMLElement>) => {
46
46
  return children;
47
47
  }
48
48
 
49
49
  const Search = ({
50
50
  children
51
- }: any) => {
51
+ }: React.AllHTMLAttributes<HTMLElement>) => {
52
52
  return children;
53
53
  }
54
54
 
55
55
  const SiteHeader = ({
56
56
  children,
57
57
  ...props
58
- }: SGDS.Component.SiteHeader) => {
58
+ }: SiteHeaderProps) => {
59
59
  const mobileMenuRef = useRef(null);
60
60
 
61
61
  let branding: React.ReactNode;
@@ -66,14 +66,14 @@ const SiteHeader = ({
66
66
 
67
67
  // assign to slots
68
68
  Children.forEach(children, (child: React.ReactNode) => {
69
- const thisChild = child as React.ReactElement<any>;
69
+ const thisChild = child as React.JSX.Element;
70
70
  if (thisChild && thisChild.type === Brand) {
71
71
  branding = thisChild;
72
72
  } else if (thisChild && thisChild.type === Navigation) {
73
73
  navigation = thisChild;
74
74
 
75
75
  if (thisChild.props.children.type === SiteNavigation) {
76
- mobileNavigation = React.cloneElement(thisChild.props.children as React.ReactElement<SGDS.Component.SiteNavigation>, { className: 'ds_site-navigation--mobile', id: 'mobile-navigation', ref: mobileMenuRef});
76
+ mobileNavigation = React.cloneElement(thisChild.props.children as React.ReactElement<SiteNavigationProps>, { className: 'ds_site-navigation--mobile', id: 'mobile-navigation', ref: mobileMenuRef});
77
77
  }
78
78
  } else if (thisChild && thisChild.type === Phase) {
79
79
  phase = thisChild;
@@ -83,6 +83,7 @@ const SiteHeader = ({
83
83
  });
84
84
 
85
85
  useEffect(() => {
86
+ /* istanbul ignore else */
86
87
  if (mobileMenuRef.current) {
87
88
  new DSMobileMenu(mobileMenuRef.current).init();
88
89
  }
@@ -0,0 +1,22 @@
1
+ import { LinkComponent } from "../../shared-types";
2
+ import { PhaseBannerProps } from "../PhaseBanner/types";
3
+ import { SiteNavigationItemProps } from "../SiteNavigation/types";
4
+ import { SiteSearchProps } from "../SiteSearch/types";
5
+
6
+ export interface SiteHeaderBrandProps extends React.AllHTMLAttributes<HTMLElement> {
7
+ homeUrl: string;
8
+ linkComponent?: LinkComponent;
9
+ siteTitle?: string;
10
+ }
11
+
12
+ export interface SiteHeaderProps extends React.AllHTMLAttributes<HTMLHeadingElement> {
13
+ logo?: {
14
+ alt?: string;
15
+ href?: string;
16
+ src?: string;
17
+ };
18
+ navigationItems?: SiteNavigationItemProps[];
19
+ phaseBanner?: PhaseBannerProps;
20
+ siteSearch?: SiteSearchProps;
21
+ siteTitle?: string;
22
+ }
@@ -45,7 +45,7 @@ test('site navigation link renders correctly', () => {
45
45
  expect(link).toHaveAttribute('href', LINK_HREF)
46
46
  });
47
47
 
48
- test('site navigation link with custom element', () => {
48
+ test('site navigation item with custom link element', () => {
49
49
  render(
50
50
  <SiteNavigation.Item href={LINK_HREF} linkComponent={
51
51
  ({ className, ...props }) => (
@@ -62,6 +62,21 @@ test('site navigation link with custom element', () => {
62
62
  expect(link?.textContent).toEqual(LINK_TEXT);
63
63
  });
64
64
 
65
+ test('site navigation item without href', () => {
66
+ render(
67
+ // @ts-expect-error required prop missing
68
+ <SiteNavigation.Item>
69
+ {LINK_TEXT}
70
+ </SiteNavigation.Item>
71
+ );
72
+
73
+ const item = screen.getByRole('listitem');
74
+ const link = within(item).queryByRole('link');
75
+
76
+ expect(link).not.toBeInTheDocument();
77
+ expect(item.textContent).toEqual(LINK_TEXT);
78
+ });
79
+
65
80
  test('highlights current item', () => {
66
81
  render(
67
82
  <SiteNavigation.Item href={LINK_HREF} isCurrent>{LINK_TEXT}</SiteNavigation.Item>
@@ -1,9 +1,12 @@
1
+ import { SiteNavigationItemProps, SiteNavigationProps } from "./types";
2
+ import clsx from 'clsx';
3
+
1
4
  const Item = ({
2
5
  children,
3
6
  isCurrent = false,
4
7
  href,
5
8
  linkComponent
6
- }: SGDS.Component.SiteNavigation.Item) => {
9
+ }: SiteNavigationItemProps) => {
7
10
  const classNames = ['ds_site-navigation__link'];
8
11
  let ariaCurrent: React.AriaAttributes["aria-current"];
9
12
 
@@ -12,11 +15,15 @@ const Item = ({
12
15
  ariaCurrent = 'page';
13
16
  }
14
17
 
18
+ const classNamesString = clsx(classNames);
19
+
15
20
  function processChildren(children: React.ReactNode) {
16
21
  if (linkComponent) {
17
- return linkComponent({ className: classNames.join(' '), href, children });
22
+ return linkComponent({ className: classNamesString, href, children });
18
23
  } else if (href) {
19
- return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNames.join(' ')}>{children}</a>;
24
+ return <a href={href} aria-current={ariaCurrent ? ariaCurrent : undefined} className={classNamesString}>{children}</a>;
25
+ } else {
26
+ return <span className={classNamesString}>{children}</span>;
20
27
  }
21
28
  }
22
29
 
@@ -33,13 +40,13 @@ const SiteNavigation = ({
33
40
  children,
34
41
  className,
35
42
  ...props
36
- }: SGDS.Component.SiteNavigation) => {
43
+ }: SiteNavigationProps) => {
37
44
  return (
38
45
  <nav
39
- className={[
46
+ className={clsx([
40
47
  'ds_site-navigation',
41
48
  className
42
- ].join(' ')}
49
+ ])}
43
50
  {...props}
44
51
  >
45
52
  <ul className="ds_site-navigation__list">
@@ -0,0 +1,11 @@
1
+ import { LinkComponent } from '../../shared-types';
2
+
3
+ export interface SiteNavigationItemProps extends React.AllHTMLAttributes<HTMLLIElement> {
4
+ isCurrent?: boolean;
5
+ href: string;
6
+ linkComponent?: LinkComponent;
7
+ }
8
+
9
+ export interface SiteNavigationProps extends React.AllHTMLAttributes<HTMLElement> {
10
+ ref?: React.RefObject<null>;
11
+ }
@@ -11,8 +11,10 @@ type AutocompleteResponseObject = {
11
11
  category: string
12
12
  }
13
13
 
14
- const suggestionMappingFunction = function (request: XMLHttpRequest) {
15
- const responseObj = JSON.parse(request.response).map((item: string) => ({
14
+ type SuggestionObject = { response: string };
15
+
16
+ const suggestionMappingFunction = function (suggestionObj: SuggestionObject) {
17
+ const responseObj = JSON.parse(suggestionObj.response).map((item: string) => ({
16
18
  key: '',
17
19
  displayText: item,
18
20
  weight: '',
@@ -142,6 +142,28 @@ test('autocomplete', () => {
142
142
 
143
143
  });
144
144
 
145
+ test('instantiating/initialising DS component script: autocomplete', () => {
146
+ render(
147
+ <SiteSearch autocompleteEndpoint="/endpoint" />
148
+ );
149
+
150
+ const searchForm = screen.getByRole('search');
151
+ const searchFormContainer = searchForm.parentElement;
152
+ expect(searchFormContainer).toHaveClass('js-initialised');
153
+ expect(searchFormContainer).toHaveClass('js-instantiated');
154
+ });
155
+
156
+ test('instantiating/initialising DS component script: no autocomplete', () => {
157
+ render(
158
+ <SiteSearch />
159
+ );
160
+
161
+ const searchForm = screen.getByRole('search');
162
+ const searchFormContainer = searchForm.parentElement;
163
+ expect(searchFormContainer).not.toHaveClass('js-initialised');
164
+ expect(searchFormContainer).not.toHaveClass('js-instantiated');
165
+ });
166
+
145
167
  test('passing additional props', () => {
146
168
  render(
147
169
  <SiteSearch data-test="foo" />
@@ -1,7 +1,8 @@
1
1
  import { useEffect, useRef } from 'react';
2
- // @ts-ignore
3
2
  import DSAutocomplete from '@scottish-government/design-system/src/components/autocomplete/autocomplete';
4
3
  import Button from '../Button';
4
+ import { SiteSearchProps, SuggestionMappingFunctionProps } from './types';
5
+ import clsx from 'clsx';
5
6
 
6
7
  const SiteSearch = function ({
7
8
  action = '/search',
@@ -14,19 +15,20 @@ const SiteSearch = function ({
14
15
  name = 'q',
15
16
  placeholder = 'Search',
16
17
  ...props
17
- }: SGDS.Component.SiteSearch) {
18
+ }: SiteSearchProps) {
18
19
  const ref = useRef(null);
19
20
  const hasAutocomplete = !!autocompleteEndpoint;
20
- let autocompleteId = hasAutocomplete ? id + '-autocomplete' : '';
21
+ const autocompleteId = hasAutocomplete ? id + '-autocomplete' : '';
21
22
 
22
23
  type AutoCompleteOptions = {
23
24
  minLength?: number,
24
- suggestionMappingFunction?: Function,
25
+ suggestionMappingFunction?: SuggestionMappingFunctionProps,
25
26
  throttleDelay?: number
26
27
  }
27
28
 
28
29
  useEffect(() => {
29
- if (hasAutocomplete && ref.current) {
30
+ const autocompleteElement = document.getElementById(autocompleteId);
31
+ if (hasAutocomplete && autocompleteElement && ref.current) {
30
32
  const options: AutoCompleteOptions = {};
31
33
  if (minLength) {
32
34
  options.minLength = minLength;
@@ -36,7 +38,7 @@ const SiteSearch = function ({
36
38
  }
37
39
 
38
40
  const autocomplete = new DSAutocomplete(
39
- document.getElementById(autocompleteId),
41
+ autocompleteElement,
40
42
  autocompleteEndpoint,
41
43
  options
42
44
  );
@@ -47,11 +49,11 @@ const SiteSearch = function ({
47
49
 
48
50
  return (
49
51
  <div
50
- className={[
51
- 'ds_site-search', ,
52
+ className={clsx([
53
+ 'ds_site-search',
52
54
  className,
53
- hasAutocomplete ? 'ds_autocomplete' : undefined
54
- ].join(' ')}
55
+ hasAutocomplete && 'ds_autocomplete'
56
+ ])}
55
57
  id={autocompleteId ? autocompleteId : undefined}
56
58
  ref={ref}
57
59
  {...props}
@@ -68,11 +70,11 @@ const SiteSearch = function ({
68
70
  <input aria-autocomplete={hasAutocomplete ? 'list' : undefined}
69
71
  aria-owns={hasAutocomplete ? 'autocomplete-suggestions' : undefined}
70
72
  autoComplete={hasAutocomplete ? 'off' : undefined}
71
- className={[
73
+ className={clsx([
72
74
  'ds_input',
73
75
  'ds_site-search__input',
74
- hasAutocomplete ? 'js-autocomplete-input' : undefined
75
- ].join(' ')}
76
+ hasAutocomplete && 'js-autocomplete-input'
77
+ ])}
76
78
  id={id}
77
79
  name={name}
78
80
  placeholder={placeholder}
@@ -0,0 +1,19 @@
1
+ type FormMethods = 'GET' | 'POST';
2
+
3
+ export type Suggestion = {
4
+ displayText: string;
5
+ isActive: boolean;
6
+ }
7
+
8
+ export type SuggestionMappingFunctionProps = (suggestions: object[]) => Suggestion[];
9
+
10
+ export interface SiteSearchProps extends React.AllHTMLAttributes<HTMLInputElement> {
11
+ action?: string;
12
+ autocompleteEndpoint?: string;
13
+ autocompleteSuggestionMappingFunction?: SuggestionMappingFunctionProps;
14
+ id: string;
15
+ method?: FormMethods;
16
+ minLength?: number;
17
+ name?: string;
18
+ placeholder?: string;
19
+ }
@@ -8,16 +8,16 @@ const meta = {
8
8
  component: SkipLinks,
9
9
  argTypes: {
10
10
  mainContentId: {
11
- description: 'The id attribute of the main content element to link to',
11
+ description: 'The id attribute of the \'main content\' element to link to',
12
12
  type: 'string'
13
13
  },
14
14
  mainLinkText: {
15
- description: 'The text to use for the main content link',
15
+ description: 'The text to use for the \'main content\' link',
16
16
  type: 'string'
17
17
  },
18
18
  isStatic: {
19
19
  control: 'boolean',
20
- description: 'Use the static display variant'
20
+ description: 'Use the \'static\' display variant'
21
21
  },
22
22
  children: argTypes.children()
23
23
  },
@@ -1,12 +1,12 @@
1
1
  import React, { useEffect } from 'react';
2
-
3
- // @ts-ignore
4
2
  import dsSkipLinks from '@scottish-government/design-system/src/components/skip-links/skip-links';
3
+ import { SkipLinksLinkProps, SkipLinksProps } from './types';
4
+ import clsx from 'clsx';
5
5
 
6
6
  const Link = ({
7
7
  children,
8
8
  fragmentId
9
- }: SGDS.Component.SkipLinks.Link) => {
9
+ }: SkipLinksLinkProps) => {
10
10
  return (
11
11
  <li
12
12
  className="ds_skip-links__item"
@@ -22,7 +22,7 @@ const SkipLinks = ({
22
22
  mainLinkText = 'Skip to main content',
23
23
  isStatic,
24
24
  ...props
25
- }: SGDS.Component.SkipLinks) => {
25
+ }: SkipLinksProps) => {
26
26
 
27
27
  useEffect(() => {
28
28
  dsSkipLinks.init();
@@ -30,10 +30,10 @@ const SkipLinks = ({
30
30
 
31
31
  return (
32
32
  <div
33
- className={[
33
+ className={clsx([
34
34
  'ds_skip-links',
35
- isStatic && 'ds_skip-links--static',
36
- ].join(' ')}
35
+ isStatic && 'ds_skip-links--static'
36
+ ])}
37
37
  {...props}
38
38
  >
39
39
  <ul className="ds_skip-links__list">
@@ -0,0 +1,9 @@
1
+ export interface SkipLinksLinkProps extends React.AllHTMLAttributes<HTMLLIElement> {
2
+ fragmentId: string;
3
+ }
4
+
5
+ export interface SkipLinksProps extends React.AllHTMLAttributes<HTMLDivElement> {
6
+ mainContentId?: string;
7
+ mainLinkText?: string;
8
+ isStatic?: boolean;
9
+ }
@@ -16,17 +16,6 @@ const ACTIONS = [
16
16
  }
17
17
  ];
18
18
 
19
- const ITEMS = [
20
- {
21
- title: 'Phone number',
22
- value: '0123 456 7890'
23
- },
24
- {
25
- title: 'Address',
26
- value: `Victoria Quay\nEdinburgh\nEH6 6QQ`
27
- }
28
- ];
29
-
30
19
  const TITLE_TEXT = 'Joe Bloggs';
31
20
 
32
21
  test('summary card renders correctly', () => {
@@ -3,6 +3,9 @@ import React, { Children, useId } from 'react';
3
3
  import ActionLink from '../../common/ActionLink';
4
4
  import ConditionalWrapper from '../../common/ConditionalWrapper';
5
5
  import WrapperTag from "../../common/WrapperTag";
6
+ import { SummaryCardProps } from './types';
7
+ import { ActionLinkProps } from '../../common/ActionLink/types';
8
+ import clsx from 'clsx';
6
9
 
7
10
  const SummaryCard = ({
8
11
  children,
@@ -10,14 +13,14 @@ const SummaryCard = ({
10
13
  headingLevel = 'h3',
11
14
  title,
12
15
  ...props
13
- }: SGDS.Component.SummaryCard) => {
14
- let actions: any[] = [];
15
- let remainingChildren: any[] = [];
16
+ }: SummaryCardProps) => {
17
+ const actions: React.ReactElement[] = [];
18
+ const remainingChildren: React.ReactElement[] = [];
16
19
 
17
20
  const describedById = useId();
18
21
 
19
22
  Children.forEach(children, (child: React.ReactNode) => {
20
- const thisChild = child as React.ReactElement<SGDS.Common.ActionLink>;
23
+ const thisChild = child as React.ReactElement<ActionLinkProps>;
21
24
  if (thisChild && thisChild.type === ActionLink) {
22
25
  actions.push(React.cloneElement(thisChild, { describedby: describedById }));
23
26
  } else {
@@ -27,10 +30,10 @@ const SummaryCard = ({
27
30
 
28
31
  return (
29
32
  <div
30
- className={[
33
+ className={clsx([
31
34
  'ds_summary-card',
32
35
  className
33
- ].join(' ')}
36
+ ])}
34
37
  {...props}
35
38
  >
36
39
  <div className="ds_summary-card__header">
@@ -0,0 +1,6 @@
1
+ import { HeadingLevel } from '../../shared-types';
2
+
3
+ export interface SummaryCardProps extends React.AllHTMLAttributes<HTMLElement> {
4
+ headingLevel?: HeadingLevel;
5
+ title: string;
6
+ }
@@ -14,7 +14,7 @@ const meta = {
14
14
  )
15
15
  ],
16
16
  argTypes: {
17
- Title: {
17
+ title: {
18
18
  description: 'Title of the summary list item.',
19
19
  type: {
20
20
  name: 'string',
@@ -26,16 +26,16 @@ const meta = {
26
26
  args: {
27
27
  title: 'Contact details',
28
28
  children: [
29
- <SummaryList.Value name="Email">
29
+ <SummaryList.Value name="Email" key="1">
30
30
  email@gov.scot
31
31
  </SummaryList.Value>,
32
- <SummaryList.Value name="Telephone">
32
+ <SummaryList.Value name="Telephone" key="2">
33
33
  0123 456 7890
34
34
  </SummaryList.Value>,
35
- <SummaryList.Action href="foo">
35
+ <SummaryList.Action href="foo" key="3">
36
36
  Change
37
37
  </SummaryList.Action>,
38
- <SummaryList.Action onclick={function w(){}}>
38
+ <SummaryList.Action onclick={function w(){}} key="4">
39
39
  Delete
40
40
  </SummaryList.Action>
41
41
  ]
@@ -34,7 +34,7 @@ const meta = {
34
34
  <SummaryList.Item title="Address">
35
35
  <SummaryList.Value>
36
36
  Scottish Government<br />
37
- St Andrew's House<br />
37
+ St Andrew&apos;s House<br />
38
38
  Regent Road<br />
39
39
  Edinburgh<br />
40
40
  EH1 3DG
@@ -1,5 +1,5 @@
1
1
  import { test, expect, vi } from 'vitest';
2
- import { within, render, screen, fireEvent } from '@testing-library/react';
2
+ import { within, render, screen } from '@testing-library/react';
3
3
  import SummaryList from './SummaryList';
4
4
 
5
5
  const ONCLICK_FUNCTION = vi.fn();
@@ -7,11 +7,6 @@ const TITLE = 'Name';
7
7
  const VALUE_1 = 'Jane Smith';
8
8
  const VALUE_2 = 'Tony Brown';
9
9
 
10
- const ACTION_HREF = "#foo"
11
- const ACTION_ONCLICK = ONCLICK_FUNCTION;
12
- const ACTION_TEXT = 'Name';
13
- const DESCRIBEDBY_ID = 'q1-name';
14
-
15
10
  test('summary list renders correctly', () => {
16
11
  render(
17
12
  <SummaryList data-testid="summarylist">