@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,48 @@
1
+ import { FC } from 'react';
2
+
3
+ export interface SparklineProps {
4
+ data: number[];
5
+ color?: string;
6
+ width?: string | number;
7
+ height?: string | number;
8
+ strokeWidth?: number;
9
+ }
10
+
11
+ /**
12
+ * Sparkline component - renders a simple SVG line chart for trend visualization
13
+ * Designed to be used as Stats.Sparkline for showing mini trend charts
14
+ */
15
+ export const Sparkline: FC<SparklineProps> = ({
16
+ data,
17
+ color = 'currentColor',
18
+ width = '100%',
19
+ height = '100%',
20
+ strokeWidth = 2,
21
+ }) => {
22
+ if (!data || data.length === 0) return null;
23
+
24
+ const max = Math.max(...data);
25
+ const min = Math.min(...data);
26
+ const range = max - min || 1;
27
+
28
+ const points = data
29
+ .map((value, index) => {
30
+ const divisor = Math.max(data.length - 1, 1); // in case of single data point
31
+ const x = (index / divisor) * 100;
32
+ const y = 100 - ((value - min) / range) * 100;
33
+ return `${x},${y}`;
34
+ })
35
+ .join(' ');
36
+
37
+ return (
38
+ <svg width={width} height={height} viewBox="0 0 100 100" preserveAspectRatio="none">
39
+ <polyline
40
+ points={points}
41
+ fill="none"
42
+ stroke={color}
43
+ strokeWidth={strokeWidth}
44
+ vectorEffect="non-scaling-stroke"
45
+ />
46
+ </svg>
47
+ );
48
+ };
@@ -0,0 +1,192 @@
1
+ import { FC, useContext, ReactNode, cloneElement, isValidElement } from 'react';
2
+ import { styled, Size } from '../../../styled';
3
+ import { StatContext, Direction } from './context';
4
+ import { AiOutlineArrowUp, AiOutlineArrowDown } from 'react-icons/ai';
5
+
6
+ const Container = styled.div<{ isGrouped: boolean; direction: Direction; size: Size }>`
7
+ background-color: ${({ theme }) => theme.colors.backgroundAlt};
8
+ padding: ${({ theme, size }) => {
9
+ switch (size) {
10
+ case 'tiny':
11
+ return theme.spacing['0_5'];
12
+ case 'small':
13
+ return theme.spacing['1'];
14
+ case 'medium':
15
+ return theme.spacing['2'];
16
+ case 'large':
17
+ return theme.spacing['3'];
18
+ case 'huge':
19
+ return theme.spacing['4'];
20
+ }
21
+ }};
22
+
23
+ ${({ isGrouped, direction, theme }) => {
24
+ if (isGrouped) {
25
+ if (direction === 'vertical') {
26
+ return `
27
+ &:not(:last-child) {
28
+ border-bottom: 1px solid ${theme.colors.secondary};
29
+ }
30
+ &:first-child {
31
+ border-top-left-radius: ${theme.borderRadius.medium};
32
+ border-top-right-radius: ${theme.borderRadius.medium};
33
+ }
34
+ &:last-child {
35
+ border-bottom-left-radius: ${theme.borderRadius.medium};
36
+ border-bottom-right-radius: ${theme.borderRadius.medium};
37
+ }
38
+ `;
39
+ } else {
40
+ return `
41
+ &:not(:last-child) {
42
+ border-right: 1px solid ${theme.colors.secondary};
43
+ }
44
+ &:first-child {
45
+ border-top-left-radius: ${theme.borderRadius.medium};
46
+ border-bottom-left-radius: ${theme.borderRadius.medium};
47
+ }
48
+ &:last-child {
49
+ border-top-right-radius: ${theme.borderRadius.medium};
50
+ border-bottom-right-radius: ${theme.borderRadius.medium};
51
+ }
52
+ `;
53
+ }
54
+ } else {
55
+ return `
56
+ border-radius: ${theme.borderRadius.medium};
57
+ border: 1px solid ${theme.colors.secondary};
58
+ `;
59
+ }
60
+ }};
61
+
62
+ dt {
63
+ font-size: ${({ theme, size }) => {
64
+ switch (size) {
65
+ case 'tiny':
66
+ return theme.fontSize.tiny;
67
+ case 'small':
68
+ return theme.fontSize.small;
69
+ case 'medium':
70
+ return theme.fontSize.medium;
71
+ case 'large':
72
+ return theme.fontSize.mediumLarge;
73
+ case 'huge':
74
+ return theme.fontSize.large;
75
+ }
76
+ }};
77
+ color: ${({ theme }) => theme.colors.textAlt};
78
+ margin-bottom: ${({ theme }) => theme.spacing['0_5']};
79
+ }
80
+
81
+ dd {
82
+ font-weight: bold;
83
+ color: ${({ theme }) => theme.colors.white};
84
+ font-size: ${({ theme, size }) => {
85
+ switch (size) {
86
+ case 'tiny':
87
+ return theme.fontSize.small;
88
+ case 'small':
89
+ return theme.fontSize.medium;
90
+ case 'medium':
91
+ return theme.fontSize.mediumLarge;
92
+ case 'large':
93
+ return theme.fontSize.large;
94
+ case 'huge':
95
+ return theme.fontSize.huge;
96
+ }
97
+ }};
98
+ color: ${({ theme }) => theme.colors.text};
99
+ font-size: ${({ theme }) => theme.fontSize.mediumLarge};
100
+ letter-spacing: 1px;
101
+ margin: 0;
102
+ padding: 0;
103
+ display: flex;
104
+ align-items: center;
105
+ gap: ${({ theme }) => theme.spacing['1']};
106
+
107
+ &.placeholder {
108
+ min-width: 80%;
109
+ min-height: 25px;
110
+ }
111
+ }
112
+ `;
113
+
114
+ const TrendContainer = styled.span<{ direction: 'up' | 'down' }>`
115
+ display: inline-flex;
116
+ align-items: center;
117
+ gap: ${({ theme }) => theme.spacing['0_5']};
118
+ font-size: ${({ theme }) => theme.fontSize.small};
119
+ font-weight: normal;
120
+ color: ${({ theme, direction }) => (direction === 'up' ? theme.colors.success : theme.colors.error)};
121
+ `;
122
+
123
+ const IconWrapper = styled.span`
124
+ display: inline-flex;
125
+ align-items: center;
126
+ margin-right: ${({ theme }) => theme.spacing['0_5']};
127
+ `;
128
+
129
+ export interface TrendConfig {
130
+ direction: 'up' | 'down';
131
+ value: string | number;
132
+ }
133
+
134
+ export interface StatProps {
135
+ description: string;
136
+ value: string | number | ReactNode;
137
+ icon?: ReactNode;
138
+ trend?: TrendConfig;
139
+ isLoading?: boolean;
140
+ size?: Size;
141
+ }
142
+
143
+ export const Stat: FC<StatProps> = ({ description, value, icon, trend, isLoading, size: propSize }) => {
144
+ const { grouped, direction, size: contextSize } = useContext(StatContext);
145
+ const size = propSize ?? contextSize;
146
+
147
+ const renderValue = () => {
148
+ if (typeof value === 'string' || typeof value === 'number') {
149
+ return value.toString();
150
+ }
151
+ return value;
152
+ };
153
+
154
+ const renderIcon = () => {
155
+ if (!icon) return null;
156
+ if (isValidElement(icon)) {
157
+ return <IconWrapper>{cloneElement(icon, { size: 20 } as any)}</IconWrapper>;
158
+ }
159
+ return <IconWrapper>{icon}</IconWrapper>;
160
+ };
161
+
162
+ const renderTrend = () => {
163
+ if (!trend) return null;
164
+ const TrendIcon = trend.direction === 'up' ? AiOutlineArrowUp : AiOutlineArrowDown;
165
+ return (
166
+ <TrendContainer direction={trend.direction}>
167
+ <TrendIcon size={14} />
168
+ {trend.value}
169
+ </TrendContainer>
170
+ );
171
+ };
172
+
173
+ if (isLoading) {
174
+ return (
175
+ <Container isGrouped={grouped} direction={direction} size={size} aria-busy="true" aria-label="Loading">
176
+ <dt>{description}</dt>
177
+ <dd className="placeholder"></dd>
178
+ </Container>
179
+ );
180
+ }
181
+
182
+ return (
183
+ <Container isGrouped={grouped} direction={direction} size={size}>
184
+ <dt>{description}</dt>
185
+ <dd>
186
+ {renderIcon()}
187
+ {renderValue()}
188
+ {renderTrend()}
189
+ </dd>
190
+ </Container>
191
+ );
192
+ };
@@ -0,0 +1,196 @@
1
+ import React from 'react';
2
+ import { Meta, StoryFn } from '@storybook/react';
3
+ import { Stats, StatsProps } from '../../../components';
4
+ import { AiOutlineDollar, AiOutlineUser, AiOutlineShoppingCart, AiOutlineEye } from 'react-icons/ai';
5
+
6
+ export default {
7
+ title: 'Data/Stat',
8
+ component: Stats,
9
+ args: {
10
+ direction: 'horizontal',
11
+ grouped: false,
12
+ size: 'medium',
13
+ },
14
+ } as Meta<StatsProps>;
15
+
16
+ export const HorizontalGrouped: StoryFn<StatsProps> = () => {
17
+ return (
18
+ <div style={{ width: '1000px' }}>
19
+ <Stats direction="horizontal" grouped>
20
+ <Stats.Stat description="Credits" value="$0.00" />
21
+ <Stats.Stat description="Current month so far" value="$0.00" />
22
+ <Stats.Stat description="Last invoice" value="$0.00" />
23
+ </Stats>
24
+ </div>
25
+ );
26
+ };
27
+
28
+ export const HorizontalSeparated: StoryFn<StatsProps> = () => {
29
+ return (
30
+ <div style={{ width: '1000px' }}>
31
+ <Stats direction="horizontal" grouped={false}>
32
+ <Stats.Stat description="Credits" value="$0.00" />
33
+ <Stats.Stat description="Current month so far" value="$0.00" />
34
+ <Stats.Stat description="Last invoice" value="$0.00" />
35
+ </Stats>
36
+ </div>
37
+ );
38
+ };
39
+
40
+ export const VerticalGrouped: StoryFn<StatsProps> = () => {
41
+ return (
42
+ <div style={{ width: '300px' }}>
43
+ <Stats direction="vertical" grouped>
44
+ <Stats.Stat description="Credits" value="$0.00" />
45
+ <Stats.Stat description="Current month so far" value="$0.00" />
46
+ <Stats.Stat description="Last invoice" value="$0.00" />
47
+ </Stats>
48
+ </div>
49
+ );
50
+ };
51
+
52
+ export const VerticalSeparated: StoryFn<StatsProps> = () => {
53
+ return (
54
+ <div style={{ width: '300px' }}>
55
+ <Stats direction="vertical" grouped={false}>
56
+ <Stats.Stat description="Credits" value="$0.00" />
57
+ <Stats.Stat description="Current month so far" value="$0.00" />
58
+ <Stats.Stat description="Last invoice" value="$0.00" />
59
+ </Stats>
60
+ </div>
61
+ );
62
+ };
63
+
64
+ export const LoadingState: StoryFn<StatsProps> = (args) => {
65
+ return (
66
+ <div style={{ width: '700px' }}>
67
+ <Stats direction={args.direction} grouped={args.grouped}>
68
+ <Stats.Stat isLoading description="Credits" value="$0.00" />
69
+ <Stats.Stat description="Current month so far" value="$0.00" />
70
+ <Stats.Stat description="Last invoice" value="$0.00" />
71
+ </Stats>
72
+ </div>
73
+ );
74
+ };
75
+
76
+ export const WithIcons: StoryFn<StatsProps> = () => {
77
+ return (
78
+ <div style={{ width: '1000px' }}>
79
+ <Stats direction="horizontal" grouped>
80
+ <Stats.Stat description="Revenue" value="$12,345" icon={<AiOutlineDollar />} />
81
+ <Stats.Stat description="Active Users" value={1234} icon={<AiOutlineUser />} />
82
+ <Stats.Stat description="Total Orders" value="567" icon={<AiOutlineShoppingCart />} />
83
+ </Stats>
84
+ </div>
85
+ );
86
+ };
87
+
88
+ export const WithTrends: StoryFn<StatsProps> = () => {
89
+ return (
90
+ <div style={{ width: '1000px' }}>
91
+ <Stats direction="horizontal" grouped>
92
+ <Stats.Stat
93
+ description="Revenue"
94
+ value="$12,345"
95
+ icon={<AiOutlineDollar />}
96
+ trend={{ direction: 'up', value: '+12.5%' }}
97
+ />
98
+ <Stats.Stat
99
+ description="Active Users"
100
+ value={1234}
101
+ icon={<AiOutlineUser />}
102
+ trend={{ direction: 'down', value: '-5.2%' }}
103
+ />
104
+ <Stats.Stat
105
+ description="Page Views"
106
+ value="45.2K"
107
+ icon={<AiOutlineEye />}
108
+ trend={{ direction: 'up', value: '+8%' }}
109
+ />
110
+ </Stats>
111
+ </div>
112
+ );
113
+ };
114
+
115
+ export const SizeVariants: StoryFn<StatsProps> = () => {
116
+ return (
117
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>
118
+ <div>
119
+ <h3>Small</h3>
120
+ <Stats direction="horizontal" grouped size="small">
121
+ <Stats.Stat description="Revenue" value="$12,345" icon={<AiOutlineDollar />} />
122
+ <Stats.Stat description="Users" value="1,234" icon={<AiOutlineUser />} />
123
+ </Stats>
124
+ </div>
125
+ <div>
126
+ <h3>Medium (Default)</h3>
127
+ <Stats direction="horizontal" grouped size="medium">
128
+ <Stats.Stat description="Revenue" value="$12,345" icon={<AiOutlineDollar />} />
129
+ <Stats.Stat description="Users" value="1,234" icon={<AiOutlineUser />} />
130
+ </Stats>
131
+ </div>
132
+ <div>
133
+ <h3>Large</h3>
134
+ <Stats direction="horizontal" grouped size="large">
135
+ <Stats.Stat description="Revenue" value="$12,345" icon={<AiOutlineDollar />} />
136
+ <Stats.Stat description="Users" value="1,234" icon={<AiOutlineUser />} />
137
+ </Stats>
138
+ </div>
139
+ </div>
140
+ );
141
+ };
142
+
143
+ export const AllFeatures: StoryFn<StatsProps> = () => {
144
+ return (
145
+ <div style={{ width: '1000px' }}>
146
+ <Stats direction="horizontal" grouped size="medium">
147
+ <Stats.Stat
148
+ description="Total Revenue"
149
+ value="$45,231"
150
+ icon={<AiOutlineDollar />}
151
+ trend={{ direction: 'up', value: '+20.1%' }}
152
+ />
153
+ <Stats.Stat
154
+ description="Active Users"
155
+ value="2,345"
156
+ icon={<AiOutlineUser />}
157
+ trend={{ direction: 'up', value: '+12%' }}
158
+ />
159
+ <Stats.Stat
160
+ description="Orders"
161
+ value="892"
162
+ icon={<AiOutlineShoppingCart />}
163
+ trend={{ direction: 'down', value: '-3.5%' }}
164
+ />
165
+ <Stats.Stat description="Page Views" value="123.4K" icon={<AiOutlineEye />} />
166
+ </Stats>
167
+ </div>
168
+ );
169
+ };
170
+
171
+ export const VerticalWithAllFeatures: StoryFn<StatsProps> = () => {
172
+ return (
173
+ <div style={{ width: '350px' }}>
174
+ <Stats direction="vertical" grouped size="medium">
175
+ <Stats.Stat
176
+ description="Total Revenue"
177
+ value="$45,231"
178
+ icon={<AiOutlineDollar />}
179
+ trend={{ direction: 'up', value: '+20.1%' }}
180
+ />
181
+ <Stats.Stat
182
+ description="Active Users"
183
+ value="2,345"
184
+ icon={<AiOutlineUser />}
185
+ trend={{ direction: 'up', value: '+12%' }}
186
+ />
187
+ <Stats.Stat
188
+ description="Total Orders"
189
+ value="892"
190
+ icon={<AiOutlineShoppingCart />}
191
+ trend={{ direction: 'down', value: '-3.5%' }}
192
+ />
193
+ </Stats>
194
+ </div>
195
+ );
196
+ };
@@ -0,0 +1,18 @@
1
+ import { createContext } from 'react';
2
+ import { Size } from '../../../styled/types';
3
+
4
+ export type Direction = 'horizontal' | 'vertical';
5
+
6
+ interface StatsContextValue {
7
+ grouped: boolean;
8
+ direction: Direction;
9
+ size: Size;
10
+ }
11
+
12
+ const defaultValue: StatsContextValue = {
13
+ grouped: false,
14
+ direction: 'vertical',
15
+ size: 'medium',
16
+ };
17
+
18
+ export const StatContext = createContext<StatsContextValue>(defaultValue);
@@ -0,0 +1,62 @@
1
+ import { FC, PropsWithChildren, Children, isValidElement } from 'react';
2
+ import { styled, Size } from '../../../styled';
3
+ import { Stat } from './Stat';
4
+ import { Sparkline } from './Sparkline';
5
+ import { StatContext, Direction } from './context';
6
+
7
+ export const Container = styled.dl<{ direction: Direction; grouped: boolean; count: number }>`
8
+ display: grid;
9
+ ${({ direction, count }) => {
10
+ return direction === 'horizontal'
11
+ ? `grid-template-columns: repeat(${count},1fr)`
12
+ : `grid-template-rows: repeat(${count},1fr)`;
13
+ }};
14
+ border: ${({ grouped, theme }) => (grouped ? `1px solid ${theme.colors.secondary}` : 'none')};
15
+ border-radius: ${({ theme }) => theme.borderRadius.medium};
16
+ gap: ${({ theme, direction, grouped }) => {
17
+ if (grouped) return 0;
18
+ return direction === 'vertical' ? `${theme.spacing['2']} 0` : `0 ${theme.spacing['2']}`;
19
+ }};
20
+ `;
21
+
22
+ export interface StatsProps {
23
+ direction?: Direction;
24
+ grouped: boolean;
25
+ size?: Size;
26
+ }
27
+
28
+ interface SubComponents {
29
+ Stat: typeof Stat;
30
+ Sparkline: typeof Sparkline;
31
+ }
32
+
33
+ export const Stats: FC<PropsWithChildren<StatsProps>> & SubComponents = ({
34
+ direction = 'vertical',
35
+ grouped,
36
+ size = 'medium',
37
+ children,
38
+ }) => {
39
+ // throw error if child is not a Stat component
40
+ Children.forEach(children, (child) => {
41
+ if (!isValidElement(child)) {
42
+ return;
43
+ }
44
+ if (child.type !== Stat) {
45
+ throw new Error(`Stats component only accepts Stat components as children. Received ${child.type} instead.`);
46
+ }
47
+ });
48
+
49
+ return (
50
+ <Container direction={direction} grouped={grouped} count={Children.count(children)}>
51
+ <StatContext.Provider value={{ grouped, direction, size }}>{children}</StatContext.Provider>
52
+ </Container>
53
+ );
54
+ };
55
+
56
+ Stats.Stat = Stat;
57
+ Stats.Sparkline = Sparkline;
58
+
59
+ export type { Direction } from './context';
60
+ export type { Size } from '../../../styled';
61
+ export type { TrendConfig } from './Stat';
62
+ export type { SparklineProps } from './Sparkline';
@@ -0,0 +1,146 @@
1
+ import React, { FC, useEffect } from 'react';
2
+ import { Meta, StoryFn } from '@storybook/react';
3
+
4
+ import { Table, TableProps } from '.';
5
+ import { createColumnHelper } from '@tanstack/react-table';
6
+ import { Chip } from '../../../components';
7
+ import { useTableActions } from '../../../hooks';
8
+
9
+ type User = {
10
+ firstName: string;
11
+ lastName: string;
12
+ age: number;
13
+ visits: number;
14
+ status: string;
15
+ progress: number;
16
+ };
17
+
18
+ const data: User[] = [
19
+ {
20
+ firstName: 'John',
21
+ lastName: 'Doe',
22
+ age: 32,
23
+ visits: 32,
24
+ status: 'complicated',
25
+ progress: 66,
26
+ },
27
+ {
28
+ firstName: 'Jane',
29
+ lastName: 'Doe',
30
+ age: 30,
31
+ visits: 30,
32
+ status: 'single',
33
+ progress: 100,
34
+ },
35
+ {
36
+ firstName: 'Sam',
37
+ lastName: 'Doe',
38
+ age: 28,
39
+ visits: 28,
40
+ status: 'married',
41
+ progress: 0,
42
+ },
43
+ {
44
+ firstName: 'Sally',
45
+ lastName: 'Doe',
46
+ age: 26,
47
+ visits: 26,
48
+ status: 'single',
49
+ progress: 100,
50
+ },
51
+ {
52
+ firstName: 'Bob',
53
+ lastName: 'Doe',
54
+ age: 24,
55
+ visits: 24,
56
+ status: 'single',
57
+ progress: 100,
58
+ },
59
+ {
60
+ firstName: 'Barbara',
61
+ lastName: 'Doe',
62
+ age: 22,
63
+ visits: 22,
64
+ status: 'single',
65
+ progress: 100,
66
+ },
67
+ ];
68
+
69
+ const columnHelper = createColumnHelper<User>();
70
+ const columns = [
71
+ columnHelper.accessor('firstName', {
72
+ id: 'firstName',
73
+ header: 'First Name',
74
+ cell: (info) => info.getValue(),
75
+ }),
76
+ columnHelper.accessor('lastName', {
77
+ id: 'lastName',
78
+ header: 'Last Name',
79
+ cell: (info) => <i>{info.getValue()}</i>,
80
+ }),
81
+ columnHelper.accessor('age', {
82
+ id: 'age',
83
+ header: 'Age',
84
+ cell: (info) => info.renderValue(),
85
+ }),
86
+ columnHelper.accessor('visits', {
87
+ id: 'visits',
88
+ header: 'Visits',
89
+ }),
90
+ columnHelper.accessor('status', {
91
+ id: 'status',
92
+ header: 'Status',
93
+ cell: (info) => <Chip variant="outline" color="primary" label={info.getValue()} />,
94
+ }),
95
+ columnHelper.accessor('progress', {
96
+ id: 'progress',
97
+ header: 'Profile Progress',
98
+ }),
99
+ ];
100
+
101
+ export default {
102
+ title: 'Data/Table',
103
+ component: Table,
104
+ args: {
105
+ sort: false,
106
+ refetching: true,
107
+ isLoading: false,
108
+ data,
109
+ },
110
+ } as Meta<TableProps<User>>;
111
+
112
+ const Users: FC<TableProps<User>> = (args) => {
113
+ const { pagination, sorting, columnSearch, columnFilters, rowSelection } = useTableActions<User>();
114
+
115
+ useEffect(() => {
116
+ pagination.setPaginationState({
117
+ ...pagination.paginationState,
118
+ pageSize: 1,
119
+ });
120
+ }, []);
121
+
122
+ return (
123
+ <Table
124
+ id="story-table"
125
+ data={args.data}
126
+ columns={columns}
127
+ pagination={{
128
+ ...pagination,
129
+ pageOptions: {
130
+ pageCount: 10,
131
+ total: 20,
132
+ },
133
+ }}
134
+ isLoading={args.isLoading}
135
+ columnFiltering={columnFilters}
136
+ columnSearch={columnSearch}
137
+ rowSelection={rowSelection}
138
+ sorting={sorting}
139
+ />
140
+ );
141
+ };
142
+
143
+ export const EmptyTable: StoryFn<TableProps<User>> = (args) => {
144
+ return <Users {...args} data={[]} />;
145
+ };
146
+ export const DataTable: StoryFn<TableProps<User>> = (args) => <Users {...args} />;