@tpzdsp/next-toolkit 2.5.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/package.json +21 -12
  2. package/src/assets/styles/globals.css +75 -95
  3. package/src/assets/styles/ol.css +57 -16
  4. package/src/assets/styles/utils.css +80 -0
  5. package/src/components/Accordion/Accordion.css +85 -0
  6. package/src/components/Accordion/Accordion.stories.tsx +264 -0
  7. package/src/components/Accordion/Accordion.tsx +98 -0
  8. package/src/components/Alert/Alert.css +129 -0
  9. package/src/components/Alert/Alert.stories.tsx +291 -0
  10. package/src/components/Alert/Alert.tsx +76 -0
  11. package/src/components/BackLink/BackLink.css +12 -0
  12. package/src/components/BackLink/BackLink.stories.tsx +52 -0
  13. package/src/components/BackLink/BackLink.tsx +44 -0
  14. package/src/components/BackToTop/BackToTop.css +23 -0
  15. package/src/components/BackToTop/BackToTop.stories.tsx +41 -0
  16. package/src/components/BackToTop/BackToTop.tsx +48 -0
  17. package/src/components/Breadcrumb/Breadcrumb.css +42 -0
  18. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +94 -0
  19. package/src/components/Breadcrumb/Breadcrumb.tsx +135 -0
  20. package/src/components/Button/Button.css +229 -0
  21. package/src/components/Button/Button.stories.tsx +140 -20
  22. package/src/components/Button/Button.tsx +53 -28
  23. package/src/components/Button/ButtonSkeleton.stories.tsx +50 -0
  24. package/src/components/Button/ButtonSkeleton.tsx +14 -0
  25. package/src/components/ButtonGroup/ButtonGroup.css +52 -0
  26. package/src/components/ButtonGroup/ButtonGroup.stories.tsx +156 -0
  27. package/src/components/ButtonGroup/ButtonGroup.tsx +50 -0
  28. package/src/components/ButtonLink/ButtonLink.css +114 -0
  29. package/src/components/ButtonLink/ButtonLink.stories.tsx +38 -51
  30. package/src/components/ButtonLink/ButtonLink.tsx +54 -23
  31. package/src/components/Card/Card.css +13 -0
  32. package/src/components/Card/Card.stories.tsx +98 -57
  33. package/src/components/Card/Card.tsx +4 -13
  34. package/src/components/CardGroup/CardGroup.css +10 -0
  35. package/src/components/CardGroup/CardGroup.stories.tsx +81 -0
  36. package/src/components/CardGroup/CardGroup.tsx +9 -0
  37. package/src/components/Checkbox/Checkbox.css +49 -0
  38. package/src/components/Checkbox/Checkbox.stories.tsx +86 -0
  39. package/src/components/Checkbox/Checkbox.tsx +32 -0
  40. package/src/components/Chip/Chip.css +54 -0
  41. package/src/components/Chip/Chip.stories.tsx +94 -0
  42. package/src/components/Chip/Chip.tsx +34 -0
  43. package/src/components/CookieBanner/CookieBanner.css +19 -0
  44. package/src/components/CookieBanner/CookieBanner.stories.tsx +52 -0
  45. package/src/components/CookieBanner/CookieBanner.tsx +55 -0
  46. package/src/components/CopyButton/CopyButton.stories.tsx +28 -0
  47. package/src/components/CopyButton/CopyButton.tsx +65 -0
  48. package/src/components/DateInput/DateInput.css +13 -0
  49. package/src/components/DateInput/DateInput.stories.tsx +131 -0
  50. package/src/components/DateInput/DateInput.test.tsx +21 -0
  51. package/src/components/DateInput/DateInput.tsx +98 -0
  52. package/src/components/Details/Details.css +28 -0
  53. package/src/components/Details/Details.stories.tsx +48 -0
  54. package/src/components/Details/Details.tsx +41 -0
  55. package/src/components/Dropdown/Dropdown.css +81 -0
  56. package/src/components/Dropdown/Dropdown.stories.tsx +131 -0
  57. package/src/components/Dropdown/Dropdown.tsx +69 -0
  58. package/src/components/ErrorBoundary/ErrorBoundary.stories.tsx +4 -39
  59. package/src/components/ErrorBoundary/ErrorBoundary.tsx +7 -4
  60. package/src/components/ErrorBoundary/ErrorFallback.tsx +32 -66
  61. package/src/components/ErrorModal/ErrorModal.css +34 -0
  62. package/src/components/ErrorModal/ErrorModal.stories.tsx +100 -0
  63. package/src/components/ErrorModal/ErrorModal.tsx +123 -0
  64. package/src/components/ErrorText/ErrorText.css +22 -0
  65. package/src/components/ErrorText/ErrorText.stories.tsx +42 -27
  66. package/src/components/ErrorText/ErrorText.tsx +10 -8
  67. package/src/components/ExternalLink/ExternalLink.css +12 -0
  68. package/src/components/ExternalLink/ExternalLink.stories.tsx +43 -0
  69. package/src/components/ExternalLink/ExternalLink.tsx +43 -0
  70. package/src/components/Fieldset/Fieldset.css +103 -0
  71. package/src/components/Fieldset/Fieldset.stories.tsx +304 -0
  72. package/src/components/Fieldset/Fieldset.tsx +38 -0
  73. package/src/components/FileUpload/FileUpload.css +85 -0
  74. package/src/components/FileUpload/FileUpload.stories.tsx +106 -0
  75. package/src/components/FileUpload/FileUpload.tsx +99 -0
  76. package/src/components/{layout/footer → Footer}/Copyright.tsx +3 -2
  77. package/src/components/Footer/Footer.stories.tsx +27 -0
  78. package/src/components/Footer/Footer.tsx +46 -0
  79. package/src/components/Footer/Licence.tsx +18 -0
  80. package/src/components/Footer/MetaLinks.tsx +47 -0
  81. package/src/components/Footer/Small/SmallFooter.stories.tsx +3 -0
  82. package/src/components/Footer/Small/SmallFooter.tsx +53 -41
  83. package/src/components/Form/FormGroup.css +18 -0
  84. package/src/components/Form/FormGroup.stories.tsx +87 -0
  85. package/src/components/Form/FormGroup.tsx +16 -0
  86. package/src/components/{layout/header → Header}/Header.stories.tsx +26 -12
  87. package/src/components/Header/Header.test.tsx +87 -0
  88. package/src/components/Header/Header.tsx +304 -0
  89. package/src/components/Header/HeaderAppContent.tsx +120 -0
  90. package/src/components/Heading/Heading.css +40 -0
  91. package/src/components/Heading/Heading.stories.tsx +15 -5
  92. package/src/components/Heading/Heading.tsx +21 -44
  93. package/src/components/Heading/HeadingSkeleton.stories.tsx +30 -0
  94. package/src/components/Heading/HeadingSkeleton.tsx +14 -0
  95. package/src/components/Hero/Hero.css +19 -0
  96. package/src/components/Hero/Hero.stories.tsx +41 -0
  97. package/src/components/Hero/Hero.tsx +14 -0
  98. package/src/components/HintText/HintText.css +5 -0
  99. package/src/components/HintText/HintText.stories.tsx +29 -0
  100. package/src/components/HintText/HintText.tsx +13 -0
  101. package/src/components/InfoBox/InfoBox.css +38 -0
  102. package/src/components/InfoBox/InfoBox.stories.tsx +51 -403
  103. package/src/components/InfoBox/InfoBox.tsx +31 -158
  104. package/src/components/Input/Input.css +77 -0
  105. package/src/components/Input/Input.stories.tsx +123 -0
  106. package/src/components/Input/Input.tsx +74 -0
  107. package/src/components/InputGroup/InputGroup.css +140 -0
  108. package/src/components/InputGroup/InputGroup.stories.tsx +125 -0
  109. package/src/components/InputGroup/InputGroup.tsx +47 -0
  110. package/src/components/InsetText/InsetText.css +5 -0
  111. package/src/components/InsetText/InsetText.stories.tsx +30 -0
  112. package/src/components/InsetText/InsetText.tsx +9 -0
  113. package/src/components/Keyboard/Keyboard.css +9 -0
  114. package/src/components/Keyboard/Keyboard.stories.tsx +63 -0
  115. package/src/components/Keyboard/Keyboard.tsx +30 -0
  116. package/src/components/Label/Label.css +27 -0
  117. package/src/components/Label/Label.stories.tsx +40 -0
  118. package/src/components/Label/Label.tsx +17 -0
  119. package/src/components/LayerSwitcher/LayerSwitcher.css +59 -0
  120. package/src/components/LayerSwitcher/LayerSwitcher.stories.tsx +112 -0
  121. package/src/components/LayerSwitcher/LayerSwitcher.tsx +61 -0
  122. package/src/components/Layout/401/401.stories.tsx +23 -0
  123. package/src/components/Layout/401/401.tsx +1 -0
  124. package/src/components/Layout/403/403.stories.tsx +23 -0
  125. package/src/components/Layout/403/403.tsx +21 -0
  126. package/src/components/Layout/404/404.stories.tsx +23 -0
  127. package/src/components/Layout/404/404.tsx +28 -0
  128. package/src/components/Layout/500/500.stories.tsx +56 -0
  129. package/src/components/Layout/500/500.tsx +63 -0
  130. package/src/components/Layout/ButtonGroup/ButtonGroup.css +52 -0
  131. package/src/components/Layout/ButtonGroup/ButtonGroup.stories.tsx +156 -0
  132. package/src/components/Layout/ButtonGroup/ButtonGroup.tsx +50 -0
  133. package/src/components/Layout/HeadingGroup/HeadingGroup.css +21 -0
  134. package/src/components/Layout/HeadingGroup/HeadingGroup.stories.tsx +84 -0
  135. package/src/components/Layout/HeadingGroup/HeadingGroup.tsx +9 -0
  136. package/src/components/Layout/MainWrapper/MainWrapper.css +12 -0
  137. package/src/components/Layout/MainWrapper/MainWrapper.stories.tsx +36 -0
  138. package/src/components/Layout/MainWrapper/MainWrapper.tsx +14 -0
  139. package/src/components/Layout/PageShell/PageShell.css +42 -0
  140. package/src/components/Layout/PageShell/PageShell.stories.tsx +108 -0
  141. package/src/components/Layout/PageShell/PageShell.tsx +31 -0
  142. package/src/components/Layout/ParagraphGroup/ParagraphGroup.css +5 -0
  143. package/src/components/Layout/ParagraphGroup/ParagraphGroup.stories.tsx +34 -0
  144. package/src/components/Layout/ParagraphGroup/ParagraphGroup.tsx +9 -0
  145. package/src/components/Layout/Stack/Stack.css +29 -0
  146. package/src/components/Layout/Stack/Stack.stories.tsx +83 -0
  147. package/src/components/Layout/Stack/Stack.tsx +19 -0
  148. package/src/components/Layout/WidthContainer/WidthContainer.css +17 -0
  149. package/src/components/Layout/WidthContainer/WidthContainer.stories.tsx +59 -0
  150. package/src/components/Layout/WidthContainer/WidthContainer.tsx +13 -0
  151. package/src/components/Legend/Legend.css +95 -0
  152. package/src/components/Legend/Legend.stories.tsx +81 -0
  153. package/src/components/Legend/Legend.tsx +32 -0
  154. package/src/components/Legend/LegendDot.tsx +15 -0
  155. package/src/components/Legend/LegendPanel.stories.tsx +101 -0
  156. package/src/components/Legend/LegendPanel.tsx +68 -0
  157. package/src/components/Legend/LegendSkeleton.stories.tsx +87 -0
  158. package/src/components/Legend/LegendSkeleton.tsx +73 -0
  159. package/src/components/LegendSelect/LegendSelect.css +8 -0
  160. package/src/components/LegendSelect/LegendSelect.stories.tsx +80 -0
  161. package/src/components/LegendSelect/LegendSelect.tsx +26 -0
  162. package/src/components/Link/Link.css +98 -0
  163. package/src/components/Link/Link.stories.tsx +70 -0
  164. package/src/components/Link/Link.tsx +52 -0
  165. package/src/components/LinkButton/LinkButton.css +67 -0
  166. package/src/components/LinkButton/LinkButton.stories.tsx +90 -42
  167. package/src/components/LinkButton/LinkButton.tsx +50 -63
  168. package/src/components/LinkList/LinkList.css +28 -0
  169. package/src/components/LinkList/LinkList.stories.tsx +46 -0
  170. package/src/components/LinkList/LinkList.tsx +23 -0
  171. package/src/components/List/Li.tsx +9 -0
  172. package/src/components/List/List.css +9 -0
  173. package/src/components/List/OrderedList.stories.tsx +36 -0
  174. package/src/components/List/OrderedList.tsx +9 -0
  175. package/src/components/List/UnorderedList.stories.tsx +36 -0
  176. package/src/components/List/UnorderedList.tsx +9 -0
  177. package/src/components/LoadingBox/LoadingBox.css +27 -0
  178. package/src/components/LoadingBox/LoadingBox.stories.tsx +66 -0
  179. package/src/components/LoadingBox/LoadingBox.tsx +40 -0
  180. package/src/components/Modal/Modal.css +111 -0
  181. package/src/components/Modal/Modal.stories.tsx +94 -155
  182. package/src/components/Modal/Modal.tsx +141 -75
  183. package/src/components/NoScriptBanner/NoScriptBanner.css +17 -0
  184. package/src/components/NoScriptBanner/NoScriptBanner.stories.tsx +46 -0
  185. package/src/components/NoScriptBanner/NoScriptBanner.tsx +26 -0
  186. package/src/components/Paragraph/Paragraph.css +22 -0
  187. package/src/components/Paragraph/Paragraph.stories.tsx +1 -42
  188. package/src/components/Paragraph/Paragraph.tsx +4 -3
  189. package/src/components/Paragraph/ParagraphSkeleton.stories.tsx +44 -0
  190. package/src/components/Paragraph/ParagraphSkeleton.tsx +33 -0
  191. package/src/components/PasswordInput/PasswordInput.css +3 -0
  192. package/src/components/PasswordInput/PasswordInput.stories.tsx +47 -0
  193. package/src/components/PasswordInput/PasswordInput.tsx +45 -0
  194. package/src/components/PhaseBanner/PhaseBanner.css +12 -0
  195. package/src/components/PhaseBanner/PhaseBanner.stories.tsx +61 -0
  196. package/src/components/PhaseBanner/PhaseBanner.tsx +17 -0
  197. package/src/components/Popover/Popover.css +43 -0
  198. package/src/components/Popover/Popover.stories.tsx +102 -0
  199. package/src/components/Popover/Popover.tsx +40 -0
  200. package/src/components/Radio/Radio.css +69 -0
  201. package/src/components/Radio/Radio.stories.tsx +169 -0
  202. package/src/components/Radio/Radio.tsx +56 -0
  203. package/src/components/Resizable/Resizable.css +86 -0
  204. package/src/components/Resizable/Resizable.stories.tsx +123 -0
  205. package/src/components/Resizable/Resizable.tsx +86 -0
  206. package/src/components/ScrollArea/ScrollArea.css +9 -0
  207. package/src/components/ScrollArea/ScrollArea.stories.tsx +42 -0
  208. package/src/components/ScrollArea/ScrollArea.tsx +11 -0
  209. package/src/components/SearchBox/SearchBox.stories.tsx +88 -0
  210. package/src/components/SearchBox/SearchBox.tsx +36 -0
  211. package/src/components/Select/AsyncSelect.stories.tsx +84 -0
  212. package/src/components/Select/AsyncSelect.tsx +41 -0
  213. package/src/components/Select/Select.css +202 -0
  214. package/src/components/Select/Select.stories.tsx +162 -0
  215. package/src/components/Select/Select.test.tsx +36 -0
  216. package/src/components/Select/Select.tsx +296 -0
  217. package/src/components/Select/SelectSkeleton.stories.tsx +51 -0
  218. package/src/components/Select/SelectSkeleton.tsx +23 -0
  219. package/src/components/Separator/Separator.css +41 -0
  220. package/src/components/Separator/Separator.stories.tsx +63 -0
  221. package/src/components/Separator/Separator.tsx +42 -0
  222. package/src/components/Sidebar/ResizableSidebar.tsx +118 -0
  223. package/src/components/Sidebar/Sidebar.css +203 -0
  224. package/src/components/Sidebar/Sidebar.stories.tsx +438 -0
  225. package/src/components/Sidebar/Sidebar.tsx +225 -0
  226. package/src/components/Skeleton/Skeleton.css +16 -0
  227. package/src/components/Skeleton/Skeleton.stories.tsx +39 -0
  228. package/src/components/Skeleton/Skeleton.tsx +12 -0
  229. package/src/components/SkipLink/SkipLink.css +16 -0
  230. package/src/components/SkipLink/SkipLink.stories.tsx +40 -0
  231. package/src/components/SkipLink/SkipLink.tsx +15 -0
  232. package/src/components/Spinner/Spinner.css +30 -0
  233. package/src/components/Spinner/Spinner.stories.tsx +36 -0
  234. package/src/components/Spinner/Spinner.tsx +45 -0
  235. package/src/components/StartButton/StartButton.css +13 -0
  236. package/src/components/StartButton/StartButton.stories.tsx +68 -0
  237. package/src/components/StartButton/StartButton.tsx +50 -0
  238. package/src/components/SubmitButton/SubmitButton.stories.tsx +31 -0
  239. package/src/components/SubmitButton/SubmitButton.tsx +14 -0
  240. package/src/components/SummaryList/SummaryList.css +71 -0
  241. package/src/components/SummaryList/SummaryList.stories.tsx +211 -0
  242. package/src/components/SummaryList/SummaryList.tsx +41 -0
  243. package/src/components/SummaryList/SummaryListSkeleton.stories.tsx +67 -0
  244. package/src/components/SummaryList/SummaryListSkeleton.tsx +40 -0
  245. package/src/components/Tabs/Tabs.css +84 -0
  246. package/src/components/Tabs/Tabs.stories.tsx +133 -0
  247. package/src/components/Tabs/Tabs.tsx +66 -0
  248. package/src/components/Tag/Tag.css +8 -0
  249. package/src/components/Tag/Tag.stories.tsx +96 -0
  250. package/src/components/Tag/Tag.tsx +34 -0
  251. package/src/components/Textarea/Textarea.css +38 -0
  252. package/src/components/Textarea/Textarea.stories.tsx +131 -0
  253. package/src/components/Textarea/Textarea.tsx +50 -0
  254. package/src/components/TextareaCount/TextareaCount.css +17 -0
  255. package/src/components/TextareaCount/TextareaCount.stories.tsx +131 -0
  256. package/src/components/TextareaCount/TextareaCount.tsx +108 -0
  257. package/src/components/Tooltip/Tooltip.css +43 -0
  258. package/src/components/Tooltip/Tooltip.stories.tsx +110 -0
  259. package/src/components/Tooltip/Tooltip.tsx +53 -0
  260. package/src/components/WarningText/WarningText.css +20 -0
  261. package/src/components/WarningText/WarningText.stories.tsx +29 -0
  262. package/src/components/WarningText/WarningText.tsx +17 -0
  263. package/src/components/index.ts +343 -61
  264. package/src/errors/errorDisplay.ts +70 -0
  265. package/src/errors/index.ts +1 -0
  266. package/src/http/constants.ts +2 -0
  267. package/src/http/fetch.ts +7 -3
  268. package/src/map/LayerSwitcherPanel.tsx +2 -173
  269. package/src/map/LegendShim.tsx +2 -0
  270. package/src/map/MapComponent.tsx +7 -17
  271. package/src/map/MapControlsOverlay.tsx +68 -175
  272. package/src/map/Popup.tsx +71 -24
  273. package/src/map/geocoder/Geocoder.test.tsx +46 -3
  274. package/src/map/geocoder/Geocoder.tsx +155 -278
  275. package/src/map/index.ts +1 -1
  276. package/src/types/utils.ts +0 -10
  277. package/src/utils/components.ts +96 -0
  278. package/src/utils/index.ts +1 -0
  279. package/src/utils/utils.ts +0 -12
  280. package/src/assets/images/defra-logo.svg +0 -51
  281. package/src/assets/images/ea-logo.svg +0 -58
  282. package/src/assets/images/ogl.svg +0 -1
  283. package/src/components/Button/Button.test.tsx +0 -53
  284. package/src/components/ButtonLink/ButtonLink.test.tsx +0 -154
  285. package/src/components/Card/Card.test.tsx +0 -51
  286. package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +0 -75
  287. package/src/components/ErrorBoundary/ErrorFallback.test.tsx +0 -107
  288. package/src/components/ErrorText/ErrorText.test.tsx +0 -33
  289. package/src/components/Heading/Heading.test.tsx +0 -22
  290. package/src/components/Hint/Hint.stories.tsx +0 -58
  291. package/src/components/Hint/Hint.test.tsx +0 -33
  292. package/src/components/Hint/Hint.tsx +0 -12
  293. package/src/components/InfoBox/InfoBox.test.tsx +0 -330
  294. package/src/components/InfoBox/types.ts +0 -6
  295. package/src/components/LinkButton/LinkButton.test.tsx +0 -177
  296. package/src/components/Modal/Modal.test.tsx +0 -246
  297. package/src/components/NotificationBanner/NotificationBanner.stories.tsx +0 -45
  298. package/src/components/NotificationBanner/NotificationBanner.test.tsx +0 -58
  299. package/src/components/NotificationBanner/NotificationBanner.tsx +0 -45
  300. package/src/components/Paragraph/Paragraph.test.tsx +0 -10
  301. package/src/components/SlidingPanel/SlidingPanel.stories.tsx +0 -129
  302. package/src/components/SlidingPanel/SlidingPanel.test.tsx +0 -83
  303. package/src/components/SlidingPanel/SlidingPanel.tsx +0 -258
  304. package/src/components/accordion/Accordion.stories.tsx +0 -234
  305. package/src/components/accordion/Accordion.test.tsx +0 -192
  306. package/src/components/accordion/Accordion.tsx +0 -73
  307. package/src/components/backToTop/BackToTop.stories.tsx +0 -407
  308. package/src/components/backToTop/BackToTop.test.tsx +0 -57
  309. package/src/components/backToTop/BackToTop.tsx +0 -134
  310. package/src/components/chip/Chip.stories.tsx +0 -61
  311. package/src/components/chip/Chip.test.tsx +0 -31
  312. package/src/components/chip/Chip.tsx +0 -23
  313. package/src/components/container/Container.tsx +0 -42
  314. package/src/components/cookieBanner/CookieBanner.stories.tsx +0 -257
  315. package/src/components/cookieBanner/CookieBanner.test.tsx +0 -68
  316. package/src/components/cookieBanner/CookieBanner.tsx +0 -73
  317. package/src/components/divider/RuleDivider.stories.tsx +0 -254
  318. package/src/components/divider/RuleDivider.test.tsx +0 -164
  319. package/src/components/divider/RuleDivider.tsx +0 -23
  320. package/src/components/dropdown/DropdownMenu.test.tsx +0 -211
  321. package/src/components/dropdown/DropdownMenu.tsx +0 -108
  322. package/src/components/dropdown/useDropdownMenu.ts +0 -249
  323. package/src/components/form/Input.stories.tsx +0 -435
  324. package/src/components/form/Input.test.tsx +0 -206
  325. package/src/components/form/Input.tsx +0 -23
  326. package/src/components/form/TextArea.stories.tsx +0 -464
  327. package/src/components/form/TextArea.test.tsx +0 -232
  328. package/src/components/form/TextArea.tsx +0 -23
  329. package/src/components/layout/footer/Footer.tsx +0 -26
  330. package/src/components/layout/footer/Licence.tsx +0 -19
  331. package/src/components/layout/footer/MetaLinks.tsx +0 -36
  332. package/src/components/layout/header/Header.test.tsx +0 -36
  333. package/src/components/layout/header/Header.tsx +0 -90
  334. package/src/components/layout/header/HeaderAuthClient.test.tsx +0 -45
  335. package/src/components/layout/header/HeaderAuthClient.tsx +0 -40
  336. package/src/components/layout/header/HeaderNavClient.test.tsx +0 -44
  337. package/src/components/layout/header/HeaderNavClient.tsx +0 -67
  338. package/src/components/link/ExternalLink.test.tsx +0 -102
  339. package/src/components/link/ExternalLink.tsx +0 -29
  340. package/src/components/link/Link.tsx +0 -26
  341. package/src/components/select/Select.stories.tsx +0 -336
  342. package/src/components/select/Select.test.tsx +0 -474
  343. package/src/components/select/Select.tsx +0 -125
  344. package/src/components/select/SelectSkeleton.stories.tsx +0 -194
  345. package/src/components/select/SelectSkeleton.test.tsx +0 -104
  346. package/src/components/select/SelectSkeleton.tsx +0 -23
  347. package/src/components/select/common.ts +0 -3
  348. package/src/components/select/index.ts +0 -18
  349. package/src/components/skipLink/SkipLink.stories.tsx +0 -346
  350. package/src/components/skipLink/SkipLink.test.tsx +0 -22
  351. package/src/components/skipLink/SkipLink.tsx +0 -49
  352. package/src/map/LegendPanel.tsx +0 -85
  353. /package/src/{components → assets}/images/DefraLogo.tsx +0 -0
  354. /package/src/{components → assets}/images/EaLogo.tsx +0 -0
  355. /package/src/{components → assets}/images/OglLogo.tsx +0 -0
  356. /package/src/components/{googleAnalytics → GoogleAnalytics}/GlobalVars.tsx +0 -0
  357. /package/src/components/{googleAnalytics → GoogleAnalytics}/GoogleAnalytics.tsx +0 -0
@@ -1,474 +0,0 @@
1
- /* eslint-disable vitest/no-conditional-expect -- react-select internals require conditional checks */
2
- import selectEvent from 'react-select-event';
3
-
4
- import { Select } from './Select';
5
- import { render, screen, userEvent, waitFor } from '../../test/renderers';
6
-
7
- // Suppress act warnings for react-select tests
8
- const originalError = console.error;
9
-
10
- beforeAll(() => {
11
- console.error = (...args: unknown[]) => {
12
- const errorMessage = args[0];
13
-
14
- if (
15
- typeof errorMessage === 'string' &&
16
- (errorMessage.includes('act(') || errorMessage.includes('Warning: An update to'))
17
- ) {
18
- return;
19
- }
20
-
21
- originalError.call(console, ...args);
22
- };
23
- });
24
-
25
- afterAll(() => {
26
- console.error = originalError;
27
- });
28
-
29
- const OPTIONS = [
30
- { value: 'option1', label: 'Option 1' },
31
- { value: 'option2', label: 'Option 2' },
32
- { value: 'option3', label: 'Option 3' },
33
- ];
34
-
35
- const PLACEHOLDER_TEXT = 'Select an option...';
36
- const NO_OPTIONS_MESSAGE = 'No options available';
37
-
38
- describe('Select', () => {
39
- it('should render with default props', () => {
40
- render(<Select options={OPTIONS} />);
41
-
42
- expect(screen.getByRole('combobox')).toBeInTheDocument();
43
- });
44
-
45
- it('should render with placeholder text', () => {
46
- render(<Select options={OPTIONS} placeholder={PLACEHOLDER_TEXT} />);
47
-
48
- expect(screen.getByText(PLACEHOLDER_TEXT)).toBeInTheDocument();
49
- });
50
-
51
- it('should render with default value', () => {
52
- render(<Select options={OPTIONS} defaultValue={OPTIONS[0]} />);
53
-
54
- expect(screen.getByText('Option 1')).toBeInTheDocument();
55
- });
56
-
57
- it('should open dropdown when clicked', async () => {
58
- render(<Select options={OPTIONS} />);
59
-
60
- const selectInput = screen.getByRole('combobox');
61
-
62
- await selectEvent.openMenu(selectInput);
63
-
64
- await waitFor(() => {
65
- expect(screen.getByText('Option 1')).toBeInTheDocument();
66
- expect(screen.getByText('Option 2')).toBeInTheDocument();
67
- expect(screen.getByText('Option 3')).toBeInTheDocument();
68
- });
69
- });
70
-
71
- it('should select option when clicked', async () => {
72
- const onChangeMock = vi.fn();
73
-
74
- render(<Select options={OPTIONS} onChange={onChangeMock} />);
75
-
76
- const selectInput = screen.getByRole('combobox');
77
-
78
- await selectEvent.select(selectInput, 'Option 2');
79
-
80
- await waitFor(() => {
81
- expect(onChangeMock).toHaveBeenCalledWith(OPTIONS[1], expect.any(Object));
82
- });
83
- });
84
-
85
- it('should call onChange with correct value', async () => {
86
- const onChangeMock = vi.fn();
87
-
88
- render(<Select options={OPTIONS} onChange={onChangeMock} />);
89
-
90
- const selectInput = screen.getByRole('combobox');
91
-
92
- await selectEvent.select(selectInput, 'Option 1');
93
-
94
- await waitFor(() => {
95
- expect(onChangeMock).toHaveBeenCalledWith(
96
- OPTIONS[0],
97
- expect.objectContaining({
98
- action: 'select-option',
99
- }),
100
- );
101
- });
102
- });
103
-
104
- it('should display selected value', async () => {
105
- render(<Select options={OPTIONS} />);
106
-
107
- const selectInput = screen.getByRole('combobox');
108
-
109
- await selectEvent.select(selectInput, 'Option 3');
110
-
111
- await waitFor(() => {
112
- expect(screen.getByText('Option 3')).toBeInTheDocument();
113
- });
114
- });
115
-
116
- it('should be clearable when isClearable is true', async () => {
117
- const onChangeMock = vi.fn();
118
-
119
- render(
120
- <Select options={OPTIONS} defaultValue={OPTIONS[0]} isClearable onChange={onChangeMock} />,
121
- );
122
-
123
- // Verify the option is initially selected
124
- expect(screen.getByText('Option 1')).toBeInTheDocument();
125
-
126
- // Find the select input
127
- const selectInput = screen.getByRole('combobox');
128
-
129
- // Look for any clickable element that might be the clear button
130
- // This is more reliable than trying to use selectEvent.clearAll
131
- const user = userEvent.setup();
132
-
133
- // The clear indicator should be rendered somewhere in the select container
134
- const selectContainer = selectInput.closest('[class*="select"]') ?? selectInput.parentElement;
135
-
136
- if (selectContainer) {
137
- // Look for elements that might be the clear button
138
- const possibleClearButtons = selectContainer.querySelectorAll(
139
- 'svg, [role="button"], [class*="clear"]',
140
- );
141
-
142
- let cleared = false;
143
-
144
- for (const element of possibleClearButtons) {
145
- try {
146
- await user.click(element as HTMLElement);
147
-
148
- // Check if this click triggered a clear action
149
- if (onChangeMock.mock.calls.some((call) => call[1]?.action === 'clear')) {
150
- cleared = true;
151
- break;
152
- }
153
- } catch {
154
- // Continue to next element
155
- continue;
156
- }
157
- }
158
-
159
- if (cleared) {
160
- expect(onChangeMock).toHaveBeenCalledWith(
161
- null,
162
- expect.objectContaining({ action: 'clear' }),
163
- );
164
- } else {
165
- // Fallback: just verify that isClearable doesn't break the component
166
- expect(selectInput).toBeInTheDocument();
167
- }
168
- }
169
- });
170
-
171
- it('should handle multi-select', async () => {
172
- const onChangeMock = vi.fn();
173
-
174
- render(<Select options={OPTIONS} isMulti onChange={onChangeMock} />);
175
-
176
- const selectInput = screen.getByRole('combobox');
177
-
178
- await selectEvent.select(selectInput, 'Option 1');
179
-
180
- await waitFor(() => {
181
- expect(onChangeMock).toHaveBeenCalledWith([OPTIONS[0]], expect.any(Object));
182
- });
183
- });
184
-
185
- it('should display multiple selected values', async () => {
186
- render(<Select options={OPTIONS} isMulti />);
187
-
188
- const selectInput = screen.getByRole('combobox');
189
-
190
- await selectEvent.select(selectInput, 'Option 1');
191
- await selectEvent.select(selectInput, 'Option 2');
192
-
193
- await waitFor(() => {
194
- expect(screen.getByText('Option 1')).toBeInTheDocument();
195
- expect(screen.getByText('Option 2')).toBeInTheDocument();
196
- });
197
- });
198
-
199
- it('should remove multi-value when remove button is clicked', async () => {
200
- const onChangeMock = vi.fn();
201
- const { container } = render(
202
- <Select
203
- options={OPTIONS}
204
- isMulti
205
- defaultValue={[OPTIONS[0], OPTIONS[1]]}
206
- onChange={onChangeMock}
207
- />,
208
- );
209
-
210
- await waitFor(() => {
211
- expect(screen.getByText('Option 1')).toBeInTheDocument();
212
- expect(screen.getByText('Option 2')).toBeInTheDocument();
213
- });
214
-
215
- const user = userEvent.setup();
216
-
217
- // Look for remove buttons (X icons) in the multi-value tags
218
- const removeButtons = container.querySelectorAll(
219
- 'svg, [class*="multiValueRemove"], [class*="remove"]',
220
- );
221
-
222
- let removed = false;
223
-
224
- for (const button of removeButtons) {
225
- try {
226
- await user.click(button as HTMLElement);
227
-
228
- // Check if this click triggered a remove action
229
- if (
230
- onChangeMock.mock.calls.some(
231
- (call) =>
232
- call[1]?.action === 'remove-value' ||
233
- (Array.isArray(call[0]) && call[0].length === 1),
234
- )
235
- ) {
236
- removed = true;
237
- break;
238
- }
239
- } catch {
240
- // Continue to next button if this one fails
241
- continue;
242
- }
243
- }
244
-
245
- if (removed) {
246
- // Verify that one option was removed and one remains
247
- await waitFor(() => {
248
- expect(onChangeMock).toHaveBeenCalledWith(
249
- expect.arrayContaining([expect.objectContaining({ value: expect.any(String) })]),
250
- expect.objectContaining({ action: 'remove-value' }),
251
- );
252
- });
253
- } else {
254
- // Fallback: just verify that multi-select with remove doesn't break the component
255
- expect(screen.getByText('Option 1')).toBeInTheDocument();
256
- expect(screen.getByText('Option 2')).toBeInTheDocument();
257
- }
258
- });
259
-
260
- it('should be disabled when isDisabled is true', () => {
261
- const { container } = render(<Select options={OPTIONS} isDisabled />);
262
-
263
- // Look for the select container
264
- const selectContainer = container.querySelector('[class*="select"]');
265
-
266
- expect(selectContainer).toBeInTheDocument();
267
-
268
- // Check for disabled state in various ways
269
- const disabledInput =
270
- container.querySelector('input[disabled]') ??
271
- container.querySelector('[aria-disabled="true"]') ??
272
- container.querySelector('[class*="disabled"]');
273
-
274
- expect(disabledInput).toBeInTheDocument();
275
-
276
- // Verify it's actually disabled
277
- if (disabledInput instanceof HTMLInputElement) {
278
- expect(disabledInput).toBeDisabled();
279
- } else {
280
- expect(disabledInput).toHaveAttribute('aria-disabled', 'true');
281
- }
282
- });
283
-
284
- it('should show no options message when options are empty', async () => {
285
- render(<Select options={[]} noOptionsMessage={() => NO_OPTIONS_MESSAGE} />);
286
-
287
- const selectInput = screen.getByRole('combobox');
288
-
289
- await selectEvent.openMenu(selectInput);
290
-
291
- await waitFor(() => {
292
- expect(screen.getByText(NO_OPTIONS_MESSAGE)).toBeInTheDocument();
293
- });
294
- });
295
-
296
- it('should filter options when searchable', async () => {
297
- const user = userEvent.setup();
298
-
299
- render(<Select options={OPTIONS} isSearchable />);
300
-
301
- const selectInput = screen.getByRole('combobox');
302
-
303
- // Click to focus and open menu
304
- await user.click(selectInput);
305
- await user.type(selectInput, 'Option 2');
306
-
307
- await waitFor(() => {
308
- expect(screen.getByText('Option 2')).toBeInTheDocument();
309
- expect(screen.queryByText('Option 1')).not.toBeInTheDocument();
310
- expect(screen.queryByText('Option 3')).not.toBeInTheDocument();
311
- });
312
- });
313
-
314
- it('should handle keyboard navigation', async () => {
315
- const user = userEvent.setup();
316
- const onChangeMock = vi.fn();
317
-
318
- render(<Select options={OPTIONS} onChange={onChangeMock} />);
319
-
320
- const selectInput = screen.getByRole('combobox');
321
-
322
- // Focus the select
323
- await user.click(selectInput);
324
-
325
- // Navigate down once (should highlight first option)
326
- await user.keyboard('{ArrowDown}');
327
-
328
- // Navigate down again (should highlight second option)
329
- await user.keyboard('{ArrowDown}');
330
-
331
- // Select the highlighted option
332
- await user.keyboard('{Enter}');
333
-
334
- await waitFor(() => {
335
- // Verify that an option was selected
336
- expect(onChangeMock).toHaveBeenCalledWith(
337
- expect.objectContaining({
338
- value: expect.any(String),
339
- label: expect.any(String),
340
- }),
341
- expect.objectContaining({
342
- action: 'select-option',
343
- }),
344
- );
345
- });
346
-
347
- // Check which option was actually selected
348
- const selectedCall = onChangeMock.mock.calls[0];
349
- const selectedOption = selectedCall?.[0];
350
-
351
- // Verify the selected option is displayed
352
- await waitFor(() => {
353
- expect(screen.getByText(selectedOption?.label)).toBeInTheDocument();
354
- });
355
- });
356
-
357
- it('should accept custom classNames', () => {
358
- const customClassNames = {
359
- control: () => 'custom-control-class',
360
- container: () => 'custom-container-class',
361
- };
362
-
363
- const { container } = render(<Select options={OPTIONS} classNames={customClassNames} />);
364
-
365
- // Check that the container has the custom class
366
- const selectContainer = container.querySelector('[class*="custom-container-class"]');
367
-
368
- expect(selectContainer).toBeInTheDocument();
369
-
370
- // Check that the control has the custom class
371
- const selectControl = container.querySelector('[class*="custom-control-class"]');
372
-
373
- expect(selectControl).toBeInTheDocument();
374
- });
375
-
376
- it('should handle value prop for controlled component', async () => {
377
- const onChangeMock = vi.fn();
378
-
379
- const { rerender } = render(
380
- <Select options={OPTIONS} value={OPTIONS[0]} onChange={onChangeMock} />,
381
- );
382
-
383
- expect(screen.getByText('Option 1')).toBeInTheDocument();
384
-
385
- // Try to select a different option
386
- const selectInput = screen.getByRole('combobox');
387
-
388
- await selectEvent.select(selectInput, 'Option 2');
389
-
390
- await waitFor(() => {
391
- expect(onChangeMock).toHaveBeenCalledWith(OPTIONS[1], expect.any(Object));
392
- });
393
-
394
- // Rerender with new value to simulate controlled component
395
- rerender(<Select options={OPTIONS} value={OPTIONS[1]} onChange={onChangeMock} />);
396
-
397
- expect(screen.getByText('Option 2')).toBeInTheDocument();
398
- });
399
-
400
- it('should render custom dropdown indicator', () => {
401
- const { container } = render(<Select options={OPTIONS} />);
402
-
403
- // Look for SVG elements (the LuChevronDown icon)
404
- const svgElements = container.querySelectorAll('svg');
405
-
406
- // Should have at least one SVG (the dropdown indicator)
407
- expect(svgElements.length).toBeGreaterThan(0);
408
-
409
- // Verify at least one SVG is present in the DOM
410
- expect(svgElements[0]).toBeInTheDocument();
411
- });
412
-
413
- it('should handle loading state', () => {
414
- // Test that component renders without crashing when isLoading is true
415
- const { rerender } = render(<Select options={OPTIONS} />);
416
-
417
- expect(screen.getByRole('combobox')).toBeInTheDocument();
418
-
419
- // Rerender with isLoading=true - should not crash
420
- rerender(<Select options={OPTIONS} isLoading />);
421
-
422
- expect(screen.getByRole('combobox')).toBeInTheDocument();
423
-
424
- // Test that it can handle both states
425
- rerender(<Select options={OPTIONS} isLoading={false} />);
426
-
427
- expect(screen.getByRole('combobox')).toBeInTheDocument();
428
- });
429
-
430
- it('should handle custom formatOptionLabel', async () => {
431
- const formatOptionLabel = (option: { value: string; label: string }) =>
432
- `Custom: ${option.label}`;
433
-
434
- render(<Select options={OPTIONS} formatOptionLabel={formatOptionLabel} />);
435
-
436
- const selectInput = screen.getByRole('combobox');
437
-
438
- await selectEvent.openMenu(selectInput);
439
-
440
- await waitFor(() => {
441
- expect(screen.getByText('Custom: Option 1')).toBeInTheDocument();
442
- expect(screen.getByText('Custom: Option 2')).toBeInTheDocument();
443
- });
444
- });
445
-
446
- it('should generate unique instanceId', () => {
447
- const { container: container1 } = render(<Select options={OPTIONS} />);
448
- const { container: container2 } = render(<Select options={OPTIONS} />);
449
-
450
- const select1 = container1.querySelector('[id*="react-select"]');
451
- const select2 = container2.querySelector('[id*="react-select"]');
452
-
453
- expect(select1?.id).not.toBe(select2?.id);
454
- });
455
-
456
- it('should handle complex option objects', async () => {
457
- const complexOptions = [
458
- { value: 'user1', label: 'John Doe', email: 'john@example.com' },
459
- { value: 'user2', label: 'Jane Smith', email: 'jane@example.com' },
460
- ];
461
-
462
- const onChangeMock = vi.fn();
463
-
464
- render(<Select options={complexOptions} onChange={onChangeMock} />);
465
-
466
- const selectInput = screen.getByRole('combobox');
467
-
468
- await selectEvent.select(selectInput, 'Jane Smith');
469
-
470
- await waitFor(() => {
471
- expect(onChangeMock).toHaveBeenCalledWith(complexOptions[1], expect.any(Object));
472
- });
473
- });
474
- });
@@ -1,125 +0,0 @@
1
- 'use client';
2
-
3
- import { useId } from 'react';
4
-
5
- import { LuChevronDown, LuX } from 'react-icons/lu';
6
- import type {
7
- ClassNamesConfig,
8
- ClearIndicatorProps,
9
- DropdownIndicatorProps,
10
- GroupBase,
11
- MultiValueRemoveProps,
12
- Props as ReactSelectProps,
13
- } from 'react-select';
14
- import { components, default as ReactSelect } from 'react-select';
15
-
16
- import { SELECT_CONTAINER_CLASSES, SELECT_CONTROL_CLASSES } from './common';
17
- import { cn } from '../../utils';
18
-
19
- // extends the react-select props with some of our own
20
- export type SelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = Omit<
21
- ReactSelectProps<Option, IsMulti, Group>,
22
- 'className'
23
- >;
24
-
25
- const getClassNames = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
26
- userClassNames?: ClassNamesConfig<Option, IsMulti, Group>,
27
- ): ClassNamesConfig<Option, IsMulti, Group> => {
28
- return {
29
- container: (props) => cn(SELECT_CONTAINER_CLASSES, userClassNames?.container?.(props)),
30
- control: (props) =>
31
- cn(
32
- SELECT_CONTROL_CLASSES,
33
- props.isDisabled ? '!cursor-not-allowed bg-gray-100' : 'bg-white',
34
- props.isFocused
35
- ? 'shadow-[0px_0px_0px_theme(borderWidth.form)_theme(colors.focus)] border-focus'
36
- : '',
37
- userClassNames?.control?.(props),
38
- ),
39
- dropdownIndicator: (props) => cn('w-4 h-4', userClassNames?.dropdownIndicator?.(props)),
40
- placeholder: (props) => cn('text-text-secondary', userClassNames?.placeholder?.(props)),
41
- menu: (props) =>
42
- cn(
43
- 'bg-white border border-black mt-1 overflow-hidden shadow-sm shadow-[0px_0px_6px_0px_#00000044]',
44
- userClassNames?.menu?.(props),
45
- ),
46
- menuList: (props) => cn('flex flex-col', userClassNames?.menuList?.(props)),
47
- option: (props) =>
48
- cn(
49
- 'overflow-x-hidden text-ellipsis px-4 py-1 shrink-0',
50
- !props.isSelected && props.isFocused ? 'bg-slate-100' : '',
51
- props.isSelected ? 'bg-brand text-white' : '',
52
- userClassNames?.option?.(props),
53
- ),
54
- noOptionsMessage: (props) => cn('px-4 py-1', userClassNames?.noOptionsMessage?.(props)),
55
- clearIndicator: (props) =>
56
- cn('cursor-pointer pointer-events-auto w-4 h-4', userClassNames?.clearIndicator?.(props)),
57
- indicatorsContainer: (props) =>
58
- cn('flex gap-1 items-center justify-center', userClassNames?.indicatorsContainer?.(props)),
59
- indicatorSeparator: (props) =>
60
- cn(
61
- props.isMulti && props.hasValue ? 'bg-border-input/30' : '',
62
- userClassNames?.indicatorSeparator?.(props),
63
- ),
64
- multiValue: (props) =>
65
- cn(
66
- 'flex gap-2 items-center justify-center px-2 bg-brand text-white m-[2px]',
67
- userClassNames?.multiValue?.(props),
68
- ),
69
- multiValueRemove: (props) => cn('w-3 h-3', userClassNames?.multiValueRemove?.(props)),
70
- };
71
- };
72
-
73
- // custom components should be defined outside the rendering, according to
74
- // https://react-select.com/components#defining-components
75
- const customDropdownIndicator = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
76
- props: DropdownIndicatorProps<Option, IsMulti, Group>,
77
- ) => {
78
- return <LuChevronDown className={props.getClassNames('dropdownIndicator', props)} />;
79
- };
80
-
81
- const customClearIndicator = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
82
- props: ClearIndicatorProps<Option, IsMulti, Group>,
83
- ) => {
84
- return (
85
- <components.ClearIndicator {...props}>
86
- <LuX className={props.getClassNames('clearIndicator', props)} />
87
- </components.ClearIndicator>
88
- );
89
- };
90
-
91
- const customMultiValueRemove = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
92
- props: MultiValueRemoveProps<Option, IsMulti, Group>,
93
- ) => {
94
- return (
95
- <components.MultiValueRemove {...props}>
96
- <LuX className="w-full h-full" />
97
- </components.MultiValueRemove>
98
- );
99
- };
100
-
101
- export const Select = <
102
- Option,
103
- IsMulti extends boolean = false,
104
- Group extends GroupBase<Option> = GroupBase<Option>,
105
- >({
106
- classNames: userClassNames,
107
- ...props
108
- }: SelectProps<Option, IsMulti, Group>) => {
109
- // use id to prevent hydration errors
110
- const id = useId();
111
-
112
- return (
113
- <ReactSelect
114
- {...props}
115
- instanceId={id}
116
- unstyled
117
- classNames={getClassNames<Option, IsMulti, Group>(userClassNames)}
118
- components={{
119
- DropdownIndicator: customDropdownIndicator,
120
- ClearIndicator: customClearIndicator,
121
- MultiValueRemove: customMultiValueRemove,
122
- }}
123
- />
124
- );
125
- };