@takaro/lib-components 0.0.0-next.0da151e

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 (430) hide show
  1. package/.babelrc +7 -0
  2. package/@types/files.d.ts +23 -0
  3. package/@types/react-table-config.d.ts +121 -0
  4. package/Dockerfile.dev +21 -0
  5. package/package.json +15 -0
  6. package/public/images/7-days-to-die/logo.png +0 -0
  7. package/public/images/csmm-icon.png +0 -0
  8. package/public/images/milk.png +0 -0
  9. package/public/images/placeholder-01.jpeg +0 -0
  10. package/public/images/placeholder-02.jpeg +0 -0
  11. package/public/images/placeholder-03.jpeg +0 -0
  12. package/public/images/rust/logo.png +0 -0
  13. package/readme.md +10 -0
  14. package/src/components/actions/Button/Button.stories.tsx +149 -0
  15. package/src/components/actions/Button/Button.test.tsx +8 -0
  16. package/src/components/actions/Button/Button.test.tsx.snap +89 -0
  17. package/src/components/actions/Button/__snapshots__/Button.test.tsx.snap +18 -0
  18. package/src/components/actions/Button/index.tsx +89 -0
  19. package/src/components/actions/Button/style.ts +142 -0
  20. package/src/components/actions/ContextMenu/ContextMenu.stories.tsx +41 -0
  21. package/src/components/actions/ContextMenu/Group.tsx +34 -0
  22. package/src/components/actions/ContextMenu/MenuItem.tsx +69 -0
  23. package/src/components/actions/ContextMenu/index.tsx +216 -0
  24. package/src/components/actions/Dropdown/Dropdown.stories.tsx +88 -0
  25. package/src/components/actions/Dropdown/DropdownContext.tsx +21 -0
  26. package/src/components/actions/Dropdown/DropdownMenu.tsx +70 -0
  27. package/src/components/actions/Dropdown/DropdownMenuGroup.tsx +37 -0
  28. package/src/components/actions/Dropdown/DropdownMenuItem.tsx +128 -0
  29. package/src/components/actions/Dropdown/DropdownTrigger.tsx +87 -0
  30. package/src/components/actions/Dropdown/index.tsx +22 -0
  31. package/src/components/actions/Dropdown/useDropdown.tsx +89 -0
  32. package/src/components/actions/DropdownButton/DropdownButton.stories.tsx +88 -0
  33. package/src/components/actions/DropdownButton/index.tsx +128 -0
  34. package/src/components/actions/IconButton/IconButton.stories.tsx +54 -0
  35. package/src/components/actions/IconButton/IconButton.test.tsx +8 -0
  36. package/src/components/actions/IconButton/IconButton.test.tsx.snap +46 -0
  37. package/src/components/actions/IconButton/__snapshots__/IconButton.test.tsx.snap +18 -0
  38. package/src/components/actions/IconButton/getIconSize.ts +16 -0
  39. package/src/components/actions/IconButton/index.tsx +28 -0
  40. package/src/components/actions/IconButton/style.ts +51 -0
  41. package/src/components/actions/ToggleButton/ToggleButton.stories.tsx +85 -0
  42. package/src/components/actions/ToggleButton/ToggleButton.tsx +48 -0
  43. package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +107 -0
  44. package/src/components/actions/ToggleButton/index.tsx +2 -0
  45. package/src/components/actions/ToggleButton/style.ts +75 -0
  46. package/src/components/actions/index.ts +16 -0
  47. package/src/components/charts/AreaChart/AreaChart.stories.tsx +103 -0
  48. package/src/components/charts/AreaChart/index.tsx +428 -0
  49. package/src/components/charts/BarChart/BarChart.stories.tsx +55 -0
  50. package/src/components/charts/BarChart/index.tsx +420 -0
  51. package/src/components/charts/BrushHandle.tsx +21 -0
  52. package/src/components/charts/EmptyChart.tsx +45 -0
  53. package/src/components/charts/GeoMercator/GeoMercator.stories.tsx +77 -0
  54. package/src/components/charts/GeoMercator/index.tsx +228 -0
  55. package/src/components/charts/GeoMercator/iso3166-alpha2-to-alpha3.ts +250 -0
  56. package/src/components/charts/GeoMercator/world.d.ts +1 -0
  57. package/src/components/charts/GeoMercator/world.json +99818 -0
  58. package/src/components/charts/Heatmap/Heatmap.stories.tsx +189 -0
  59. package/src/components/charts/Heatmap/index.tsx +461 -0
  60. package/src/components/charts/LineChart/LineChart.stories.tsx +111 -0
  61. package/src/components/charts/LineChart/index.tsx +353 -0
  62. package/src/components/charts/PieChart/PieChart.stories.tsx +151 -0
  63. package/src/components/charts/PieChart/index.tsx +457 -0
  64. package/src/components/charts/PointHighlight.tsx +49 -0
  65. package/src/components/charts/RadarChart/RadarChart.stories.tsx +47 -0
  66. package/src/components/charts/RadarChart/generators.ts +30 -0
  67. package/src/components/charts/RadarChart/index.tsx +224 -0
  68. package/src/components/charts/RadialBarChart/RadialBarChart.stories.tsx +59 -0
  69. package/src/components/charts/RadialBarChart/index.tsx +231 -0
  70. package/src/components/charts/RadialLineChart/RadialLineChart.stories.tsx +43 -0
  71. package/src/components/charts/RadialLineChart/index.tsx +231 -0
  72. package/src/components/charts/ZoomControls.tsx +49 -0
  73. package/src/components/charts/index.tsx +26 -0
  74. package/src/components/charts/useGradients.tsx +37 -0
  75. package/src/components/charts/util.ts +78 -0
  76. package/src/components/data/Avatar/Avatar.stories.tsx +93 -0
  77. package/src/components/data/Avatar/context.tsx +20 -0
  78. package/src/components/data/Avatar/index.tsx +136 -0
  79. package/src/components/data/Avatar/style.ts +124 -0
  80. package/src/components/data/Avatar/useImageLoadingStatus.tsx +32 -0
  81. package/src/components/data/Chip/Chip.stories.tsx +67 -0
  82. package/src/components/data/Chip/Chip.test.tsx +8 -0
  83. package/src/components/data/Chip/Chip.test.tsx.snap +50 -0
  84. package/src/components/data/Chip/__snapshots__/Chip.test.tsx.snap +38 -0
  85. package/src/components/data/Chip/index.tsx +67 -0
  86. package/src/components/data/Chip/style.ts +49 -0
  87. package/src/components/data/Console/Console.stories.tsx +51 -0
  88. package/src/components/data/Console/Console.tsx +125 -0
  89. package/src/components/data/Console/ConsoleInput/index.tsx +87 -0
  90. package/src/components/data/Console/ConsoleInput/style.ts +41 -0
  91. package/src/components/data/Console/ConsoleLine/index.tsx +127 -0
  92. package/src/components/data/Console/ConsoleLine/style.ts +76 -0
  93. package/src/components/data/Console/MessageModel.ts +9 -0
  94. package/src/components/data/Console/constants.ts +6 -0
  95. package/src/components/data/Console/index.tsx +4 -0
  96. package/src/components/data/Console/style.ts +31 -0
  97. package/src/components/data/Console/useConsoleLiveMode.ts +42 -0
  98. package/src/components/data/CopyId/CopyId.stories.tsx +36 -0
  99. package/src/components/data/CopyId/index.tsx +107 -0
  100. package/src/components/data/CountryList/index.tsx +146 -0
  101. package/src/components/data/DateFormatter/DateFormatter.stories.tsx +26 -0
  102. package/src/components/data/DateFormatter/index.tsx +15 -0
  103. package/src/components/data/Drawer/Drawer.stories.tsx +155 -0
  104. package/src/components/data/Drawer/DrawerBody.tsx +22 -0
  105. package/src/components/data/Drawer/DrawerContent.tsx +169 -0
  106. package/src/components/data/Drawer/DrawerContext.tsx +21 -0
  107. package/src/components/data/Drawer/DrawerFooter.tsx +19 -0
  108. package/src/components/data/Drawer/DrawerHeading.tsx +50 -0
  109. package/src/components/data/Drawer/DrawerSkeleton.tsx +29 -0
  110. package/src/components/data/Drawer/index.tsx +25 -0
  111. package/src/components/data/Drawer/useDrawer.tsx +66 -0
  112. package/src/components/data/InfiniteScroll/InfiniteScroll.stories.tsx +33 -0
  113. package/src/components/data/InfiniteScroll/index.tsx +54 -0
  114. package/src/components/data/Stats/Sparkline.tsx +48 -0
  115. package/src/components/data/Stats/Stat.tsx +192 -0
  116. package/src/components/data/Stats/Stats.stories.tsx +196 -0
  117. package/src/components/data/Stats/context.tsx +18 -0
  118. package/src/components/data/Stats/index.tsx +62 -0
  119. package/src/components/data/Table/Table.stories.tsx +146 -0
  120. package/src/components/data/Table/index.tsx +492 -0
  121. package/src/components/data/Table/react-table.d.ts +14 -0
  122. package/src/components/data/Table/style.ts +97 -0
  123. package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +164 -0
  124. package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +207 -0
  125. package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +90 -0
  126. package/src/components/data/Table/subcomponents/ColumnVisibility/index.tsx +70 -0
  127. package/src/components/data/Table/subcomponents/Filter/field.tsx +127 -0
  128. package/src/components/data/Table/subcomponents/Filter/index.tsx +228 -0
  129. package/src/components/data/Table/subcomponents/Filter/style.ts +26 -0
  130. package/src/components/data/Table/subcomponents/Filter/types.ts +10 -0
  131. package/src/components/data/Table/subcomponents/Pagination/PagePicker.tsx +109 -0
  132. package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
  133. package/src/components/data/Table/subcomponents/Pagination/style.ts +49 -0
  134. package/src/components/data/index.ts +28 -0
  135. package/src/components/dialogs/Dialog/Dialog.stories.tsx +77 -0
  136. package/src/components/dialogs/Dialog/DialogBody.tsx +64 -0
  137. package/src/components/dialogs/Dialog/DialogContent.tsx +44 -0
  138. package/src/components/dialogs/Dialog/DialogContext.tsx +21 -0
  139. package/src/components/dialogs/Dialog/DialogHeading.tsx +56 -0
  140. package/src/components/dialogs/Dialog/index.tsx +20 -0
  141. package/src/components/dialogs/Dialog/useDialog.tsx +50 -0
  142. package/src/components/feedback/Alert/Alert.stories.tsx +75 -0
  143. package/src/components/feedback/Alert/Alert.test.tsx +8 -0
  144. package/src/components/feedback/Alert/Alert.test.tsx.snap +146 -0
  145. package/src/components/feedback/Alert/__snapshots__/Alert.test.tsx.snap +44 -0
  146. package/src/components/feedback/Alert/index.tsx +120 -0
  147. package/src/components/feedback/Alert/style.ts +97 -0
  148. package/src/components/feedback/Badge/Badge.stories.tsx +23 -0
  149. package/src/components/feedback/Badge/index.tsx +47 -0
  150. package/src/components/feedback/ErrorFallback/ErrorFallback.stories.tsx +10 -0
  151. package/src/components/feedback/ErrorFallback/index.tsx +49 -0
  152. package/src/components/feedback/ErrorPage/ErrorPage.stories.tsx +31 -0
  153. package/src/components/feedback/ErrorPage/index.tsx +193 -0
  154. package/src/components/feedback/FormError/FormError.stories.tsx +25 -0
  155. package/src/components/feedback/FormError/index.tsx +54 -0
  156. package/src/components/feedback/IconTooltip/IconTooltip.stories.tsx +22 -0
  157. package/src/components/feedback/IconTooltip/index.tsx +51 -0
  158. package/src/components/feedback/Loaders/Loaders.stories.tsx +28 -0
  159. package/src/components/feedback/Loaders/Loading.test.tsx +8 -0
  160. package/src/components/feedback/Loaders/Loading.test.tsx.snap +141 -0
  161. package/src/components/feedback/Loaders/Loading.tsx +107 -0
  162. package/src/components/feedback/Loaders/Spinner.test.tsx +8 -0
  163. package/src/components/feedback/Loaders/Spinner.test.tsx.snap +18 -0
  164. package/src/components/feedback/Loaders/Spinner.tsx +74 -0
  165. package/src/components/feedback/Loaders/__snapshots__/Loading.test.tsx.snap +141 -0
  166. package/src/components/feedback/Loaders/__snapshots__/Spinner.test.tsx.snap +10 -0
  167. package/src/components/feedback/Loaders/index.ts +2 -0
  168. package/src/components/feedback/NetworkDetector/NetworkDetector.stories.tsx +21 -0
  169. package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx +8 -0
  170. package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx.snap +3 -0
  171. package/src/components/feedback/NetworkDetector/__snapshots__/NetworkDetector.test.tsx.snap +3 -0
  172. package/src/components/feedback/NetworkDetector/index.tsx +41 -0
  173. package/src/components/feedback/NotificationBanner/NotificationBanner.stories.tsx +13 -0
  174. package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +15 -0
  175. package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx.snap +3 -0
  176. package/src/components/feedback/NotificationBanner/__snapshots__/NotificationBanner.test.tsx.snap +3 -0
  177. package/src/components/feedback/NotificationBanner/index.tsx +78 -0
  178. package/src/components/feedback/Popover/Popover.stories.tsx +33 -0
  179. package/src/components/feedback/Popover/PopoverContent.tsx +46 -0
  180. package/src/components/feedback/Popover/PopoverContext.tsx +21 -0
  181. package/src/components/feedback/Popover/PopoverTrigger.tsx +45 -0
  182. package/src/components/feedback/Popover/index.tsx +22 -0
  183. package/src/components/feedback/Popover/usePopover.tsx +87 -0
  184. package/src/components/feedback/ProgressBar/ProgressBar.stories.tsx +38 -0
  185. package/src/components/feedback/ProgressBar/index.tsx +137 -0
  186. package/src/components/feedback/Skeleton/Skeleton.stories.tsx +33 -0
  187. package/src/components/feedback/Skeleton/Skeleton.test.tsx +8 -0
  188. package/src/components/feedback/Skeleton/Skeleton.test.tsx.snap +35 -0
  189. package/src/components/feedback/Skeleton/__snapshots__/Skeleton.test.tsx.snap +9 -0
  190. package/src/components/feedback/Skeleton/index.tsx +62 -0
  191. package/src/components/feedback/Tooltip/Tooltip.stories.tsx +69 -0
  192. package/src/components/feedback/Tooltip/TooltipContent.tsx +51 -0
  193. package/src/components/feedback/Tooltip/TooltipContext.tsx +13 -0
  194. package/src/components/feedback/Tooltip/TooltipTrigger.tsx +39 -0
  195. package/src/components/feedback/Tooltip/index.tsx +26 -0
  196. package/src/components/feedback/Tooltip/useTooltip.tsx +82 -0
  197. package/src/components/feedback/index.ts +37 -0
  198. package/src/components/feedback/snacks/CookieConsent/index.tsx +125 -0
  199. package/src/components/feedback/snacks/CookieConsent/style.ts +99 -0
  200. package/src/components/feedback/snacks/Default/default.stories.tsx +73 -0
  201. package/src/components/feedback/snacks/Default/index.tsx +78 -0
  202. package/src/components/feedback/snacks/Default/style.ts +58 -0
  203. package/src/components/feedback/snacks/Drawer/Drawer.stories.tsx +46 -0
  204. package/src/components/feedback/snacks/Drawer/index.tsx +85 -0
  205. package/src/components/feedback/snacks/NetworkDetector/index.tsx +73 -0
  206. package/src/components/feedback/snacks/index.d.ts +15 -0
  207. package/src/components/feedback/snacks/index.ts +8 -0
  208. package/src/components/index.ts +9 -0
  209. package/src/components/inputs/CheckBox/CheckBox.stories.tsx +64 -0
  210. package/src/components/inputs/CheckBox/Controlled.tsx +123 -0
  211. package/src/components/inputs/CheckBox/Generic.tsx +42 -0
  212. package/src/components/inputs/CheckBox/index.tsx +4 -0
  213. package/src/components/inputs/CheckBox/style.ts +56 -0
  214. package/src/components/inputs/CodeField/CodeField.stories.tsx +86 -0
  215. package/src/components/inputs/CodeField/index.tsx +174 -0
  216. package/src/components/inputs/CodeField/style.ts +50 -0
  217. package/src/components/inputs/Date/DatePicker/Controlled.tsx +103 -0
  218. package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +267 -0
  219. package/src/components/inputs/Date/DatePicker/Generic.tsx +283 -0
  220. package/src/components/inputs/Date/DatePicker/formats.tsx +32 -0
  221. package/src/components/inputs/Date/DatePicker/style.ts +41 -0
  222. package/src/components/inputs/Date/DateRangePicker/Context.tsx +123 -0
  223. package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
  224. package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +37 -0
  225. package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +98 -0
  226. package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +54 -0
  227. package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +49 -0
  228. package/src/components/inputs/Date/DateRangePicker/Generic.tsx +167 -0
  229. package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +254 -0
  230. package/src/components/inputs/Date/DateRangePicker/QuickSelect/style.ts +40 -0
  231. package/src/components/inputs/Date/DateRangePicker/style.ts +65 -0
  232. package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +150 -0
  233. package/src/components/inputs/Date/subcomponents/Calendar/style.ts +61 -0
  234. package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +170 -0
  235. package/src/components/inputs/Date/subcomponents/RelativePicker/style.ts +50 -0
  236. package/src/components/inputs/Date/subcomponents/TimePicker/TimePicker.stories.tsx +25 -0
  237. package/src/components/inputs/Date/subcomponents/TimePicker/index.tsx +40 -0
  238. package/src/components/inputs/Date/subcomponents/TimePicker/style.ts +34 -0
  239. package/src/components/inputs/Date/types.ts +14 -0
  240. package/src/components/inputs/DurationField/Controlled.tsx +69 -0
  241. package/src/components/inputs/DurationField/Duration.stories.tsx +57 -0
  242. package/src/components/inputs/DurationField/Generic.tsx +197 -0
  243. package/src/components/inputs/DurationField/__tests__/Generic.test.tsx +12 -0
  244. package/src/components/inputs/DurationField/index.tsx +5 -0
  245. package/src/components/inputs/DurationField/style.ts +42 -0
  246. package/src/components/inputs/EditableField/EditableField.stories.tsx +65 -0
  247. package/src/components/inputs/EditableField/index.tsx +135 -0
  248. package/src/components/inputs/EditableField/style.ts +11 -0
  249. package/src/components/inputs/FileField/Controlled.tsx +104 -0
  250. package/src/components/inputs/FileField/FileField.stories.tsx +210 -0
  251. package/src/components/inputs/FileField/Generic.tsx +133 -0
  252. package/src/components/inputs/FileField/index.tsx +5 -0
  253. package/src/components/inputs/FileField/style.ts +34 -0
  254. package/src/components/inputs/InputProps.ts +59 -0
  255. package/src/components/inputs/RadioGroup/Controlled.tsx +45 -0
  256. package/src/components/inputs/RadioGroup/Generic.tsx +34 -0
  257. package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +118 -0
  258. package/src/components/inputs/RadioGroup/RadioItem.tsx +130 -0
  259. package/src/components/inputs/RadioGroup/context.tsx +20 -0
  260. package/src/components/inputs/RadioGroup/index.ts +5 -0
  261. package/src/components/inputs/RadioGroup/style.ts +3 -0
  262. package/src/components/inputs/Switch/Controlled.tsx +57 -0
  263. package/src/components/inputs/Switch/Generic.tsx +40 -0
  264. package/src/components/inputs/Switch/Switch.stories.tsx +89 -0
  265. package/src/components/inputs/Switch/index.ts +5 -0
  266. package/src/components/inputs/Switch/style.ts +62 -0
  267. package/src/components/inputs/TagField/Controlled.tsx +103 -0
  268. package/src/components/inputs/TagField/Generic.tsx +138 -0
  269. package/src/components/inputs/TagField/TagField.stories.tsx +68 -0
  270. package/src/components/inputs/TagField/index.ts +5 -0
  271. package/src/components/inputs/TagField/style.ts +25 -0
  272. package/src/components/inputs/TagField/util.ts +34 -0
  273. package/src/components/inputs/TextAreaField/Controlled.tsx +101 -0
  274. package/src/components/inputs/TextAreaField/Generic.tsx +58 -0
  275. package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +99 -0
  276. package/src/components/inputs/TextAreaField/index.ts +5 -0
  277. package/src/components/inputs/TextAreaField/style.ts +28 -0
  278. package/src/components/inputs/TextField/Controlled.tsx +120 -0
  279. package/src/components/inputs/TextField/Generic.tsx +138 -0
  280. package/src/components/inputs/TextField/TextField.stories.tsx +217 -0
  281. package/src/components/inputs/TextField/index.ts +5 -0
  282. package/src/components/inputs/TextField/style.ts +103 -0
  283. package/src/components/inputs/TextField/util.ts +24 -0
  284. package/src/components/inputs/ValueConfirmationField/ValueConfirmationField.stories.tsx +33 -0
  285. package/src/components/inputs/ValueConfirmationField/index.tsx +54 -0
  286. package/src/components/inputs/index.ts +72 -0
  287. package/src/components/inputs/layout/Description.tsx +33 -0
  288. package/src/components/inputs/layout/ErrorMessage/ErrorMessage.stories.tsx +28 -0
  289. package/src/components/inputs/layout/ErrorMessage/index.tsx +63 -0
  290. package/src/components/inputs/layout/InputWrapper.ts +6 -0
  291. package/src/components/inputs/layout/Label/index.tsx +71 -0
  292. package/src/components/inputs/layout/Label/style.ts +50 -0
  293. package/src/components/inputs/layout/index.ts +8 -0
  294. package/src/components/inputs/layout/setAriaDescribedBy.ts +3 -0
  295. package/src/components/inputs/selects/SelectField/Controlled.tsx +127 -0
  296. package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +48 -0
  297. package/src/components/inputs/selects/SelectField/Generic/index.tsx +299 -0
  298. package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +252 -0
  299. package/src/components/inputs/selects/SelectField/index.ts +5 -0
  300. package/src/components/inputs/selects/SelectField/style.ts +29 -0
  301. package/src/components/inputs/selects/SelectQueryField/Controlled.tsx +110 -0
  302. package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +401 -0
  303. package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +280 -0
  304. package/src/components/inputs/selects/SelectQueryField/index.tsx +5 -0
  305. package/src/components/inputs/selects/SelectQueryField/style.ts +13 -0
  306. package/src/components/inputs/selects/SubComponents/Option.tsx +114 -0
  307. package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +18 -0
  308. package/src/components/inputs/selects/SubComponents/index.ts +10 -0
  309. package/src/components/inputs/selects/SubComponents/style.ts +51 -0
  310. package/src/components/inputs/selects/data.ts +123 -0
  311. package/src/components/inputs/selects/index.tsx +49 -0
  312. package/src/components/inputs/selects/sharedStyle.ts +76 -0
  313. package/src/components/layout/Container/index.ts +21 -0
  314. package/src/components/layout/index.ts +1 -0
  315. package/src/components/navigation/HorizontalNav/HorizontalNav.stories.tsx +29 -0
  316. package/src/components/navigation/HorizontalNav/index.tsx +13 -0
  317. package/src/components/navigation/HorizontalNav/style.ts +93 -0
  318. package/src/components/navigation/IconNav/IconNav.stories.tsx +46 -0
  319. package/src/components/navigation/IconNav/index.tsx +50 -0
  320. package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +90 -0
  321. package/src/components/navigation/Steppers/SlimStepper/index.tsx +104 -0
  322. package/src/components/navigation/Steppers/SlimStepper/style.ts +85 -0
  323. package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +88 -0
  324. package/src/components/navigation/Steppers/Stepper/index.tsx +114 -0
  325. package/src/components/navigation/Steppers/Stepper/style.ts +106 -0
  326. package/src/components/navigation/Steppers/context.tsx +2 -0
  327. package/src/components/navigation/Steppers/provider.tsx +18 -0
  328. package/src/components/navigation/Steppers/reducer.ts +51 -0
  329. package/src/components/navigation/Steppers/stepStates.ts +5 -0
  330. package/src/components/navigation/Steppers/useStepper.ts +34 -0
  331. package/src/components/navigation/Tabs/Content.tsx +39 -0
  332. package/src/components/navigation/Tabs/Context.tsx +21 -0
  333. package/src/components/navigation/Tabs/List.tsx +17 -0
  334. package/src/components/navigation/Tabs/Tabs.stories.tsx +119 -0
  335. package/src/components/navigation/Tabs/Trigger.tsx +66 -0
  336. package/src/components/navigation/Tabs/index.tsx +35 -0
  337. package/src/components/navigation/Tabs/useTabs.tsx +28 -0
  338. package/src/components/navigation/index.ts +17 -0
  339. package/src/components/other/ActionMenu/ActionMenu.stories.tsx +81 -0
  340. package/src/components/other/ActionMenu/index.tsx +62 -0
  341. package/src/components/other/ActionMenu/style.ts +47 -0
  342. package/src/components/other/ClipBoard/ClipBoard.stories.tsx +14 -0
  343. package/src/components/other/ClipBoard/ClipBoard.test.tsx +8 -0
  344. package/src/components/other/ClipBoard/ClipBoard.test.tsx.snap +70 -0
  345. package/src/components/other/ClipBoard/__snapshots__/ClipBoard.test.tsx.snap +36 -0
  346. package/src/components/other/ClipBoard/index.tsx +70 -0
  347. package/src/components/other/CollapseList/CollapseList.stories.tsx +21 -0
  348. package/src/components/other/CollapseList/index.tsx +110 -0
  349. package/src/components/other/Collapsible/Collapsible.stories.tsx +19 -0
  350. package/src/components/other/Collapsible/CollapsibleContent.tsx +29 -0
  351. package/src/components/other/Collapsible/CollapsibleContext.tsx +17 -0
  352. package/src/components/other/Collapsible/CollapsibleTrigger.tsx +83 -0
  353. package/src/components/other/Collapsible/index.tsx +21 -0
  354. package/src/components/other/Company/index.tsx +44 -0
  355. package/src/components/other/Company/style.ts +58 -0
  356. package/src/components/other/Empty/Empty.stories.tsx +28 -0
  357. package/src/components/other/Empty/Empty.test.tsx +10 -0
  358. package/src/components/other/Empty/Empty.test.tsx.snap +85 -0
  359. package/src/components/other/Empty/__snapshots__/Empty.test.tsx.snap +21 -0
  360. package/src/components/other/Empty/index.tsx +85 -0
  361. package/src/components/other/PermissionsGuard/PermissionsGuard.stories.tsx +55 -0
  362. package/src/components/other/PermissionsGuard/hasPermissionsHelper.ts +18 -0
  363. package/src/components/other/PermissionsGuard/index.tsx +27 -0
  364. package/src/components/other/Plan/Plan.stories.tsx +21 -0
  365. package/src/components/other/Plan/index.tsx +92 -0
  366. package/src/components/other/Plan/style.ts +61 -0
  367. package/src/components/other/Usage/Usage.stories.tsx +21 -0
  368. package/src/components/other/Usage/Usage.tsx +35 -0
  369. package/src/components/other/Usage/UsageCard.stories.tsx +31 -0
  370. package/src/components/other/Usage/UsageCard.tsx +88 -0
  371. package/src/components/other/index.ts +27 -0
  372. package/src/components/visual/Card/Card.stories.tsx +22 -0
  373. package/src/components/visual/Card/CardBody.tsx +11 -0
  374. package/src/components/visual/Card/CardTitle.tsx +29 -0
  375. package/src/components/visual/Card/index.tsx +58 -0
  376. package/src/components/visual/Divider/Divider.stories.tsx +19 -0
  377. package/src/components/visual/Divider/Divider.test.tsx +8 -0
  378. package/src/components/visual/Divider/Divider.test.tsx.snap +35 -0
  379. package/src/components/visual/Divider/__snapshots__/Divider.test.tsx.snap +13 -0
  380. package/src/components/visual/Divider/index.tsx +88 -0
  381. package/src/components/visual/Flag/index.tsx +61 -0
  382. package/src/components/visual/index.ts +8 -0
  383. package/src/errors/base.ts +14 -0
  384. package/src/errors/errors.ts +126 -0
  385. package/src/errors/index.ts +14 -0
  386. package/src/helpers/camelCaseToSpaces.ts +5 -0
  387. package/src/helpers/formatNumber.ts +6 -0
  388. package/src/helpers/getInitials.ts +16 -0
  389. package/src/helpers/getSnackbarProvider.tsx +57 -0
  390. package/src/helpers/getTransition.ts +9 -0
  391. package/src/helpers/index.ts +6 -0
  392. package/src/helpers/makeData.ts +34 -0
  393. package/src/helpers/regexprs.ts +9 -0
  394. package/src/hooks/index.ts +9 -0
  395. package/src/hooks/useCallbackRef.tsx +17 -0
  396. package/src/hooks/useDebounce.tsx +22 -0
  397. package/src/hooks/useFocus.tsx +12 -0
  398. package/src/hooks/useLocalStorage.tsx +35 -0
  399. package/src/hooks/useLockScroll.ts +26 -0
  400. package/src/hooks/useOnScreen.ts +24 -0
  401. package/src/hooks/useOutsideAlerter.tsx +15 -0
  402. package/src/hooks/useTableActions.ts +61 -0
  403. package/src/hooks/useTheme.tsx +7 -0
  404. package/src/images/company-icon-primary.svg +3 -0
  405. package/src/images/company-icon-secondary.svg +3 -0
  406. package/src/images/index.ts +4 -0
  407. package/src/index.ts +9 -0
  408. package/src/stories/Colors.mdx +35 -0
  409. package/src/stories/Introduction.mdx +17 -0
  410. package/src/stories/Spacing.mdx +25 -0
  411. package/src/styled/GlobalStyle.ts +209 -0
  412. package/src/styled/Snackbar.tsx +41 -0
  413. package/src/styled/animations.ts +36 -0
  414. package/src/styled/breakpoint.ts +7 -0
  415. package/src/styled/device.ts +10 -0
  416. package/src/styled/index.ts +10 -0
  417. package/src/styled/spacing.ts +38 -0
  418. package/src/styled/theme.tsx +110 -0
  419. package/src/styled/types.ts +5 -0
  420. package/src/styled/zIndex.ts +31 -0
  421. package/src/test/__mocks__/fileMock.ts +2 -0
  422. package/src/test/setupTests.ts +3 -0
  423. package/src/test/snapshotResolver.js +21 -0
  424. package/src/test/testUtils.tsx +34 -0
  425. package/src/types/index.ts +1 -0
  426. package/src/types/json.ts +5 -0
  427. package/src/views/LoadingPage.tsx +36 -0
  428. package/src/views/index.ts +1 -0
  429. package/tsconfig.json +14 -0
  430. package/vite.config.mts +17 -0
@@ -0,0 +1,41 @@
1
+ import { styled } from '../../../../styled';
2
+ import { AiOutlineEnter as EnterIcon } from 'react-icons/ai';
3
+
4
+ export const Container = styled.div`
5
+ position: relative;
6
+ display: flex;
7
+ flex-direction: row;
8
+ width: 100%;
9
+ align-items: center;
10
+ input {
11
+ position: relative;
12
+ width: 100%;
13
+ background-color: ${({ theme }) => theme.colors.backgroundAlt};
14
+ border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
15
+ color: white;
16
+ font-size: 110%;
17
+ height: 40px;
18
+ font-weight: 500;
19
+ font-family: 'inconsolata';
20
+ border-radius: 0;
21
+ padding-right: ${({ theme }) => theme.spacing[6]};
22
+ ::placeholder {
23
+ color: white;
24
+ }
25
+ border-bottom-left-radius: 1rem;
26
+ border-bottom-right-radius: 1rem;
27
+ }
28
+
29
+ span {
30
+ font-family: 'inconsolata';
31
+ color: black;
32
+ font-weight: 500;
33
+ margin-left: ${({ theme }) => theme.spacing[1]};
34
+ }
35
+ `;
36
+
37
+ export const StyledEnterIcon = styled(EnterIcon)`
38
+ position: absolute;
39
+ right: 2rem;
40
+ cursor: pointer;
41
+ `;
@@ -0,0 +1,127 @@
1
+ import { CSSProperties, FC, ReactElement, useEffect, useMemo, useRef, useState } from 'react';
2
+ import {
3
+ AiFillWarning as WarningIcon,
4
+ AiFillCloseCircle as ErrorIcon,
5
+ AiFillBug as DebugIcon,
6
+ AiFillInfoCircle as InfoIcon,
7
+ AiFillMacCommand as CommandIcon,
8
+ } from 'react-icons/ai';
9
+ import { Tooltip } from '../../../../components';
10
+ import { BsChevronExpand as EnterIcon } from 'react-icons/bs';
11
+ import {
12
+ Wrapper,
13
+ Container,
14
+ Body,
15
+ Header,
16
+ IconContainer,
17
+ TimestampContainer,
18
+ TextContainer,
19
+ CollapsedContainer,
20
+ ExpandIconContainer,
21
+ } from './style';
22
+ import { Message, MessageType } from '../MessageModel';
23
+ import { GUTTER_SIZE, LIST_PADDING_SIZE } from '../constants';
24
+
25
+ const COLLAPSED_LENGTH = 125;
26
+
27
+ interface ConsoleLineProps {
28
+ message: Message;
29
+ index: number;
30
+ collapsed: boolean;
31
+ style: CSSProperties;
32
+ setRowState: (i: number, height: number, collapsed: boolean) => void;
33
+ }
34
+
35
+ export const ConsoleLine: FC<ConsoleLineProps> = ({ message, collapsed, style, index, setRowState }) => {
36
+ const { data, type, timestamp } = message;
37
+
38
+ const canCollapse = useMemo(() => {
39
+ if (!message.data) return false;
40
+ if (message.type === 'command') return true;
41
+
42
+ // TODO: should calculate the max chars per line based on the font constant, font size and textcontent container
43
+ return message.data.length > COLLAPSED_LENGTH;
44
+ }, [index]);
45
+
46
+ const [isCollapsed, setIsCollapsed] = useState<boolean>(collapsed);
47
+ const rowRef = useRef<HTMLDivElement>(null);
48
+ const containerRef = useRef<HTMLDivElement>(null);
49
+
50
+ useEffect(() => {
51
+ if (containerRef.current) {
52
+ setRowState(index, containerRef.current.clientHeight, isCollapsed);
53
+ }
54
+ }, [rowRef, isCollapsed]);
55
+
56
+ function defineCollapsableMessageLayout(): ReactElement {
57
+ let header = '';
58
+ let body = '';
59
+
60
+ if (type === 'command') {
61
+ if (message.result == undefined) {
62
+ throw new Error('Command messages should have a return type');
63
+ }
64
+ header = data;
65
+ body = message.result;
66
+ } else {
67
+ // TODO: maybe the header should contain the max on line with ...
68
+ // and the body the entire message?
69
+ header = data.split('\n')[0];
70
+ body = data.split('\n').slice(1).join('\n');
71
+ }
72
+
73
+ return (
74
+ <CollapsedContainer>
75
+ <Header isCollapsed={isCollapsed} type={type}>
76
+ <p>{header}</p>
77
+ {body && (
78
+ <Tooltip>
79
+ <Tooltip.Trigger asChild>
80
+ <ExpandIconContainer>
81
+ <EnterIcon onClick={() => setIsCollapsed(!isCollapsed)} size={14} />
82
+ </ExpandIconContainer>
83
+ </Tooltip.Trigger>
84
+ <Tooltip.Content>{isCollapsed ? 'show body' : 'collapse body'}</Tooltip.Content>
85
+ </Tooltip>
86
+ )}
87
+ </Header>
88
+ <Body isCollapsed={isCollapsed} type={type}>
89
+ {body}
90
+ </Body>
91
+ </CollapsedContainer>
92
+ );
93
+ }
94
+
95
+ const setIcon = (messageType: MessageType): ReactElement => {
96
+ switch (messageType) {
97
+ case 'info':
98
+ return <InfoIcon size={14} />;
99
+ case 'warning':
100
+ return <WarningIcon size={14} />;
101
+ case 'debug':
102
+ return <DebugIcon size={14} />;
103
+ case 'error':
104
+ return <ErrorIcon size={14} />;
105
+ case 'command':
106
+ return <CommandIcon size={14} />;
107
+ }
108
+ };
109
+
110
+ return (
111
+ <Wrapper
112
+ messageType={type}
113
+ style={{
114
+ ...style,
115
+ top: `${(style.top as number) + GUTTER_SIZE + LIST_PADDING_SIZE}px`,
116
+ height: `${(style.height as number) - GUTTER_SIZE}px`,
117
+ }}
118
+ ref={rowRef}
119
+ >
120
+ <Container isCollapsed={isCollapsed} ref={containerRef}>
121
+ <IconContainer messageType={type}>{setIcon(type)}</IconContainer>
122
+ <TimestampContainer>[{timestamp}]</TimestampContainer>
123
+ {canCollapse ? defineCollapsableMessageLayout() : <TextContainer>{data}</TextContainer>}
124
+ </Container>
125
+ </Wrapper>
126
+ );
127
+ };
@@ -0,0 +1,76 @@
1
+ import { styled } from '../../../../styled';
2
+ import { MessageType } from '../MessageModel';
3
+
4
+ export const Wrapper = styled.div<{
5
+ messageType: MessageType;
6
+ }>`
7
+ display: flex;
8
+ flex-direction: row;
9
+ position: relative;
10
+ font-family: 'inconsolata';
11
+ width: 100%;
12
+ border-bottom: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
13
+
14
+ &:last-child {
15
+ border-bottom: none;
16
+ }
17
+ `;
18
+
19
+ export const Container = styled.div<{ isCollapsed: boolean }>`
20
+ max-width: 100%;
21
+ width: 100%;
22
+ height: fit-content;
23
+ display: grid;
24
+ align-content: start;
25
+ grid-template-columns: 4rem 18rem 1fr;
26
+ margin: ${({ theme }) => theme.spacing[0]};
27
+ `;
28
+
29
+ export const IconContainer = styled.div<{ messageType: MessageType }>`
30
+ padding-left: ${({ theme }) => theme.spacing['0_75']};
31
+ display: flex;
32
+ align-items: center;
33
+ svg {
34
+ fill: ${({ theme, messageType }) => {
35
+ if (messageType === 'debug') return theme.colors.error;
36
+ if (messageType === 'command') return theme.colors.primary;
37
+ return theme.colors[messageType];
38
+ }};
39
+ }
40
+ `;
41
+
42
+ export const TimestampContainer = styled.div`
43
+ font-family: 'inconsolata';
44
+ `;
45
+
46
+ export const TextContainer = styled.div`
47
+ font-family: 'inconsolata';
48
+ font-size: ${({ theme }) => theme.fontSize.medium};
49
+ color: ${({ theme }) => theme.colors.text};
50
+ `;
51
+
52
+ export const CollapsedContainer = styled.div`
53
+ display: flex;
54
+ flex-direction: column;
55
+ `;
56
+
57
+ export const Header = styled.div<{ isCollapsed: boolean; type: MessageType }>`
58
+ display: flex;
59
+ flex-direction: row;
60
+ align-items: center;
61
+ p {
62
+ font-family: 'inconsolata';
63
+ }
64
+ `;
65
+
66
+ export const Body = styled.pre<{ isCollapsed: boolean; type: MessageType }>`
67
+ display: ${({ isCollapsed }) => (isCollapsed ? 'none' : 'block')};
68
+ font-family: 'inconsolata';
69
+ margin: 0;
70
+ `;
71
+
72
+ export const ExpandIconContainer = styled.span`
73
+ position: absolute;
74
+ cursor: pointer;
75
+ right: ${({ theme }) => theme.spacing['2']};
76
+ `;
@@ -0,0 +1,9 @@
1
+ export type MessageType = 'info' | 'warning' | 'error' | 'debug' | 'command';
2
+
3
+ export interface Message {
4
+ type: MessageType;
5
+ timestamp: string;
6
+ data: string;
7
+ // in case it is a command
8
+ result?: string;
9
+ }
@@ -0,0 +1,6 @@
1
+ export const DEFAULT_LINE_HEIGHT = 25;
2
+ export const GUTTER_SIZE = 10;
3
+ /* TODO: this does not work with the scrollitemto because it has no knowledge of the padding.
4
+ * https://gist.github.com/ValentinJS/4f3738ed426cac183e8446c869b162dd might be an option.
5
+ */
6
+ export const LIST_PADDING_SIZE = 0;
@@ -0,0 +1,4 @@
1
+ export { Console } from './Console';
2
+ export type { ConsoleProps } from './Console';
3
+
4
+ export type { Message } from './MessageModel';
@@ -0,0 +1,31 @@
1
+ import { styled } from '../../../styled';
2
+
3
+ export const Wrapper = styled.div`
4
+ height: 100%;
5
+ font-weight: 500;
6
+ border-left: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
7
+ border-right: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
8
+ position: relative;
9
+ border-top-right-radius: ${({ theme }) => theme.borderRadius.large};
10
+ border-top-left-radius: ${({ theme }) => theme.borderRadius.large};
11
+ `;
12
+
13
+ export const Header = styled.div`
14
+ background-color: ${({ theme }) => theme.colors.backgroundAlt};
15
+ border-bottom: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
16
+ border-top: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
17
+ height: 50px;
18
+ display: flex;
19
+ gap: ${({ theme }) => theme.spacing[1]};
20
+ align-items: center;
21
+ justify-content: flex-end;
22
+ padding: 0 ${({ theme }) => theme.spacing[1]};
23
+ border-top-left-radius: 1rem;
24
+ border-top-right-radius: 1rem;
25
+ `;
26
+
27
+ export const MessageContainer = styled.div`
28
+ min-height: 550px;
29
+ height: calc(100% - 50px);
30
+ border-radius: 0;
31
+ `;
@@ -0,0 +1,42 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { Message } from './MessageModel';
3
+
4
+ export function useConsoleLiveModeScrolling(messages: Message[]) {
5
+ const [isLiveModeEnabled, setIsLiveModeEnabled] = useState<boolean>(true);
6
+ const [scrollOffset, setScrollOffset] = useState<number>(0);
7
+
8
+ // unfortunately the react-window libraries does not have up to date types
9
+ const consoleMessagesBoxRef = useRef<null | any>(null);
10
+
11
+ // scrolls to the latest message
12
+ const scrollNewMessages = useCallback(() => {
13
+ consoleMessagesBoxRef.current?.scrollToItem(messages.length, 'end');
14
+ }, [messages]);
15
+
16
+ const toggleLiveModeOnConsoleScroll = useCallback(() => {
17
+ if (consoleMessagesBoxRef.current) {
18
+ // in case we are scrolling down, don't do anything.
19
+ if (consoleMessagesBoxRef.current.state.scrollDirection === 'forward') {
20
+ return;
21
+ }
22
+
23
+ if (consoleMessagesBoxRef.current.state.scrollOffset < scrollOffset) {
24
+ setIsLiveModeEnabled(false);
25
+ }
26
+ setScrollOffset(consoleMessagesBoxRef.current.state.scrollOffset);
27
+ }
28
+ }, [scrollOffset]);
29
+
30
+ useEffect(() => {
31
+ if (isLiveModeEnabled) {
32
+ scrollNewMessages();
33
+ }
34
+ }, [messages, isLiveModeEnabled, scrollNewMessages]);
35
+
36
+ return {
37
+ consoleMessagesBoxRef,
38
+ isLiveModeEnabled,
39
+ setIsLiveModeEnabled,
40
+ toggleLiveModeOnConsoleScroll,
41
+ };
42
+ }
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { Meta, StoryFn } from '@storybook/react';
3
+ import { styled } from '../../../styled';
4
+ import { CopyId, CopyIdProps } from '../../../components';
5
+
6
+ const Wrapper = styled.div`
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ justify-content: center;
11
+ padding: 5rem;
12
+ background: ${({ theme }) => theme.colors.background};
13
+ text-align: left;
14
+
15
+ & > div {
16
+ margin: 1rem;
17
+ }
18
+ `;
19
+
20
+ export default {
21
+ title: 'Data/CopyId',
22
+ component: CopyId,
23
+ decorators: [(story) => <Wrapper>{story()}</Wrapper>],
24
+ args: {
25
+ id: '3141592653589793238462643383279',
26
+ },
27
+ } as Meta<CopyIdProps>;
28
+
29
+ export const Default: StoryFn<CopyIdProps> = (args) => <CopyId {...args} />;
30
+
31
+ export const CustomPlaceholder: StoryObj<CopyIdProps> = {
32
+ args: {
33
+ placeholder: 'custom placeholder',
34
+ id: '3141592653589793238462643383279',
35
+ },
36
+ };
@@ -0,0 +1,107 @@
1
+ import { FC, useEffect, useState } from 'react';
2
+ import { Chip, Tooltip } from '../../../components';
3
+ import { AiFillCopy as CopyIcon, AiOutlineCheck as CheckmarkIcon, AiOutlineLink as LinkIcon } from 'react-icons/ai';
4
+ import { styled } from '../../../styled';
5
+
6
+ const Container = styled.div`
7
+ display: inline-flex;
8
+ align-items: center;
9
+ gap: ${({ theme }) => theme.spacing['0_5']};
10
+ `;
11
+
12
+ const LinkButton = styled.button`
13
+ display: inline-flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ background-color: ${({ theme }) => theme.colors.backgroundAlt};
17
+ border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
18
+ cursor: pointer;
19
+ padding: ${({ theme }) => theme.spacing['0_5']};
20
+ border-radius: ${({ theme }) => theme.borderRadius.small};
21
+ transition: all 0.2s ease;
22
+
23
+ &:hover {
24
+ background-color: ${({ theme }) => theme.colors.primary};
25
+ border-color: ${({ theme }) => theme.colors.primary};
26
+
27
+ svg {
28
+ color: ${({ theme }) => theme.colors.white};
29
+ }
30
+ }
31
+
32
+ svg {
33
+ width: 16px;
34
+ height: 16px;
35
+ color: ${({ theme }) => theme.colors.primary};
36
+ }
37
+ `;
38
+
39
+ export interface CopyIdProps {
40
+ id?: string;
41
+ placeholder?: string;
42
+ copyText?: string;
43
+ externalLink?: string;
44
+ externalLinkTooltip?: string;
45
+ }
46
+
47
+ export const CopyId: FC<CopyIdProps> = ({
48
+ id,
49
+ placeholder,
50
+ copyText = 'copied',
51
+ externalLink,
52
+ externalLinkTooltip = 'Open external link',
53
+ }) => {
54
+ const [copied, setCopied] = useState<boolean>(false);
55
+
56
+ function handleCopy(text: string) {
57
+ setCopied(true);
58
+ navigator.clipboard.writeText(text);
59
+ }
60
+
61
+ useEffect(() => {
62
+ /* If it was copied, show a checkmark for 2.5s thn make it possible to copy again */
63
+ if (copied) {
64
+ setTimeout(() => {
65
+ setCopied(false);
66
+ }, 2500);
67
+ }
68
+ }, [copied]);
69
+
70
+ if (!id) return <></>;
71
+
72
+ if (externalLink) {
73
+ return (
74
+ <Container>
75
+ <Chip
76
+ icon={copied ? <CheckmarkIcon /> : <CopyIcon />}
77
+ onClick={() => handleCopy(id)}
78
+ label={copied ? copyText : placeholder ? placeholder : id}
79
+ color="backgroundAccent"
80
+ />
81
+ <Tooltip>
82
+ <Tooltip.Trigger asChild>
83
+ <LinkButton
84
+ onClick={(e) => {
85
+ e.stopPropagation();
86
+ window.open(externalLink, '_blank', 'noopener,noreferrer');
87
+ }}
88
+ aria-label={externalLinkTooltip}
89
+ >
90
+ <LinkIcon />
91
+ </LinkButton>
92
+ </Tooltip.Trigger>
93
+ <Tooltip.Content>{externalLinkTooltip}</Tooltip.Content>
94
+ </Tooltip>
95
+ </Container>
96
+ );
97
+ }
98
+
99
+ return (
100
+ <Chip
101
+ icon={copied ? <CheckmarkIcon /> : <CopyIcon />}
102
+ onClick={() => handleCopy(id)}
103
+ label={copied ? copyText : placeholder ? placeholder : id}
104
+ color="backgroundAccent"
105
+ />
106
+ );
107
+ };
@@ -0,0 +1,146 @@
1
+ import { styled } from '../../../styled';
2
+ import { Flag } from '../../visual/Flag';
3
+ import { alpha2ToAlpha3 } from '../../charts/GeoMercator/iso3166-alpha2-to-alpha3';
4
+
5
+ const alpha3ToAlpha2: Record<string, string> = Object.entries(alpha2ToAlpha3).reduce(
6
+ (acc, [alpha2, alpha3]) => {
7
+ acc[alpha3] = alpha2;
8
+ return acc;
9
+ },
10
+ {} as Record<string, string>,
11
+ );
12
+
13
+ const Container = styled.div`
14
+ width: 320px;
15
+ min-width: 320px;
16
+ flex-shrink: 0;
17
+ height: 100%;
18
+ overflow: auto;
19
+ background-color: ${({ theme }) => theme.colors.backgroundAlt};
20
+ border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
21
+ border-radius: ${({ theme }) => theme.borderRadius.medium};
22
+ padding: ${({ theme }) => theme.spacing['3']};
23
+ `;
24
+
25
+ const Title = styled.h3`
26
+ margin: 0 0 ${({ theme }) => theme.spacing['2']} 0;
27
+ font-size: ${({ theme }) => theme.fontSize.tiny};
28
+ font-weight: 500;
29
+ color: ${({ theme }) => theme.colors.textAlt};
30
+ text-transform: uppercase;
31
+ letter-spacing: 0.5px;
32
+ `;
33
+
34
+ const CountryGrid = styled.div`
35
+ display: grid;
36
+ grid-template-columns: 1fr 1fr;
37
+ gap: ${({ theme }) => theme.spacing['2']};
38
+ `;
39
+
40
+ const CountryTable = styled.div`
41
+ display: table;
42
+ width: 100%;
43
+ font-size: ${({ theme }) => theme.fontSize.small};
44
+ border-collapse: collapse;
45
+ `;
46
+
47
+ const CountryRow = styled.div`
48
+ display: table-row;
49
+
50
+ &:hover {
51
+ background-color: ${({ theme }) => theme.colors.backgroundAccent};
52
+ }
53
+
54
+ &:last-child > div {
55
+ border-bottom: none;
56
+ }
57
+ `;
58
+
59
+ const CountryCell = styled.div`
60
+ display: table-cell;
61
+ padding: 2px 0;
62
+ vertical-align: middle;
63
+ border-bottom: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
64
+ color: ${({ theme }) => theme.colors.text};
65
+ line-height: 1.3;
66
+ `;
67
+
68
+ const FlagCell = styled(CountryCell)`
69
+ width: 20px;
70
+ text-align: center;
71
+ padding-right: 4px;
72
+ `;
73
+
74
+ const CountryCodeCell = styled(CountryCell)`
75
+ padding-right: 4px;
76
+ font-weight: 500;
77
+ font-size: ${({ theme }) => theme.fontSize.tiny};
78
+ `;
79
+
80
+ const CountCell = styled(CountryCell)`
81
+ text-align: right;
82
+ font-weight: 600;
83
+ color: ${({ theme }) => theme.colors.primary};
84
+ width: 20px;
85
+ font-size: ${({ theme }) => theme.fontSize.tiny};
86
+ `;
87
+
88
+ export interface CountryListProps<T> {
89
+ /** Array of data items containing country information */
90
+ data: T[];
91
+ /** Function to extract country code from data item (supports both alpha-2 and alpha-3 codes) */
92
+ xAccessor: (d: T) => string;
93
+ /** Function to extract numeric value from data item */
94
+ yAccessor: (d: T) => number;
95
+ /** Optional title for the list. Defaults to "Countries ({count})" */
96
+ title?: string;
97
+ }
98
+
99
+ /**
100
+ * CountryList displays a sorted list of countries with flags and numeric values in a two-column layout.
101
+ *
102
+ * Features:
103
+ * - Automatically sorts data by numeric value (descending)
104
+ * - Displays country flags when available
105
+ * - Supports both alpha-2 (US) and alpha-3 (USA) country codes
106
+ * - Two-column grid layout for compact display
107
+ * - Hover effects on rows
108
+ */
109
+ export const CountryList = <T,>({ data, xAccessor, yAccessor, title }: CountryListProps<T>) => {
110
+ const sortedData = [...data].sort((a, b) => yAccessor(b) - yAccessor(a));
111
+
112
+ // Split data into two columns
113
+ const midPoint = Math.ceil(sortedData.length / 2);
114
+ const leftColumnData = sortedData.slice(0, midPoint);
115
+ const rightColumnData = sortedData.slice(midPoint);
116
+
117
+ const renderCountryTable = (columnData: T[]) => (
118
+ <CountryTable>
119
+ {columnData.map((item, index) => {
120
+ const countryCode = xAccessor(item);
121
+ const count = yAccessor(item);
122
+ const alpha2Code = countryCode.length === 3 ? alpha3ToAlpha2[countryCode] : countryCode;
123
+ // Prefer 2-letter country codes for display if available
124
+ const displayCode = alpha2Code || countryCode;
125
+
126
+ return (
127
+ <CountryRow key={`${countryCode}-${index}`}>
128
+ <FlagCell>{alpha2Code && <Flag countryCode={alpha2Code} size={1} />}</FlagCell>
129
+ <CountryCodeCell>{displayCode}</CountryCodeCell>
130
+ <CountCell>{count}</CountCell>
131
+ </CountryRow>
132
+ );
133
+ })}
134
+ </CountryTable>
135
+ );
136
+
137
+ return (
138
+ <Container>
139
+ <Title>{title || `Countries (${sortedData.length})`}</Title>
140
+ <CountryGrid>
141
+ {renderCountryTable(leftColumnData)}
142
+ {renderCountryTable(rightColumnData)}
143
+ </CountryGrid>
144
+ </Container>
145
+ );
146
+ };
@@ -0,0 +1,26 @@
1
+ // TODO: save images locally so when there is no network they are still loaded.
2
+ import React from 'react';
3
+ import { Meta, StoryFn } from '@storybook/react';
4
+ import { DateFormatter, DateFormatterProps } from '.';
5
+ import { DateTime } from 'luxon';
6
+
7
+ export default {
8
+ title: 'Data/DateFormatter',
9
+ component: DateFormatter,
10
+ args: {
11
+ ISODate: DateTime.now().toISO(),
12
+ format: DateTime.DATE_FULL,
13
+ },
14
+ } as Meta<DateFormatterProps>;
15
+
16
+ export const Default: StoryFn<DateFormatterProps> = (args) => (
17
+ <div>
18
+ provides a wrapper component for formatting dates to the standard format used throughout takaro.
19
+ <br />
20
+ The current date is formatted to format <strong>DATE_FULL</strong>
21
+ <br />
22
+ <strong>
23
+ <DateFormatter ISODate={args.ISODate} format={args.format} />
24
+ </strong>
25
+ </div>
26
+ );
@@ -0,0 +1,15 @@
1
+ import { DateTime, DateTimeFormatOptions } from 'luxon';
2
+ import { FC } from 'react';
3
+
4
+ export interface DateFormatterProps {
5
+ ISODate: string;
6
+ format?: DateTimeFormatOptions;
7
+ }
8
+
9
+ export const DateFormatter: FC<DateFormatterProps> = ({ ISODate, format }) => {
10
+ return format ? (
11
+ <>{DateTime.fromISO(ISODate).toLocaleString(format)}</>
12
+ ) : (
13
+ <>{DateTime.fromISO(ISODate).toLocaleString(DateTime.DATETIME_SHORT)}</>
14
+ );
15
+ };