@hyphen/hyphen-components 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/package.json +138 -0
  4. package/src/components/Alert/Alert.constants.ts +19 -0
  5. package/src/components/Alert/Alert.mdx +29 -0
  6. package/src/components/Alert/Alert.module.scss +74 -0
  7. package/src/components/Alert/Alert.stories.tsx +102 -0
  8. package/src/components/Alert/Alert.test.tsx +187 -0
  9. package/src/components/Alert/Alert.tsx +157 -0
  10. package/src/components/Alert/Alert.types.ts +14 -0
  11. package/src/components/Badge/Badge.mdx +28 -0
  12. package/src/components/Badge/Badge.module.scss +155 -0
  13. package/src/components/Badge/Badge.stories.tsx +52 -0
  14. package/src/components/Badge/Badge.test.tsx +74 -0
  15. package/src/components/Badge/Badge.tsx +70 -0
  16. package/src/components/Box/Box.mdx +259 -0
  17. package/src/components/Box/Box.module.scss +16 -0
  18. package/src/components/Box/Box.stories.tsx +1679 -0
  19. package/src/components/Box/Box.test.tsx +478 -0
  20. package/src/components/Box/Box.tsx +636 -0
  21. package/src/components/Button/Button.constants.ts +10 -0
  22. package/src/components/Button/Button.mdx +71 -0
  23. package/src/components/Button/Button.module.scss +312 -0
  24. package/src/components/Button/Button.stories.tsx +117 -0
  25. package/src/components/Button/Button.test.tsx +460 -0
  26. package/src/components/Button/Button.tsx +241 -0
  27. package/src/components/Card/Card.mdx +46 -0
  28. package/src/components/Card/Card.module.scss +6 -0
  29. package/src/components/Card/Card.stories.tsx +101 -0
  30. package/src/components/Card/Card.test.tsx +11 -0
  31. package/src/components/Card/Card.tsx +61 -0
  32. package/src/components/Card/components/CardFooter/CardFooter.test.tsx +11 -0
  33. package/src/components/Card/components/CardFooter/CardFooter.tsx +35 -0
  34. package/src/components/Card/components/CardHeader/CardHeader.test.tsx +23 -0
  35. package/src/components/Card/components/CardHeader/CardHeader.tsx +54 -0
  36. package/src/components/Card/components/CardSection/CardSection.test.tsx +28 -0
  37. package/src/components/Card/components/CardSection/CardSection.tsx +102 -0
  38. package/src/components/Card/components/index.ts +3 -0
  39. package/src/components/CheckboxInput/CheckboxInput.mdx +98 -0
  40. package/src/components/CheckboxInput/CheckboxInput.stories.tsx +254 -0
  41. package/src/components/CheckboxInput/CheckboxInput.test.tsx +436 -0
  42. package/src/components/CheckboxInput/CheckboxInput.tsx +171 -0
  43. package/src/components/CheckboxInput/components/Checkbox.module.scss +174 -0
  44. package/src/components/CheckboxInput/components/Checkbox.test.tsx +201 -0
  45. package/src/components/CheckboxInput/components/Checkbox.tsx +176 -0
  46. package/src/components/CheckboxInput/components/CheckboxIcon.tsx +71 -0
  47. package/src/components/DateInput/DateInput.mdx +61 -0
  48. package/src/components/DateInput/DateInput.stories.tsx +168 -0
  49. package/src/components/DateInput/DateInput.test.tsx +258 -0
  50. package/src/components/DateInput/DateInput.tsx +189 -0
  51. package/src/components/DatePicker/DatePicker.mdx +52 -0
  52. package/src/components/DatePicker/DatePicker.module.scss +603 -0
  53. package/src/components/DatePicker/DatePicker.stories.tsx +199 -0
  54. package/src/components/DatePicker/DatePicker.test.tsx +26 -0
  55. package/src/components/DatePicker/DatePicker.tsx +138 -0
  56. package/src/components/Details/Details.mdx +30 -0
  57. package/src/components/Details/Details.module.scss +32 -0
  58. package/src/components/Details/Details.stories.tsx +38 -0
  59. package/src/components/Details/Details.test.tsx +189 -0
  60. package/src/components/Details/Details.tsx +51 -0
  61. package/src/components/Details/DetailsSummary.tsx +65 -0
  62. package/src/components/Drawer/Drawer.mdx +117 -0
  63. package/src/components/Drawer/Drawer.module.scss +96 -0
  64. package/src/components/Drawer/Drawer.stories.tsx +380 -0
  65. package/src/components/Drawer/Drawer.test.tsx +90 -0
  66. package/src/components/Drawer/Drawer.tsx +249 -0
  67. package/src/components/FormControl/FormControl.tsx +78 -0
  68. package/src/components/FormLabel/FormLabel.mdx +24 -0
  69. package/src/components/FormLabel/FormLabel.module.scss +19 -0
  70. package/src/components/FormLabel/FormLabel.stories.tsx +20 -0
  71. package/src/components/FormLabel/FormLabel.test.tsx +35 -0
  72. package/src/components/FormLabel/FormLabel.tsx +96 -0
  73. package/src/components/Formik/Formik.mdx +10 -0
  74. package/src/components/Formik/Formik.stories.tsx +307 -0
  75. package/src/components/Formik/FormikCheckboxInput/FormikCheckboxInput.test.tsx +172 -0
  76. package/src/components/Formik/FormikCheckboxInput/FormikCheckboxInput.tsx +41 -0
  77. package/src/components/Formik/FormikRadioGroup/FormikRadioGroup.test.tsx +205 -0
  78. package/src/components/Formik/FormikRadioGroup/FormikRadioGroup.tsx +37 -0
  79. package/src/components/Formik/FormikSelectInput/FormikSelectInput.test.tsx +210 -0
  80. package/src/components/Formik/FormikSelectInput/FormikSelectInput.tsx +41 -0
  81. package/src/components/Formik/FormikSelectInputInset/FormikSelectInputInset.test.tsx +153 -0
  82. package/src/components/Formik/FormikSelectInputInset/FormikSelectInputInset.tsx +44 -0
  83. package/src/components/Formik/FormikSelectInputNative/FormikSelectInputNative.test.tsx +161 -0
  84. package/src/components/Formik/FormikSelectInputNative/FormikSelectInputNative.tsx +46 -0
  85. package/src/components/Formik/FormikTextInput/FormikTextInput.test.tsx +176 -0
  86. package/src/components/Formik/FormikTextInput/FormikTextInput.tsx +38 -0
  87. package/src/components/Formik/FormikTextInputInset/FormikTextInputInset.test.tsx +170 -0
  88. package/src/components/Formik/FormikTextInputInset/FormikTextInputInset.tsx +42 -0
  89. package/src/components/Formik/FormikTextareaInput/FormikTextareaInput.test.tsx +186 -0
  90. package/src/components/Formik/FormikTextareaInput/FormikTextareaInput.tsx +42 -0
  91. package/src/components/Formik/FormikTextareaInputInset/FormikTextareaInputInset.test.tsx +179 -0
  92. package/src/components/Formik/FormikTextareaInputInset/FormikTextareaInputInset.tsx +42 -0
  93. package/src/components/Formik/FormikTimePicker/FormikTimePicker.test.tsx +224 -0
  94. package/src/components/Formik/FormikTimePicker/FormikTimePicker.tsx +37 -0
  95. package/src/components/Formik/FormikTimePickerNative/FormikTimePickerNative.test.tsx +175 -0
  96. package/src/components/Formik/FormikTimePickerNative/FormikTimePickerNative.tsx +38 -0
  97. package/src/components/Formik/FormikToggle/FormikToggle.test.tsx +172 -0
  98. package/src/components/Formik/FormikToggle/FormikToggle.tsx +38 -0
  99. package/src/components/Heading/Heading.constants.ts +19 -0
  100. package/src/components/Heading/Heading.mdx +35 -0
  101. package/src/components/Heading/Heading.module.scss +5 -0
  102. package/src/components/Heading/Heading.stories.tsx +90 -0
  103. package/src/components/Heading/Heading.test.tsx +67 -0
  104. package/src/components/Heading/Heading.tsx +67 -0
  105. package/src/components/HelpText/HelpText.module.scss +14 -0
  106. package/src/components/HelpText/HelpText.tsx +33 -0
  107. package/src/components/Icon/Icon.mdx +40 -0
  108. package/src/components/Icon/Icon.stories.tsx +72 -0
  109. package/src/components/Icon/Icon.test.tsx +30 -0
  110. package/src/components/Icon/Icon.tsx +61 -0
  111. package/src/components/InputValidationMessage/InputValidationMessage.module.scss +3 -0
  112. package/src/components/InputValidationMessage/InputValidationMessage.tsx +27 -0
  113. package/src/components/Modal/Modal.mdx +60 -0
  114. package/src/components/Modal/Modal.module.scss +135 -0
  115. package/src/components/Modal/Modal.stories.tsx +194 -0
  116. package/src/components/Modal/Modal.test.tsx +81 -0
  117. package/src/components/Modal/Modal.tsx +174 -0
  118. package/src/components/Modal/components/ModalBody/ModalBody.test.tsx +20 -0
  119. package/src/components/Modal/components/ModalBody/ModalBody.tsx +24 -0
  120. package/src/components/Modal/components/ModalFooter/ModalFooter.test.tsx +32 -0
  121. package/src/components/Modal/components/ModalFooter/ModalFooter.tsx +37 -0
  122. package/src/components/Modal/components/ModalHeader/ModalHeader.test.tsx +29 -0
  123. package/src/components/Modal/components/ModalHeader/ModalHeader.tsx +58 -0
  124. package/src/components/Modal/components/index.ts +5 -0
  125. package/src/components/Pagination/Pagination.mdx +26 -0
  126. package/src/components/Pagination/Pagination.stories.tsx +55 -0
  127. package/src/components/Pagination/Pagination.test.tsx +225 -0
  128. package/src/components/Pagination/Pagination.tsx +162 -0
  129. package/src/components/Pagination/Pagination.utilities.test.ts +133 -0
  130. package/src/components/Pagination/Pagination.utilities.ts +101 -0
  131. package/src/components/Popover/Popover.mdx +104 -0
  132. package/src/components/Popover/Popover.module.scss +74 -0
  133. package/src/components/Popover/Popover.stories.tsx +471 -0
  134. package/src/components/Popover/Popover.test.tsx +128 -0
  135. package/src/components/Popover/Popover.tsx +277 -0
  136. package/src/components/RadioGroup/RadioGroup.mdx +81 -0
  137. package/src/components/RadioGroup/RadioGroup.module.scss +23 -0
  138. package/src/components/RadioGroup/RadioGroup.stories.tsx +375 -0
  139. package/src/components/RadioGroup/RadioGroup.test.tsx +282 -0
  140. package/src/components/RadioGroup/RadioGroup.tsx +145 -0
  141. package/src/components/RadioGroup/RadioInput/RadioInput.module.scss +114 -0
  142. package/src/components/RadioGroup/RadioInput/RadioInput.test.tsx +156 -0
  143. package/src/components/RadioGroup/RadioInput/RadioInput.tsx +148 -0
  144. package/src/components/RadioGroup/RadioInput/RadioInputIcon.tsx +59 -0
  145. package/src/components/ResponsiveProvider/ResponsiveProvider.mdx +36 -0
  146. package/src/components/ResponsiveProvider/ResponsiveProvider.stories.tsx +54 -0
  147. package/src/components/ResponsiveProvider/ResponsiveProvider.test.tsx +70 -0
  148. package/src/components/ResponsiveProvider/ResponsiveProvider.tsx +73 -0
  149. package/src/components/SelectInput/SelectInput.mdx +115 -0
  150. package/src/components/SelectInput/SelectInput.module.scss +357 -0
  151. package/src/components/SelectInput/SelectInput.stories.tsx +373 -0
  152. package/src/components/SelectInput/SelectInput.test.tsx +403 -0
  153. package/src/components/SelectInput/SelectInput.tsx +245 -0
  154. package/src/components/SelectInputInset/SelectInputInset.mdx +56 -0
  155. package/src/components/SelectInputInset/SelectInputInset.module.scss +397 -0
  156. package/src/components/SelectInputInset/SelectInputInset.stories.tsx +189 -0
  157. package/src/components/SelectInputInset/SelectInputInset.test.tsx +305 -0
  158. package/src/components/SelectInputInset/SelectInputInset.tsx +235 -0
  159. package/src/components/SelectInputNative/SelectInputNative.mdx +87 -0
  160. package/src/components/SelectInputNative/SelectInputNative.module.scss +356 -0
  161. package/src/components/SelectInputNative/SelectInputNative.stories.tsx +282 -0
  162. package/src/components/SelectInputNative/SelectInputNative.test.tsx +341 -0
  163. package/src/components/SelectInputNative/SelectInputNative.tsx +121 -0
  164. package/src/components/Spinner/Spinner.mdx +29 -0
  165. package/src/components/Spinner/Spinner.module.scss +16 -0
  166. package/src/components/Spinner/Spinner.stories.tsx +48 -0
  167. package/src/components/Spinner/Spinner.test.tsx +47 -0
  168. package/src/components/Spinner/Spinner.tsx +116 -0
  169. package/src/components/Table/Table.mdx +216 -0
  170. package/src/components/Table/Table.module.scss +61 -0
  171. package/src/components/Table/Table.stories.tsx +884 -0
  172. package/src/components/Table/Table.test.tsx +437 -0
  173. package/src/components/Table/Table.tsx +171 -0
  174. package/src/components/Table/TableBody/TableBody.module.scss +19 -0
  175. package/src/components/Table/TableBody/TableBody.test.tsx +38 -0
  176. package/src/components/Table/TableBody/TableBody.tsx +96 -0
  177. package/src/components/Table/TableBody/TableBodyCell/TableBodyCell.module.scss +47 -0
  178. package/src/components/Table/TableBody/TableBodyCell/TableBodyCell.test.tsx +81 -0
  179. package/src/components/Table/TableBody/TableBodyCell/TableBodyCell.tsx +94 -0
  180. package/src/components/Table/TableHead/TableHead.test.tsx +20 -0
  181. package/src/components/Table/TableHead/TableHead.tsx +78 -0
  182. package/src/components/Table/TableHead/TableHeaderCell/TableHeaderCell.module.scss +72 -0
  183. package/src/components/Table/TableHead/TableHeaderCell/TableHeaderCell.test.tsx +187 -0
  184. package/src/components/Table/TableHead/TableHeaderCell/TableHeaderCell.tsx +192 -0
  185. package/src/components/Table/common/TableRow/TableRow.module.scss +5 -0
  186. package/src/components/Table/common/TableRow/TableRow.test.tsx +52 -0
  187. package/src/components/Table/common/TableRow/TableRow.tsx +155 -0
  188. package/src/components/TextInput/TextInput.mdx +96 -0
  189. package/src/components/TextInput/TextInput.module.scss +405 -0
  190. package/src/components/TextInput/TextInput.stories.tsx +268 -0
  191. package/src/components/TextInput/TextInput.test.tsx +231 -0
  192. package/src/components/TextInput/TextInput.tsx +263 -0
  193. package/src/components/TextInputInset/TextInputInset.mdx +62 -0
  194. package/src/components/TextInputInset/TextInputInset.module.scss +418 -0
  195. package/src/components/TextInputInset/TextInputInset.stories.tsx +213 -0
  196. package/src/components/TextInputInset/TextInputInset.test.tsx +222 -0
  197. package/src/components/TextInputInset/TextInputInset.tsx +261 -0
  198. package/src/components/TextareaInput/TextareaInput.mdx +117 -0
  199. package/src/components/TextareaInput/TextareaInput.module.scss +275 -0
  200. package/src/components/TextareaInput/TextareaInput.stories.tsx +293 -0
  201. package/src/components/TextareaInput/TextareaInput.test.tsx +195 -0
  202. package/src/components/TextareaInput/TextareaInput.tsx +182 -0
  203. package/src/components/TextareaInputInset/TextareaInputInset.mdx +55 -0
  204. package/src/components/TextareaInputInset/TextareaInputInset.module.scss +337 -0
  205. package/src/components/TextareaInputInset/TextareaInputInset.stories.tsx +160 -0
  206. package/src/components/TextareaInputInset/TextareaInputInset.test.tsx +199 -0
  207. package/src/components/TextareaInputInset/TextareaInputInset.tsx +213 -0
  208. package/src/components/ThemeProvider/ThemeProvider.mdx +11 -0
  209. package/src/components/ThemeProvider/ThemeProvider.stories.tsx +56 -0
  210. package/src/components/ThemeProvider/ThemeProvider.tsx +75 -0
  211. package/src/components/TimePicker/TimePicker.mdx +75 -0
  212. package/src/components/TimePicker/TimePicker.stories.tsx +149 -0
  213. package/src/components/TimePicker/TimePicker.test.tsx +97 -0
  214. package/src/components/TimePicker/TimePicker.tsx +83 -0
  215. package/src/components/TimePickerNative/TimePickerNative.mdx +67 -0
  216. package/src/components/TimePickerNative/TimePickerNative.stories.tsx +151 -0
  217. package/src/components/TimePickerNative/TimePickerNative.test.tsx +117 -0
  218. package/src/components/TimePickerNative/TimePickerNative.tsx +93 -0
  219. package/src/components/Toast/Toast.mdx +134 -0
  220. package/src/components/Toast/Toast.store.ts +280 -0
  221. package/src/components/Toast/Toast.stories.tsx +283 -0
  222. package/src/components/Toast/Toast.test.tsx +784 -0
  223. package/src/components/Toast/Toast.types.ts +98 -0
  224. package/src/components/Toast/ToastContainer.tsx +170 -0
  225. package/src/components/Toast/ToastNotification.module.scss +63 -0
  226. package/src/components/Toast/ToastNotification.tsx +176 -0
  227. package/src/components/Toast/index.ts +4 -0
  228. package/src/components/Toast/toast.ts +102 -0
  229. package/src/components/Toast/useToasts.ts +102 -0
  230. package/src/components/Toggle/Toggle.mdx +51 -0
  231. package/src/components/Toggle/Toggle.module.scss +294 -0
  232. package/src/components/Toggle/Toggle.stories.tsx +128 -0
  233. package/src/components/Toggle/Toggle.test.tsx +308 -0
  234. package/src/components/Toggle/Toggle.tsx +184 -0
  235. package/src/constants/keyCodes.ts +2 -0
  236. package/src/docs/Brands.mdx +153 -0
  237. package/src/docs/Colors.mdx +158 -0
  238. package/src/docs/DesignTokens.mdx +415 -0
  239. package/src/docs/GetStarted.mdx +47 -0
  240. package/src/docs/intro.mdx +12 -0
  241. package/src/fonts/AvenirBold.otf +0 -0
  242. package/src/fonts/AvenirBold.woff +0 -0
  243. package/src/fonts/AvenirBold.woff2 +0 -0
  244. package/src/fonts/AvenirLight.otf +0 -0
  245. package/src/fonts/AvenirLight.woff +0 -0
  246. package/src/fonts/AvenirLight.woff2 +0 -0
  247. package/src/fonts/AvenirRegular.otf +0 -0
  248. package/src/fonts/AvenirRegular.woff +0 -0
  249. package/src/fonts/AvenirRegular.woff2 +0 -0
  250. package/src/fonts/Geist-Bold.otf +0 -0
  251. package/src/fonts/Geist-Bold.woff +0 -0
  252. package/src/fonts/Geist-Bold.woff2 +0 -0
  253. package/src/fonts/Geist-Medium.otf +0 -0
  254. package/src/fonts/Geist-Medium.woff +0 -0
  255. package/src/fonts/Geist-Medium.woff2 +0 -0
  256. package/src/fonts/Geist-Regular.otf +0 -0
  257. package/src/fonts/Geist-Regular.woff +0 -0
  258. package/src/fonts/Geist-Regular.woff2 +0 -0
  259. package/src/fonts/Geist-SemiBold.otf +0 -0
  260. package/src/fonts/Geist-SemiBold.woff +0 -0
  261. package/src/fonts/Geist-SemiBold.woff2 +0 -0
  262. package/src/fonts/GeistMono-Regular.otf +0 -0
  263. package/src/fonts/GeistMono-Regular.woff +0 -0
  264. package/src/fonts/GeistMono-Regular.woff2 +0 -0
  265. package/src/hooks/index.ts +4 -0
  266. package/src/hooks/useBreakpoint/useBreakpoint.mdx +26 -0
  267. package/src/hooks/useBreakpoint/useBreakpoint.stories.tsx +30 -0
  268. package/src/hooks/useBreakpoint/useBreakpoint.test.tsx +19 -0
  269. package/src/hooks/useBreakpoint/useBreakpoint.ts +50 -0
  270. package/src/hooks/useIsomorphicLayoutEffect/useIsomorphicLayouEffect.ts +5 -0
  271. package/src/hooks/useOpenClose/useOpenClose.mdx +15 -0
  272. package/src/hooks/useOpenClose/useOpenClose.stories.tsx +41 -0
  273. package/src/hooks/useOpenClose/useOpenClose.test.tsx +119 -0
  274. package/src/hooks/useOpenClose/useOpenClose.tsx +95 -0
  275. package/src/hooks/useWindowSize/useWindowSize.mdx +25 -0
  276. package/src/hooks/useWindowSize/useWindowSize.stories.tsx +35 -0
  277. package/src/hooks/useWindowSize/useWindowSize.ts +24 -0
  278. package/src/index.ts +48 -0
  279. package/src/lib/cssShorthandToClasses.test.ts +149 -0
  280. package/src/lib/cssShorthandToClasses.ts +133 -0
  281. package/src/lib/doesStringIncludeCssUnit.ts +6 -0
  282. package/src/lib/generateResponsiveClasses.test.ts +24 -0
  283. package/src/lib/generateResponsiveClasses.ts +30 -0
  284. package/src/lib/getAutoCompleteValue.test.ts +27 -0
  285. package/src/lib/getAutoCompleteValue.ts +12 -0
  286. package/src/lib/getColumnKeys.ts +27 -0
  287. package/src/lib/getDimensionCss.test.ts +148 -0
  288. package/src/lib/getDimensionCss.ts +73 -0
  289. package/src/lib/getElementType.test.tsx +42 -0
  290. package/src/lib/getElementType.ts +42 -0
  291. package/src/lib/getFlexCss.test.ts +122 -0
  292. package/src/lib/getFlexCss.ts +67 -0
  293. package/src/lib/index.ts +15 -0
  294. package/src/lib/isFunction.ts +6 -0
  295. package/src/lib/mergeRefs.ts +15 -0
  296. package/src/lib/prefersReducedMotion.ts +12 -0
  297. package/src/lib/react-children-utilities/filter.ts +12 -0
  298. package/src/lib/react-children-utilities/index.ts +1 -0
  299. package/src/lib/reactRouterClickHandler.ts +37 -0
  300. package/src/lib/resolveValue.ts +7 -0
  301. package/src/lib/tokens.ts +139 -0
  302. package/src/modes.ts +8 -0
  303. package/src/styles/animation.scss +152 -0
  304. package/src/styles/cursor.scss +43 -0
  305. package/src/styles/display.scss +119 -0
  306. package/src/styles/flex.scss +453 -0
  307. package/src/styles/fonts.scss +44 -0
  308. package/src/styles/globals/utilities.scss +4 -0
  309. package/src/styles/mixins.scss +14 -0
  310. package/src/styles/overflow.scss +41 -0
  311. package/src/styles/position.scss +45 -0
  312. package/src/styles/reset.scss +108 -0
  313. package/src/styles/text-align.scss +21 -0
  314. package/src/styles/utilities.scss +9 -0
  315. package/src/styles/variables/forms.scss +71 -0
  316. package/src/styles/variables/index.scss +3 -0
  317. package/src/styles/white-space.scss +21 -0
  318. package/src/types/index.ts +201 -0
  319. package/src/types/lib.types.ts +3 -0
@@ -0,0 +1,884 @@
1
+ import type { Meta } from '@storybook/react';
2
+ import React, { useEffect, useState } from 'react';
3
+ import { Table } from './Table';
4
+ import { Button } from '../Button/Button';
5
+ import { Badge } from '../Badge/Badge';
6
+ import type { Column as ColumnType } from '../../types';
7
+
8
+ const meta: Meta<typeof Table> = {
9
+ title: 'Components/Table',
10
+ component: Table,
11
+ };
12
+
13
+ export default meta;
14
+
15
+ export const Column = () =>
16
+ (() => {
17
+ const codePreviewStyle = {
18
+ padding: '3px 5px',
19
+ borderRadius: '3px',
20
+ border: '1px solid #EEEEEE',
21
+ color: 'rgba(51,51,51,0.9)',
22
+ backgroundColor: '#F8F8F8',
23
+ };
24
+ const columnInterfaceRows = [
25
+ {
26
+ name: 'align',
27
+ type: 'left | right | center',
28
+ description:
29
+ 'Text alignment for column cells (including header alignment). Cells will default to left if not defined.',
30
+ },
31
+ {
32
+ name: 'cellClassName',
33
+ type: 'string | (function: (cell, row, rowIndex) => string)',
34
+ description: 'A CSS class to be applied to all cells in the column',
35
+ },
36
+ {
37
+ name: 'dataKey',
38
+ type: 'string',
39
+ description: 'The key in the rows object that matches this column',
40
+ },
41
+ {
42
+ name: 'emptyCellPlaceholder',
43
+ type: 'string | number | undefined',
44
+ description: 'placeholder for empty cells',
45
+ },
46
+ {
47
+ name: 'heading',
48
+ type: 'string',
49
+ description: 'The heading text to be displayed',
50
+ },
51
+ {
52
+ name: 'headerClassName',
53
+ type: 'string',
54
+ description: 'The CSS class to be applied to the column header cell.',
55
+ },
56
+ {
57
+ name: 'isSortable',
58
+ type: 'boolean',
59
+ description:
60
+ 'Whether the column is sortable. Controls displaying the sort arrows and making the column header clickable',
61
+ },
62
+ {
63
+ name: 'key',
64
+ type: 'React.Key',
65
+ description:
66
+ 'a custom key to be passed to each column. This gets autogenerated if not supplued',
67
+ },
68
+ {
69
+ name: 'render',
70
+ type: 'function: (cell, row, rowIndex) => ReactNode',
71
+ description:
72
+ 'Render any custom content based on the cell and row content',
73
+ },
74
+ {
75
+ name: 'sticky',
76
+ type: "enum: 'left', 'right', ",
77
+ description:
78
+ 'Whether the column will stick to the left or right side of the table when the table is larger than its parent',
79
+ },
80
+ {
81
+ name: 'truncateOverflow',
82
+ type: 'boolean',
83
+ description:
84
+ 'Whether the column content will get truncated (with ellipsis) if it surpasses the fixed-width',
85
+ },
86
+ {
87
+ name: 'width',
88
+ type: 'number',
89
+ description: 'Specify the width of a particular column.',
90
+ },
91
+ ];
92
+ const columnConfig = [
93
+ { heading: 'Name', dataKey: 'name' },
94
+ {
95
+ heading: 'Type',
96
+ dataKey: 'type',
97
+ render: (cell: any) => <code style={codePreviewStyle}>{cell}</code>,
98
+ },
99
+ { heading: 'Description', dataKey: 'description' },
100
+ ];
101
+ return (
102
+ <Table rowKey="name" columns={columnConfig} rows={columnInterfaceRows} />
103
+ );
104
+ })();
105
+
106
+ export const CommonExample = () =>
107
+ (() => {
108
+ const columnConfig = [
109
+ {
110
+ heading: 'Customer',
111
+ dataKey: 'customerInfo',
112
+ render: (_cell: any, row: any) => (
113
+ <div>
114
+ <div>{row.name}</div>
115
+ <div className="font-color-base">{row.email}</div>
116
+ </div>
117
+ ),
118
+ },
119
+ { heading: 'phone', dataKey: 'phone', width: 125 },
120
+ { heading: 'plan', dataKey: 'plan', width: 125 },
121
+ { heading: 'status', dataKey: 'status', width: 125 },
122
+ ];
123
+ const tableData = [
124
+ {
125
+ status: 'lead captured',
126
+ name: 'John Smith',
127
+ email: 'john@hyphen.ai',
128
+ phone: '555 555-5555',
129
+ plan: 'standard',
130
+ },
131
+ {
132
+ status: 'proposal in progress',
133
+ name: 'Jill Sanchez',
134
+ email: 'jill@hyphen.ai',
135
+ phone: '555 555-5555',
136
+ plan: 'premium',
137
+ },
138
+ {
139
+ status: 'PTO',
140
+ name: 'Jin Lee',
141
+ email: 'jin@hyphen.ai',
142
+ phone: '555 555-5555',
143
+ plan: 'standard',
144
+ },
145
+ ];
146
+ return <Table rowKey="id" columns={columnConfig} rows={tableData} />;
147
+ })();
148
+
149
+ export const Loading = () =>
150
+ (() => {
151
+ const columnConfig = [
152
+ { heading: 'ID', dataKey: 'id' },
153
+ { heading: 'Color', dataKey: 'color' },
154
+ { heading: 'Flavor', dataKey: 'flavor' },
155
+ ];
156
+ const tableData = [
157
+ { id: 1, color: 'red', flavor: 'vanilla' },
158
+ { id: 2, color: 'blue', flavor: 'chocolate' },
159
+ { id: 3, color: 'green', flavor: 'strawberry' },
160
+ ];
161
+ return (
162
+ <Table rowKey="id" columns={columnConfig} rows={tableData} isLoading />
163
+ );
164
+ })();
165
+
166
+ export const Sortable = () => {
167
+ // @ts-ignore
168
+ const sortDescending = (arrOfObj, key) =>
169
+ [...arrOfObj].sort((a, b) => (b[key] > a[key] ? 1 : -1));
170
+ // @ts-ignore
171
+ const sortAscending = (arrOfObj, key) =>
172
+ [...arrOfObj].sort((a, b) => (a[key] > b[key] ? 1 : -1));
173
+ const getNewSortDirection = (event: any, currentSortedColumn: any) => {
174
+ if (
175
+ event.sortedKey === currentSortedColumn.dataKey &&
176
+ currentSortedColumn.sortDirection === 'ascending'
177
+ )
178
+ return 'descending';
179
+ return 'ascending';
180
+ };
181
+ const initialData = [
182
+ { id: 1, color: 'red', flavor: 'vanilla' },
183
+ { id: 2, color: 'green', flavor: 'strawberry' },
184
+ { id: 3, color: 'blue', flavor: 'chocolate' },
185
+ ];
186
+ const [sortedColumn, setSortedColumn] = useState<any>({});
187
+ const [tableData, setTableData] = useState(initialData);
188
+ const handleSort = (event: any) => {
189
+ const newSortDirection = getNewSortDirection(event, sortedColumn);
190
+ setSortedColumn({
191
+ dataKey: event.sortedKey,
192
+ sortDirection: newSortDirection,
193
+ });
194
+ };
195
+ useEffect(() => {
196
+ if (sortedColumn.dataKey && sortedColumn.sortDirection) {
197
+ const sortedData =
198
+ sortedColumn.sortDirection === 'ascending'
199
+ ? sortAscending(tableData, sortedColumn.dataKey)
200
+ : sortDescending(tableData, sortedColumn.dataKey);
201
+ setTableData(sortedData);
202
+ }
203
+ }, [sortedColumn, tableData]);
204
+ const columnConfig = [
205
+ { heading: 'ID', dataKey: 'id', isSortable: true },
206
+ { heading: 'Color', dataKey: 'color', isSortable: true },
207
+ { heading: 'Flavor', dataKey: 'flavor', isSortable: true },
208
+ ];
209
+ return (
210
+ <Table
211
+ rowKey="id"
212
+ columns={columnConfig}
213
+ rows={tableData}
214
+ sortedColumn={sortedColumn}
215
+ onSort={handleSort}
216
+ />
217
+ );
218
+ };
219
+
220
+ export const SortablewithDefaultSortedColumn = () => {
221
+ // @ts-ignore
222
+ const sortDescending = (arrOfObj, key) =>
223
+ [...arrOfObj].sort((a, b) => (b[key] > a[key] ? 1 : -1));
224
+ // @ts-ignore
225
+ const sortAscending = (arrOfObj, key) =>
226
+ [...arrOfObj].sort((a, b) => (a[key] > b[key] ? 1 : -1));
227
+ const getNewSortDirection = (event: any, currentSortedColumn: any) => {
228
+ if (
229
+ event.sortedKey === currentSortedColumn.dataKey &&
230
+ currentSortedColumn.sortDirection === 'ascending'
231
+ )
232
+ return 'descending';
233
+ return 'ascending';
234
+ };
235
+ const initialData = [
236
+ { id: 1, color: 'red', flavor: 'vanilla' },
237
+ { id: 2, color: 'green', flavor: 'strawberry' },
238
+ { id: 3, color: 'blue', flavor: 'chocolate' },
239
+ ];
240
+ const [sortedColumn, setSortedColumn] = useState<any>({
241
+ dataKey: 'color',
242
+ sortDirection: 'descending',
243
+ });
244
+ const [tableData, setTableData] = useState([
245
+ ...(sortedColumn.sortDirecton === 'ascending'
246
+ ? sortAscending(initialData, sortedColumn.dataKey)
247
+ : sortDescending(initialData, sortedColumn.dataKey)),
248
+ ]);
249
+ const handleSort = (event: any) => {
250
+ const newSortDirection = getNewSortDirection(event, sortedColumn);
251
+ setSortedColumn({
252
+ dataKey: event.sortedKey,
253
+ sortDirection: newSortDirection,
254
+ });
255
+ };
256
+ useEffect(() => {
257
+ if (sortedColumn.dataKey && sortedColumn.sortDirection) {
258
+ const sortedData =
259
+ sortedColumn.sortDirection === 'ascending'
260
+ ? sortAscending(tableData, sortedColumn.dataKey)
261
+ : sortDescending(tableData, sortedColumn.dataKey);
262
+ setTableData(sortedData);
263
+ }
264
+ }, [sortedColumn, tableData]);
265
+ const columnConfig = [
266
+ { heading: 'ID', dataKey: 'id', isSortable: true },
267
+ { heading: 'Color', dataKey: 'color', isSortable: true },
268
+ { heading: 'Flavor', dataKey: 'flavor', isSortable: true },
269
+ ];
270
+ return (
271
+ <Table
272
+ rowKey="id"
273
+ columns={columnConfig}
274
+ rows={tableData}
275
+ sortedColumn={sortedColumn}
276
+ onSort={handleSort}
277
+ />
278
+ );
279
+ };
280
+
281
+ export const SortableAndLoading = () => {
282
+ // @ts-ignore
283
+ const sortDescending = (arrOfObj, key) =>
284
+ [...arrOfObj].sort((a, b) => (b[key] > a[key] ? 1 : -1));
285
+ // @ts-ignore
286
+ const sortAscending = (arrOfObj, key) =>
287
+ [...arrOfObj].sort((a, b) => (a[key] > b[key] ? 1 : -1));
288
+ const getNewSortDirection = (event: any, currentSortedColumn: any) => {
289
+ if (
290
+ event.sortedKey === currentSortedColumn.dataKey &&
291
+ currentSortedColumn.sortDirection === 'ascending'
292
+ )
293
+ return 'descending';
294
+ return 'ascending';
295
+ };
296
+ const initialData = [
297
+ { id: 1, color: 'red', flavor: 'vanilla' },
298
+ { id: 2, color: 'green', flavor: 'strawberry' },
299
+ { id: 3, color: 'blue', flavor: 'chocolate' },
300
+ ];
301
+ const [sortedColumn, setSortedColumn] = useState<any>({});
302
+ const [tableData, setTableData] = useState(initialData);
303
+ const handleSort = (event: any) => {
304
+ const newSortDirection = getNewSortDirection(event, sortedColumn);
305
+ setSortedColumn({
306
+ dataKey: event.sortedKey,
307
+ sortDirection: newSortDirection,
308
+ });
309
+ };
310
+ useEffect(() => {
311
+ if (sortedColumn.dataKey && sortedColumn.sortDirection) {
312
+ const sortedData =
313
+ sortedColumn.sortDirection === 'ascending'
314
+ ? sortAscending(tableData, sortedColumn.dataKey)
315
+ : sortDescending(tableData, sortedColumn.dataKey);
316
+ setTableData(sortedData);
317
+ }
318
+ }, [sortedColumn, tableData]);
319
+ const columnConfig = [
320
+ { heading: 'ID', dataKey: 'id', isSortable: true },
321
+ { heading: 'Color', dataKey: 'color', isSortable: true },
322
+ { heading: 'Flavor', dataKey: 'flavor', isSortable: true },
323
+ ];
324
+ return (
325
+ <Table
326
+ rowKey="id"
327
+ columns={columnConfig}
328
+ rows={tableData}
329
+ sortedColumn={sortedColumn}
330
+ onSort={handleSort}
331
+ isLoading
332
+ />
333
+ );
334
+ };
335
+
336
+ export const Scrollable = () =>
337
+ (() => {
338
+ const containerStyle = {
339
+ padding: '3px 5px',
340
+ borderRadius: '3px',
341
+ border: '1px solid #EEEEEE',
342
+ width: '300px',
343
+ height: '300px',
344
+ };
345
+ const columnConfig = [
346
+ { heading: 'ID', dataKey: 'id' },
347
+ { heading: 'Color', dataKey: 'color', width: 300 },
348
+ { heading: 'Flavor', dataKey: 'flavor' },
349
+ { heading: 'Brightness', dataKey: 'brightness' },
350
+ ];
351
+ const tableData = [
352
+ { id: 1, color: 'red', flavor: 'vanilla', brightness: 'light' },
353
+ { id: 2, color: 'blue', flavor: 'chocolate', brightness: 'medium' },
354
+ { id: 3, color: 'green', flavor: 'strawberry', brightness: 'dark' },
355
+ { id: 4, color: 'green', flavor: 'strawberry', brightness: 'dark' },
356
+ { id: 5, color: 'green', flavor: 'strawberry', brightness: 'dark' },
357
+ { id: 6, color: 'green', flavor: 'strawberry', brightness: 'dark' },
358
+ { id: 7, color: 'green', flavor: 'strawberry', brightness: 'dark' },
359
+ ];
360
+ return (
361
+ <div style={containerStyle}>
362
+ <Table
363
+ rowKey="id"
364
+ columns={columnConfig}
365
+ rows={tableData}
366
+ isScrollable={{ x: true, y: true }}
367
+ />
368
+ </div>
369
+ );
370
+ })();
371
+
372
+ export const ScrollablewithStickyHeader = () =>
373
+ (() => {
374
+ const containerStyle = {
375
+ borderRadius: '3px',
376
+ border: '1px solid #EEEEEE',
377
+ width: '300px',
378
+ height: '300px',
379
+ };
380
+ const columnConfig = [
381
+ { heading: 'ID', dataKey: 'id' },
382
+ { heading: 'Color', dataKey: 'color', width: 300 },
383
+ { heading: 'Flavor', dataKey: 'flavor', width: 100 },
384
+ { heading: 'Brightness', dataKey: 'brightness', width: 150 },
385
+ ];
386
+ const tableData = [
387
+ { id: 1, color: 'red', flavor: 'vanilla', brightness: 'light' },
388
+ { id: 2, color: 'blue', flavor: 'chocolate', brightness: 'medium' },
389
+ { id: 3, color: 'green', flavor: 'strawberry', brightness: 'dark' },
390
+ { id: 4, color: 'green', flavor: 'strawberry', brightness: 'dark' },
391
+ { id: 5, color: 'green', flavor: 'strawberry', brightness: 'dark' },
392
+ { id: 6, color: 'green', flavor: 'strawberry', brightness: 'dark' },
393
+ { id: 7, color: 'green', flavor: 'strawberry', brightness: 'dark' },
394
+ ];
395
+ return (
396
+ <div style={containerStyle}>
397
+ <Table
398
+ rowKey="id"
399
+ columns={columnConfig}
400
+ rows={tableData}
401
+ isScrollable={{ x: true, y: true }}
402
+ hasStickyHeader
403
+ />
404
+ </div>
405
+ );
406
+ })();
407
+
408
+ export const ScrollablewithFirstColumnStuckToLeft = () =>
409
+ (() => {
410
+ const containerStyle = {
411
+ borderRadius: '3px',
412
+ border: '1px solid #EEEEEE',
413
+ width: '300px',
414
+ height: '300px',
415
+ };
416
+ const columnConfig: ColumnType[] = [
417
+ { heading: 'ID', dataKey: 'id', sticky: 'left' },
418
+ { heading: 'Color', dataKey: 'color', width: 300 },
419
+ { heading: 'Flavor', dataKey: 'flavor', width: 100 },
420
+ { heading: 'Brightness', dataKey: 'brightness', width: 150 },
421
+ ];
422
+ const tableData = [
423
+ { id: 1, color: 'red', flavor: 'vanilla', brightness: 'light' },
424
+ { id: 2, color: 'blue', flavor: 'chocolate', brightness: 'medium' },
425
+ { id: 3, color: 'green', flavor: 'strawberry', brightness: 'dark' },
426
+ { id: 4, color: 'green', flavor: 'strawberry', brightness: 'dark' },
427
+ { id: 5, color: 'green', flavor: 'strawberry', brightness: 'dark' },
428
+ { id: 6, color: 'green', flavor: 'strawberry', brightness: 'dark' },
429
+ { id: 7, color: 'green', flavor: 'strawberry', brightness: 'dark' },
430
+ ];
431
+ return (
432
+ <div style={containerStyle}>
433
+ <Table
434
+ rowKey="id"
435
+ columns={columnConfig}
436
+ rows={tableData}
437
+ isScrollable={{ x: true, y: true }}
438
+ />
439
+ </div>
440
+ );
441
+ })();
442
+
443
+ export const ScrollablewithStickyHeaderAndNthColumnStuckToLeft = () =>
444
+ (() => {
445
+ const containerStyle = {
446
+ borderRadius: '3px',
447
+ border: '1px solid #EEEEEE',
448
+ width: '300px',
449
+ height: '300px',
450
+ };
451
+ const columnConfig: ColumnType[] = [
452
+ { heading: 'ID', dataKey: 'id' },
453
+ { heading: 'Color', dataKey: 'color', width: 50, sticky: 'left' },
454
+ { heading: 'Flavor', dataKey: 'flavor', width: 100 },
455
+ { heading: 'Brightness', dataKey: 'brightness', width: 400 },
456
+ ];
457
+ const tableData = [
458
+ { id: 1, color: 'red', flavor: 'vanilla', brightness: 'light' },
459
+ { id: 2, color: 'blue', flavor: 'chocolate', brightness: 'medium' },
460
+ { id: 3, color: 'green', flavor: 'strawberry', brightness: 'dark' },
461
+ { id: 4, color: 'green', flavor: 'strawberry', brightness: 'dark' },
462
+ { id: 5, color: 'green', flavor: 'strawberry', brightness: 'dark' },
463
+ { id: 6, color: 'green', flavor: 'strawberry', brightness: 'dark' },
464
+ { id: 7, color: 'green', flavor: 'strawberry', brightness: 'dark' },
465
+ ];
466
+ return (
467
+ <div style={containerStyle}>
468
+ <Table
469
+ rowKey="id"
470
+ columns={columnConfig}
471
+ rows={tableData}
472
+ isScrollable={{ x: true, y: true }}
473
+ hasStickyHeader
474
+ />
475
+ </div>
476
+ );
477
+ })();
478
+
479
+ export const ScrollableWithLastColumnStuckToRight = () =>
480
+ (() => {
481
+ const containerStyle = {
482
+ borderRadius: '3px',
483
+ border: '1px solid #EEEEEE',
484
+ width: '300px',
485
+ height: '300px',
486
+ };
487
+ const columnConfig: ColumnType[] = [
488
+ { heading: 'ID', dataKey: 'id' },
489
+ { heading: 'Color', dataKey: 'color', width: 300 },
490
+ { heading: 'Flavor', dataKey: 'flavor', width: 100 },
491
+ {
492
+ heading: 'Brightness',
493
+ dataKey: 'brightness',
494
+ width: 150,
495
+ sticky: 'right',
496
+ },
497
+ ];
498
+ const tableData = [
499
+ { id: 1, color: 'red', flavor: 'vanilla', brightness: 'light' },
500
+ { id: 2, color: 'blue', flavor: 'chocolate', brightness: 'medium' },
501
+ { id: 3, color: 'green', flavor: 'strawberry', brightness: 'dark' },
502
+ { id: 4, color: 'green', flavor: 'strawberry', brightness: 'dark' },
503
+ { id: 5, color: 'green', flavor: 'strawberry', brightness: 'dark' },
504
+ { id: 6, color: 'green', flavor: 'strawberry', brightness: 'dark' },
505
+ { id: 7, color: 'green', flavor: 'strawberry', brightness: 'dark' },
506
+ ];
507
+ return (
508
+ <div style={containerStyle}>
509
+ <Table
510
+ rowKey="id"
511
+ columns={columnConfig}
512
+ rows={tableData}
513
+ isScrollable={{ x: true, y: true }}
514
+ />
515
+ </div>
516
+ );
517
+ })();
518
+
519
+ export const ScrollableWithStickyHeaderAndFirstColumnStuckToLeft = () =>
520
+ (() => {
521
+ const containerStyle = {
522
+ borderRadius: '3px',
523
+ border: '1px solid #EEEEEE',
524
+ width: '300px',
525
+ height: '300px',
526
+ };
527
+ const columnConfig: ColumnType[] = [
528
+ { heading: 'ID', dataKey: 'id', sticky: 'left' },
529
+ { heading: 'Color', dataKey: 'color', width: 300 },
530
+ { heading: 'Flavor', dataKey: 'flavor', width: 100 },
531
+ { heading: 'Brightness', dataKey: 'brightness', width: 150 },
532
+ ];
533
+ const tableData = [
534
+ { id: 1, color: 'red', flavor: 'vanilla', brightness: 'light' },
535
+ { id: 2, color: 'blue', flavor: 'chocolate', brightness: 'medium' },
536
+ { id: 3, color: 'green', flavor: 'strawberry', brightness: 'dark' },
537
+ { id: 4, color: 'green', flavor: 'strawberry', brightness: 'dark' },
538
+ { id: 5, color: 'green', flavor: 'strawberry', brightness: 'dark' },
539
+ { id: 6, color: 'green', flavor: 'strawberry', brightness: 'dark' },
540
+ { id: 7, color: 'green', flavor: 'strawberry', brightness: 'dark' },
541
+ ];
542
+ return (
543
+ <div style={containerStyle}>
544
+ <Table
545
+ rowKey="id"
546
+ columns={columnConfig}
547
+ rows={tableData}
548
+ isScrollable={{ x: true, y: true }}
549
+ hasStickyHeader
550
+ hoverableRows
551
+ isStriped
552
+ />
553
+ </div>
554
+ );
555
+ })();
556
+
557
+ export const ScrollableAndLoading = () =>
558
+ (() => {
559
+ const containerStyle = {
560
+ padding: '3px 5px',
561
+ borderRadius: '3px',
562
+ border: '1px solid #EEEEEE',
563
+ width: '300px',
564
+ height: '300px',
565
+ };
566
+ const columnConfig: ColumnType[] = [
567
+ { heading: 'ID', dataKey: 'id' },
568
+ { heading: 'Color', dataKey: 'color', width: 300 },
569
+ { heading: 'Flavor', dataKey: 'flavor' },
570
+ { heading: 'Brightness', dataKey: 'brightness' },
571
+ ];
572
+ const tableData = [
573
+ { id: 1, color: 'red', flavor: 'vanilla', brightness: 'light' },
574
+ { id: 2, color: 'blue', flavor: 'chocolate', brightness: 'medium' },
575
+ { id: 3, color: 'green', flavor: 'strawberry', brightness: 'dark' },
576
+ { id: 4, color: 'green', flavor: 'strawberry', brightness: 'dark' },
577
+ { id: 5, color: 'green', flavor: 'strawberry', brightness: 'dark' },
578
+ { id: 6, color: 'green', flavor: 'strawberry', brightness: 'dark' },
579
+ { id: 7, color: 'green', flavor: 'strawberry', brightness: 'dark' },
580
+ ];
581
+ return (
582
+ <div style={containerStyle}>
583
+ <Table
584
+ rowKey="id"
585
+ columns={columnConfig}
586
+ rows={tableData}
587
+ isScrollable={{ x: true, y: true }}
588
+ isLoading
589
+ />
590
+ </div>
591
+ );
592
+ })();
593
+
594
+ export const FixedWidthColumns = () =>
595
+ (() => {
596
+ const columnConfig: ColumnType[] = [
597
+ { heading: 'ID', dataKey: 'id', width: 150 },
598
+ { heading: 'Color', dataKey: 'color' },
599
+ { heading: 'Flavor', dataKey: 'flavor' },
600
+ ];
601
+ const tableData = [
602
+ { id: 1, color: 'red', flavor: 'vanilla' },
603
+ { id: 2, color: 'blue', flavor: 'chocolate' },
604
+ { id: 3, color: 'green', flavor: 'strawberry' },
605
+ ];
606
+ return <Table rowKey="id" columns={columnConfig} rows={tableData} />;
607
+ })();
608
+
609
+ export const FixedTableLayout = () =>
610
+ (() => {
611
+ const columnConfig: ColumnType[] = [
612
+ { heading: 'ID', dataKey: 'id', width: 150 },
613
+ { heading: 'Color', dataKey: 'color' },
614
+ { heading: 'Flavor', dataKey: 'flavor' },
615
+ ];
616
+ const tableData = [
617
+ { id: 1, color: 'red', flavor: 'vanilla' },
618
+ { id: 2, color: 'blue', flavor: 'chocolate' },
619
+ { id: 3, color: 'green', flavor: 'strawberry' },
620
+ ];
621
+ return (
622
+ <Table
623
+ rowKey="id"
624
+ columns={columnConfig}
625
+ rows={tableData}
626
+ useFixedTableLayout
627
+ />
628
+ );
629
+ })();
630
+
631
+ export const TruncateOverflow = () =>
632
+ (() => {
633
+ const columnConfig: ColumnType[] = [
634
+ { heading: 'ID', dataKey: 'id' },
635
+ { heading: 'Color', dataKey: 'color', width: 100 },
636
+ { heading: 'Flavor', dataKey: 'flavor' },
637
+ ];
638
+ const tableData = [
639
+ { id: 1, color: 'red', flavor: 'vanilla' },
640
+ { id: 2, color: 'blue longy long long long', flavor: 'chocolate' },
641
+ { id: 3, color: 'green', flavor: 'strawberry' },
642
+ ];
643
+ return (
644
+ <Table
645
+ rowKey="id"
646
+ columns={columnConfig}
647
+ rows={tableData}
648
+ truncateOverflow
649
+ />
650
+ );
651
+ })();
652
+
653
+ export const CustomActions = () =>
654
+ (() => {
655
+ const renderFlavor = (cell: any, row: any, index: number) => {
656
+ const rows = [{ href: cell.href, name: cell.name, id: row.id, index }];
657
+ const columns = [
658
+ {
659
+ heading: 'Url',
660
+ dataKey: 'href',
661
+ render: (cell: any) => <a href={cell}>{cell}</a>,
662
+ },
663
+ { heading: 'Name', dataKey: 'name' },
664
+ { heading: 'ID', dataKey: 'id' },
665
+ { heading: 'Index', dataKey: 'index' },
666
+ ];
667
+ return <Table columns={columns} rows={rows} rowKey="id" isCompact />;
668
+ };
669
+ const columnConfig: ColumnType[] = [
670
+ { heading: 'ID', dataKey: 'id' },
671
+ { heading: 'Color', dataKey: 'color' },
672
+ {
673
+ heading: 'Based on the cell/row',
674
+ dataKey: 'flavor',
675
+ // @ts-ignore
676
+ render: renderFlavor,
677
+ },
678
+ { heading: 'Any custom JSX', render: () => <Button>Do anything</Button> },
679
+ ];
680
+ const tableData = [
681
+ {
682
+ id: 1,
683
+ color: 'red',
684
+ flavor: { name: 'vanilla', href: 'www.vanilla.com' },
685
+ },
686
+ {
687
+ id: 2,
688
+ color: 'blue',
689
+ flavor: { name: 'chocolate', href: 'www.chocolate.com' },
690
+ },
691
+ {
692
+ id: 3,
693
+ color: 'green',
694
+ flavor: { name: 'strawberry', href: 'www.strawberry.com' },
695
+ },
696
+ ];
697
+ return <Table rowKey="id" columns={columnConfig} rows={tableData} />;
698
+ })();
699
+
700
+ export const EmptyCellPlaceholder = () =>
701
+ (() => {
702
+ const columnConfig = [
703
+ { heading: 'ID', dataKey: 'id' },
704
+ { heading: 'Color', dataKey: 'color', emptyCellPlaceholder: '--' },
705
+ { heading: 'Flavor', dataKey: 'flavor' },
706
+ {
707
+ heading: 'Price',
708
+ dataKey: 'price',
709
+ render: (cell: any) => (cell ? `$${cell}` : null),
710
+ emptyCellPlaceholder: '$0.00',
711
+ },
712
+ ];
713
+ const tableData = [
714
+ { id: 1, color: 'red', flavor: 'vanilla', price: 10 },
715
+ { id: 2, color: '', flavor: 'chocolate', price: 12.21 },
716
+ { id: 3, color: 'green', flavor: 'strawberry', price: 9.24 },
717
+ { id: 4, color: 'blue', flavor: 'rocky road' },
718
+ ];
719
+ return <Table rowKey="id" columns={columnConfig} rows={tableData} />;
720
+ })();
721
+
722
+ export const Borderless = () =>
723
+ (() => {
724
+ const columnConfig: ColumnType[] = [
725
+ { heading: 'ID', dataKey: 'id' },
726
+ { heading: 'Color', dataKey: 'color' },
727
+ { heading: 'Flavor', dataKey: 'flavor' },
728
+ ];
729
+ const tableData = [
730
+ { id: 1, color: 'red', flavor: 'vanilla' },
731
+ { id: 2, color: 'blue', flavor: 'chocolate' },
732
+ { id: 3, color: 'green', flavor: 'strawberry' },
733
+ ];
734
+ return (
735
+ <Table rowKey="id" columns={columnConfig} rows={tableData} isBorderless />
736
+ );
737
+ })();
738
+
739
+ export const Compact = () =>
740
+ (() => {
741
+ const columnConfig: ColumnType[] = [
742
+ { heading: 'ID', dataKey: 'id' },
743
+ { heading: 'Color', dataKey: 'color' },
744
+ { heading: 'Flavor', dataKey: 'flavor' },
745
+ ];
746
+ const tableData = [
747
+ { id: 1, color: 'red', flavor: 'vanilla' },
748
+ { id: 2, color: 'blue', flavor: 'chocolate' },
749
+ { id: 3, color: 'green', flavor: 'strawberry' },
750
+ ];
751
+ return (
752
+ <Table rowKey="id" columns={columnConfig} rows={tableData} isCompact />
753
+ );
754
+ })();
755
+
756
+ export const Striped = () =>
757
+ (() => {
758
+ const columnConfig: ColumnType[] = [
759
+ { heading: 'ID', dataKey: 'id' },
760
+ { heading: 'Color', dataKey: 'color' },
761
+ { heading: 'Flavor', dataKey: 'flavor' },
762
+ ];
763
+ const tableData = [
764
+ { id: 1, color: 'red', flavor: 'vanilla' },
765
+ { id: 2, color: 'blue', flavor: 'chocolate' },
766
+ { id: 3, color: 'green', flavor: 'strawberry' },
767
+ { id: 4, color: 'green', flavor: 'strawberry' },
768
+ { id: 5, color: 'green', flavor: 'strawberry' },
769
+ { id: 6, color: 'green', flavor: 'strawberry' },
770
+ { id: 7, color: 'green', flavor: 'strawberry' },
771
+ ];
772
+ return (
773
+ <Table rowKey="id" columns={columnConfig} rows={tableData} isStriped />
774
+ );
775
+ })();
776
+
777
+ export const Hoverable = () =>
778
+ (() => {
779
+ const columnConfig: ColumnType[] = [
780
+ { heading: 'ID', dataKey: 'id' },
781
+ { heading: 'Color', dataKey: 'color' },
782
+ { heading: 'Flavor', dataKey: 'flavor' },
783
+ ];
784
+ const tableData = [
785
+ { id: 1, color: 'red', flavor: 'vanilla' },
786
+ { id: 2, color: 'blue', flavor: 'chocolate' },
787
+ { id: 3, color: 'green', flavor: 'strawberry' },
788
+ ];
789
+ return (
790
+ <Table
791
+ rowKey="id"
792
+ columns={columnConfig}
793
+ rows={tableData}
794
+ hoverableRows
795
+ />
796
+ );
797
+ })();
798
+
799
+ export const StripedAndHoverable = () =>
800
+ (() => {
801
+ const columnConfig: ColumnType[] = [
802
+ { heading: 'ID', dataKey: 'id' },
803
+ { heading: 'Color', dataKey: 'color' },
804
+ { heading: 'Flavor', dataKey: 'flavor' },
805
+ ];
806
+ const tableData = [
807
+ { id: 1, color: 'red', flavor: 'vanilla' },
808
+ { id: 2, color: 'blue', flavor: 'chocolate' },
809
+ { id: 3, color: 'green', flavor: 'strawberry' },
810
+ ];
811
+ return (
812
+ <Table
813
+ rowKey="id"
814
+ columns={columnConfig}
815
+ rows={tableData}
816
+ hoverableRows
817
+ isStriped
818
+ />
819
+ );
820
+ })();
821
+
822
+ export const AligningCellText = () =>
823
+ (() => {
824
+ const columnConfig: ColumnType[] = [
825
+ { heading: 'Right aligned', dataKey: 'id', align: 'right' },
826
+ { heading: 'Center aligned', dataKey: 'color', align: 'center' },
827
+ { heading: 'Left aligned (default)', dataKey: 'flavor' },
828
+ ];
829
+ const tableData = [
830
+ { id: 1, color: 'red', flavor: 'vanilla' },
831
+ { id: 2, color: 'blue', flavor: 'chocolate' },
832
+ { id: 3, color: 'green', flavor: 'strawberry' },
833
+ ];
834
+ return <Table rowKey="id" columns={columnConfig} rows={tableData} />;
835
+ })();
836
+
837
+ export const GlobalAlign = () =>
838
+ (() => {
839
+ const columnConfig: ColumnType[] = [
840
+ {
841
+ heading: 'Center Aligned via Column Config',
842
+ dataKey: 'id',
843
+ align: 'center',
844
+ },
845
+ { heading: 'Globally aligned right', dataKey: 'color' },
846
+ { heading: 'Also globally aligned right', dataKey: 'flavor' },
847
+ ];
848
+ const tableData = [
849
+ { id: 1, color: 'red', flavor: 'vanilla' },
850
+ { id: 2, color: 'blue', flavor: 'chocolate' },
851
+ { id: 3, color: 'green', flavor: 'strawberry' },
852
+ ];
853
+ return (
854
+ <Table
855
+ rowKey="id"
856
+ columns={columnConfig}
857
+ rows={tableData}
858
+ align="right"
859
+ />
860
+ );
861
+ })();
862
+
863
+ export const ComponentAsColumnHeader = () =>
864
+ (() => {
865
+ const columnConfig: ColumnType[] = [
866
+ { heading: 'ID', dataKey: 'id' },
867
+ { heading: 'Color', dataKey: 'color' },
868
+ { heading: <Badge message="Status" />, dataKey: 'status' },
869
+ ];
870
+ const tableData = [
871
+ {
872
+ id: 1,
873
+ color: 'red',
874
+ status: <Badge message="danger" variant="red" />,
875
+ },
876
+ { id: 2, color: 'blue', status: <Badge message="info" variant="blue" /> },
877
+ {
878
+ id: 3,
879
+ color: 'green',
880
+ status: <Badge message="success" variant="green" />,
881
+ },
882
+ ];
883
+ return <Table rowKey="id" columns={columnConfig} rows={tableData} />;
884
+ })();