@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,21 @@
1
+ import { useContext, createContext } from 'react';
2
+ import { useDialog } from './useDialog';
3
+
4
+ type ContextType =
5
+ | (ReturnType<typeof useDialog> & {
6
+ setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
7
+ setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>;
8
+ })
9
+ | null;
10
+
11
+ export const DialogContext = createContext<ContextType>(null);
12
+
13
+ export const useDialogContext = () => {
14
+ const context = useContext(DialogContext);
15
+
16
+ if (context == null) {
17
+ throw new Error('Dialog components must be wrapped in <Dialog />');
18
+ }
19
+
20
+ return context;
21
+ };
@@ -0,0 +1,56 @@
1
+ import { forwardRef, HTMLProps, useId, useLayoutEffect } from 'react';
2
+ import { useDialogContext } from './DialogContext';
3
+ import { AiOutlineClose as CloseIcon } from 'react-icons/ai';
4
+ import { styled } from '../../../styled';
5
+ import { IconButton, Tooltip } from '../../../components';
6
+
7
+ const Container = styled.div`
8
+ display: flex;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+
12
+ h4 {
13
+ font-size: ${({ theme }) => theme.fontSize.tiny};
14
+ }
15
+ margin-bottom: ${({ theme }) => theme.spacing[2]};
16
+ `;
17
+
18
+ interface DialogHeadingProps extends HTMLProps<HTMLHeadingElement> {
19
+ hasClose?: boolean;
20
+ }
21
+
22
+ export const DialogHeading = forwardRef<HTMLHeadingElement, DialogHeadingProps>(function DialogHeading(
23
+ { children, hasClose = true, ...props },
24
+ ref,
25
+ ) {
26
+ const { setLabelId, setOpen } = useDialogContext();
27
+ const id = useId();
28
+
29
+ useLayoutEffect(() => {
30
+ setLabelId(id);
31
+ return () => setLabelId(undefined);
32
+ }, [id, setLabelId]);
33
+
34
+ return (
35
+ <Container>
36
+ <h4 {...props} ref={ref} id={id}>
37
+ {children}
38
+ </h4>
39
+ {hasClose && (
40
+ <Tooltip>
41
+ <Tooltip.Trigger asChild>
42
+ <IconButton
43
+ onClick={(e) => {
44
+ e.stopPropagation();
45
+ setOpen(false);
46
+ }}
47
+ ariaLabel="Close dialog"
48
+ icon={<CloseIcon cursor="pointer" />}
49
+ />
50
+ </Tooltip.Trigger>
51
+ <Tooltip.Content>Close dialog</Tooltip.Content>
52
+ </Tooltip>
53
+ )}
54
+ </Container>
55
+ );
56
+ });
@@ -0,0 +1,20 @@
1
+ import { DialogOptions, useDialog } from './useDialog';
2
+ import { FC, PropsWithChildren } from 'react';
3
+ import { DialogContext } from './DialogContext';
4
+ import { DialogContent } from './DialogContent';
5
+ import { DialogBody } from './DialogBody';
6
+ import { DialogHeading } from './DialogHeading';
7
+
8
+ interface SubComponentTypes {
9
+ Content: typeof DialogContent;
10
+ Body: typeof DialogBody;
11
+ Heading: typeof DialogHeading;
12
+ }
13
+
14
+ export const Dialog: FC<PropsWithChildren<DialogOptions>> & SubComponentTypes = ({ children, ...options }) => {
15
+ return <DialogContext.Provider value={useDialog(options)}>{children}</DialogContext.Provider>;
16
+ };
17
+
18
+ Dialog.Content = DialogContent;
19
+ Dialog.Body = DialogBody;
20
+ Dialog.Heading = DialogHeading;
@@ -0,0 +1,50 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { useClick, useDismiss, useFloating, useInteractions, useRole } from '@floating-ui/react';
3
+
4
+ export interface DialogOptions {
5
+ open?: boolean;
6
+ initialOpen?: boolean;
7
+ onOpenChange?: (open: boolean) => void;
8
+ }
9
+
10
+ export function useDialog({
11
+ initialOpen = false,
12
+ open: controlledOpen,
13
+ onOpenChange: setControlledOpen,
14
+ }: DialogOptions) {
15
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
16
+ const [labelId, setLabelId] = useState<string | undefined>();
17
+ const [descriptionId, setDescriptionId] = useState<string | undefined>();
18
+
19
+ const open = controlledOpen ?? uncontrolledOpen;
20
+ const setOpen = setControlledOpen ?? setUncontrolledOpen;
21
+
22
+ const data = useFloating({
23
+ open,
24
+ onOpenChange: setOpen,
25
+ });
26
+
27
+ const context = data.context;
28
+
29
+ const interactions = useInteractions([
30
+ useClick(context, {
31
+ enabled: controlledOpen == null,
32
+ }),
33
+ useDismiss(context, { outsidePressEvent: 'mousedown', bubbles: false }),
34
+ useRole(context, { role: 'dialog' }),
35
+ ]);
36
+
37
+ return useMemo(
38
+ () => ({
39
+ open,
40
+ setOpen,
41
+ ...interactions,
42
+ ...data,
43
+ labelId,
44
+ descriptionId,
45
+ setLabelId,
46
+ setDescriptionId,
47
+ }),
48
+ [open, setOpen, interactions, data, labelId, descriptionId],
49
+ );
50
+ }
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { Meta, StoryFn, StoryObj } from '@storybook/react';
3
+ import { Alert, AlertProps } from '.';
4
+
5
+ export default {
6
+ title: 'Feedback/Alert',
7
+ component: Alert,
8
+ args: {
9
+ text: 'This is the title',
10
+ variant: 'info',
11
+ },
12
+ } as Meta<AlertProps>;
13
+
14
+ export const Default: StoryFn<AlertProps> = (args) => <Alert {...args} />;
15
+
16
+ export const TitleOnly: StoryObj<AlertProps> = {
17
+ args: {
18
+ title: 'Important Notice',
19
+ variant: 'info',
20
+ },
21
+ };
22
+
23
+ export const WithList: StoryObj<AlertProps> = {
24
+ args: {
25
+ title: 'There were errors with your submission',
26
+ text: [
27
+ 'Your password must be at least 8 characters',
28
+ 'Your password must include at least one pro wrestling finishing move',
29
+ ],
30
+ variant: 'error',
31
+ },
32
+ };
33
+
34
+ export const Warning: StoryObj<AlertProps> = {
35
+ args: {
36
+ title: 'Attention required',
37
+ text: 'This is a warning! Please read this carefully before you continue!',
38
+ variant: 'warning',
39
+ action: {
40
+ execute: () => {
41
+ /* */
42
+ },
43
+ text: 'View status',
44
+ },
45
+ },
46
+ };
47
+
48
+ export const SingleLine: StoryObj<AlertProps> = {
49
+ args: {
50
+ text: 'This is a single line now',
51
+ variant: 'info',
52
+ },
53
+ };
54
+
55
+ export const SingleLineWithAction: StoryObj<AlertProps> = {
56
+ args: {
57
+ text: 'This is a single line now',
58
+ variant: 'error',
59
+ action: {
60
+ execute: () => {},
61
+ text: 'details',
62
+ },
63
+ },
64
+ };
65
+
66
+ export const SingleLineLongWithAction: StoryObj<AlertProps> = {
67
+ args: {
68
+ text: 'This is a very very very very very very very very very very long line that stretches to 2 lines',
69
+ variant: 'error',
70
+ action: {
71
+ execute: () => {},
72
+ text: 'details',
73
+ },
74
+ },
75
+ };
@@ -0,0 +1,8 @@
1
+ import { Alert } from '.';
2
+ import { render } from '../../../test/testUtils';
3
+ import { expect, it } from 'vitest';
4
+
5
+ it('Should render <Alert/>', () => {
6
+ const { container } = render(<Alert text="Alert text" title="Alert title" variant="info" />);
7
+ expect(container).toMatchSnapshot();
8
+ });
@@ -0,0 +1,146 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Should render <Alert/> 1`] = `
4
+ .c0 {
5
+ width: 100%;
6
+ padding: 1rem 1.2rem;
7
+ border-radius: 1rem;
8
+ margin: 1.5rem auto 1.5rem auto;
9
+ background-color: #d9d2f9;
10
+ }
11
+
12
+ .c0 h2 {
13
+ font-size: 1.825rem;
14
+ display: -webkit-box;
15
+ display: -webkit-flex;
16
+ display: -ms-flexbox;
17
+ display: flex;
18
+ -webkit-align-items: center;
19
+ -webkit-box-align: center;
20
+ -ms-flex-align: center;
21
+ align-items: center;
22
+ font-weight: 700;
23
+ -webkit-box-pack: start;
24
+ -webkit-justify-content: flex-start;
25
+ -ms-flex-pack: start;
26
+ justify-content: flex-start;
27
+ }
28
+
29
+ .c0 p {
30
+ margin-top: 1.5rem;
31
+ }
32
+
33
+ .c0 p,
34
+ .c0 li {
35
+ font-size: 1.325rem;
36
+ }
37
+
38
+ .c0 ul {
39
+ margin-left: 15px;
40
+ }
41
+
42
+ .c0 ul li {
43
+ list-style-type: disc;
44
+ margin-top: 0.5rem;
45
+ margin-bottom: 0.5rem;
46
+ }
47
+
48
+ .c0 h2 {
49
+ color: #331ab2;
50
+ }
51
+
52
+ .c0 p,
53
+ .c0 li {
54
+ color: #331ab2;
55
+ }
56
+
57
+ .c0::marker {
58
+ color: #331ab2;
59
+ }
60
+
61
+ .c1 {
62
+ display: grid;
63
+ grid-template-columns: 40px 1fr;
64
+ -webkit-align-items: center;
65
+ -webkit-box-align: center;
66
+ -ms-flex-align: center;
67
+ align-items: center;
68
+ }
69
+
70
+ .c2 {
71
+ display: -webkit-box;
72
+ display: -webkit-flex;
73
+ display: -ms-flexbox;
74
+ display: flex;
75
+ -webkit-align-items: center;
76
+ -webkit-box-align: center;
77
+ -ms-flex-align: center;
78
+ align-items: center;
79
+ -webkit-box-pack: center;
80
+ -webkit-justify-content: center;
81
+ -ms-flex-pack: center;
82
+ justify-content: center;
83
+ margin-right: 1.4rem;
84
+ }
85
+
86
+ .c2 svg {
87
+ fill: #664DE5;
88
+ }
89
+
90
+ .c3 {
91
+ display: none;
92
+ }
93
+
94
+ .c3 button {
95
+ margin-top: 2rem;
96
+ margin-right: 2rem;
97
+ padding: 0.8rem 0.5rem 0.8rem 0.5rem;
98
+ border-radius: 0.5rem;
99
+ background-color: #b2a6f2;
100
+ font-size: 1.3rem;
101
+ border: none;
102
+ cursor: pointer;
103
+ font-weight: 700;
104
+ color: #331ab2;
105
+ }
106
+
107
+ <div>
108
+ <div
109
+ class="c0"
110
+ style="opacity: 0;"
111
+ >
112
+ <div
113
+ class="c1"
114
+ >
115
+ <div
116
+ class="c2"
117
+ >
118
+ <svg
119
+ fill="currentColor"
120
+ height="24"
121
+ stroke="currentColor"
122
+ stroke-width="0"
123
+ viewBox="0 0 1024 1024"
124
+ width="24"
125
+ xmlns="http://www.w3.org/2000/svg"
126
+ >
127
+ <path
128
+ d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"
129
+ />
130
+ </svg>
131
+ </div>
132
+ <h2>
133
+ Alert title
134
+ </h2>
135
+ <div />
136
+ <p>
137
+ Alert text
138
+ </p>
139
+ <div />
140
+ <div
141
+ class="c3"
142
+ />
143
+ </div>
144
+ </div>
145
+ </div>
146
+ `;
@@ -0,0 +1,44 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`Should render <Alert/> 1`] = `
4
+ <div>
5
+ <div
6
+ aria-atomic="true"
7
+ aria-live="polite"
8
+ class="sc-aXZVg dfhkGl"
9
+ role="status"
10
+ style="opacity: 0; will-change: opacity;"
11
+ >
12
+ <div
13
+ class="sc-gEvEer ciCPPR"
14
+ >
15
+ <div
16
+ class="sc-eqUAAy hqcNUj"
17
+ >
18
+ <svg
19
+ fill="currentColor"
20
+ height="24"
21
+ stroke="currentColor"
22
+ stroke-width="0"
23
+ viewBox="0 0 1024 1024"
24
+ width="24"
25
+ xmlns="http://www.w3.org/2000/svg"
26
+ >
27
+ <path
28
+ d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"
29
+ />
30
+ </svg>
31
+ </div>
32
+ <h2>
33
+ Alert title
34
+ </h2>
35
+ <p>
36
+ Alert text
37
+ </p>
38
+ <div
39
+ class="sc-fqkvVR huFkoW action"
40
+ />
41
+ </div>
42
+ </div>
43
+ </div>
44
+ `;
@@ -0,0 +1,120 @@
1
+ import { forwardRef, isValidElement, MouseEvent, ReactElement, useState } from 'react';
2
+ import { Container, Grid, IconContainer, ButtonContainer } from './style';
3
+ import {
4
+ AiFillCheckCircle as Success,
5
+ AiFillCloseCircle as Error,
6
+ AiOutlineWarning as Warning,
7
+ AiFillInfoCircle as Info,
8
+ } from 'react-icons/ai';
9
+ import { AnimatePresence } from 'framer-motion';
10
+ import { Button } from '../../../components';
11
+
12
+ export type AlertVariants = 'success' | 'error' | 'warning' | 'info';
13
+
14
+ type Action = {
15
+ execute: () => void;
16
+ text: string;
17
+ };
18
+
19
+ export interface AlertProps {
20
+ variant: AlertVariants;
21
+ title?: string;
22
+ text?: string | string[] | ReactElement;
23
+ dismiss?: boolean;
24
+ action?: Action;
25
+ }
26
+
27
+ export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(
28
+ { variant, title, text, dismiss = false, action },
29
+ ref,
30
+ ) {
31
+ const [visible, setVisible] = useState(true);
32
+ const hasTitle = !!title;
33
+ const hasText = !!text;
34
+ const hasContent = hasTitle || hasText;
35
+ // Use center alignment when we have only one content line (title OR text, not both)
36
+ // Use start alignment when we have multiple lines (title AND text, or text as an array)
37
+ const useStartAlignment = (hasTitle && hasText) || Array.isArray(text);
38
+
39
+ const handleExecute = (e: MouseEvent<HTMLButtonElement>) => {
40
+ e.preventDefault();
41
+ e.stopPropagation();
42
+ action?.execute();
43
+ };
44
+ const handleDismiss = (e: MouseEvent<HTMLButtonElement>) => {
45
+ e.preventDefault();
46
+ e.stopPropagation();
47
+ setVisible(false);
48
+ };
49
+
50
+ function getIcon() {
51
+ switch (variant) {
52
+ case 'success':
53
+ return <Success size={24} />;
54
+ case 'error':
55
+ return <Error size={24} />;
56
+ case 'warning':
57
+ return <Warning size={24} />;
58
+ case 'info':
59
+ return <Info size={24} />;
60
+ }
61
+ }
62
+
63
+ function renderText() {
64
+ if (isValidElement(text)) {
65
+ return text;
66
+ }
67
+
68
+ if (typeof text === 'string') {
69
+ return <p>{text}</p>;
70
+ } else if (Array.isArray(text)) {
71
+ return <ul>{text?.map((message, index) => <li key={index}>{message}</li>)}</ul>;
72
+ }
73
+ }
74
+
75
+ // Determine ARIA role based on variant
76
+ const getAriaRole = () => {
77
+ return variant === 'error' || variant === 'warning' ? 'alert' : 'status';
78
+ };
79
+
80
+ const getAriaLive = () => {
81
+ return variant === 'error' || variant === 'warning' ? 'assertive' : 'polite';
82
+ };
83
+
84
+ return (
85
+ <AnimatePresence>
86
+ {visible && (
87
+ <Container
88
+ animate={{ opacity: 1 }}
89
+ exit={{ opacity: 0 }}
90
+ $hasTitle={hasTitle}
91
+ initial={{ opacity: 0 }}
92
+ $variant={variant}
93
+ transition={{ duration: 0.2 }}
94
+ ref={ref}
95
+ role={getAriaRole()}
96
+ aria-live={getAriaLive()}
97
+ aria-atomic="true"
98
+ >
99
+ <Grid $useStartAlignment={useStartAlignment}>
100
+ <IconContainer variant={variant}>{getIcon()}</IconContainer>
101
+ {title && <h2>{title}</h2>}
102
+ {renderText()}
103
+ <ButtonContainer hasContent={hasContent} show={!!(dismiss || action)} variant={variant} className="action">
104
+ {action && (
105
+ <Button size="small" variant="outline" onClick={handleExecute} color={variant}>
106
+ {action.text}
107
+ </Button>
108
+ )}
109
+ {dismiss && (
110
+ <Button size="small" color="white" variant="outline" onClick={handleDismiss}>
111
+ Dismiss
112
+ </Button>
113
+ )}
114
+ </ButtonContainer>
115
+ </Grid>
116
+ </Container>
117
+ )}
118
+ </AnimatePresence>
119
+ );
120
+ });
@@ -0,0 +1,97 @@
1
+ import { styled } from '../../../styled';
2
+ import { AlertVariants } from '.';
3
+ import { motion } from 'framer-motion';
4
+ import { shade } from 'polished';
5
+
6
+ // Since this actually a motion.div we are passing props to that only should be consumed by styled compmonents
7
+ // and not being passed the the underlying react node, we can prefix the prop names with `$`to turn it into
8
+ // a transient prop.
9
+ export const Container = styled(motion.div)<{
10
+ $variant: AlertVariants;
11
+ $hasTitle: boolean;
12
+ }>`
13
+ width: 100%;
14
+ padding: ${({ theme }) => theme.spacing['0_75']};
15
+ border-radius: ${({ theme }) => theme.borderRadius.large};
16
+ margin: ${({ theme }) => `${theme.spacing['1_5']} auto`};
17
+ h2 {
18
+ font-size: ${({ theme }) => theme.fontSize.mediumLarge};
19
+ font-weight: 700;
20
+ margin: 0;
21
+ text-align: left;
22
+ }
23
+ p {
24
+ margin-top: ${({ theme, $hasTitle }) => ($hasTitle ? theme.spacing['0_25'] : theme.spacing[0])};
25
+ margin-bottom: 0;
26
+ hyphens: auto;
27
+ text-align: left;
28
+ font-size: ${({ theme }) => theme.fontSize.medium};
29
+ }
30
+ li {
31
+ font-size: ${({ theme }) => theme.fontSize.medium};
32
+ text-align: left;
33
+ }
34
+ ul {
35
+ margin-left: ${({ theme }) => theme.spacing['1_5']};
36
+ margin-top: ${({ theme, $hasTitle }) => ($hasTitle ? theme.spacing['0_25'] : theme.spacing[0])};
37
+ margin-bottom: 0;
38
+ li {
39
+ list-style-type: disc;
40
+ margin-top: ${({ theme }) => theme.spacing['0_5']};
41
+ margin-bottom: ${({ theme }) => theme.spacing['0_5']};
42
+ &::marker {
43
+ font-size: ${({ theme }) => theme.fontSize.medium};
44
+ }
45
+ }
46
+ }
47
+ /* set background color equal to provided type */
48
+ ${({ $variant, theme }): string => {
49
+ return `
50
+ background-color: ${shade('0.5', theme.colors[$variant])};
51
+ border: 1px solid ${theme.colors[$variant]};
52
+ h2 {
53
+ color: white;
54
+ }
55
+ p, li {
56
+ color: white;
57
+ }
58
+ ::marker {
59
+ color: white;
60
+ }
61
+ `;
62
+ }}
63
+ `;
64
+
65
+ export const Grid = styled.div<{ $useStartAlignment: boolean }>`
66
+ display: grid;
67
+ grid-template-columns: 40px 1fr;
68
+ align-items: ${({ $useStartAlignment }) => ($useStartAlignment ? 'start' : 'center')};
69
+ gap: ${({ theme }) => theme.spacing['0_5']};
70
+
71
+ p,
72
+ ul,
73
+ .action {
74
+ grid-column: 2;
75
+ }
76
+ `;
77
+
78
+ export const IconContainer = styled.div<{ variant: AlertVariants }>`
79
+ display: flex;
80
+ align-items: center;
81
+ justify-content: center;
82
+ svg {
83
+ fill: white;
84
+ }
85
+ `;
86
+
87
+ export const ButtonContainer = styled.div<{
88
+ show: boolean;
89
+ variant: AlertVariants;
90
+ hasContent: boolean;
91
+ }>`
92
+ display: ${({ show }): string => (show ? 'flex' : 'none')};
93
+ align-items: center;
94
+ flex-wrap: wrap;
95
+ gap: ${({ theme }) => theme.spacing['0_5']};
96
+ margin-top: ${({ theme, hasContent }): string => (hasContent ? theme.spacing['1'] : theme.spacing[0])};
97
+ `;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Meta, StoryFn } from '@storybook/react';
3
+ import { Badge, BadgeProps } from '.';
4
+
5
+ export default {
6
+ title: 'Feedback/Badge',
7
+ component: Badge,
8
+ args: {
9
+ variant: 'warning',
10
+ animate: false,
11
+ },
12
+ } as Meta<BadgeProps>;
13
+
14
+ export const Default: StoryFn<BadgeProps> = (args) => (
15
+ <div>
16
+ <h2 style={{ backgroundColor: 'orange', position: 'relative', width: 'fit-content' }}>
17
+ this is the title{' '}
18
+ <Badge variant={args.variant} animate={args.animate}>
19
+ here
20
+ </Badge>
21
+ </h2>
22
+ </div>
23
+ );