@universal-tennis/ui-shared 0.1.68 → 0.1.69

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 (285) hide show
  1. package/.eslintignore +1 -1
  2. package/.eslintrc.js +73 -73
  3. package/.storybook/preview.js +12 -12
  4. package/.storybook/variables.css +15 -15
  5. package/README.md +129 -129
  6. package/dist/App.d.ts +2 -2
  7. package/dist/App.js +12 -12
  8. package/dist/components.d.ts +32 -4
  9. package/dist/components.js +37 -8
  10. package/dist/components.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +12 -12
  13. package/dist/items.d.ts +2 -2
  14. package/dist/items.js +1 -1
  15. package/dist/stories/assets/css/variables.css +6 -3
  16. package/dist/stories/assets/icon-chat-blue.svg +10 -10
  17. package/dist/stories/atoms/Button/Button.d.ts +10 -9
  18. package/dist/stories/atoms/Button/Button.js +95 -79
  19. package/dist/stories/atoms/Button/Button.js.map +1 -1
  20. package/dist/stories/atoms/Button/Button.stories.d.ts +17 -16
  21. package/dist/stories/atoms/Button/Button.stories.js +45 -36
  22. package/dist/stories/atoms/Button/Button.stories.js.map +1 -1
  23. package/dist/stories/atoms/Icons/AddIcon.d.ts +3 -0
  24. package/dist/stories/atoms/Icons/AddIcon.js +9 -0
  25. package/dist/stories/atoms/Icons/AddIcon.js.map +1 -0
  26. package/dist/stories/atoms/Icons/AvailabilityMaybeIcon.d.ts +3 -0
  27. package/dist/stories/atoms/Icons/AvailabilityMaybeIcon.js +7 -0
  28. package/dist/stories/atoms/Icons/AvailabilityMaybeIcon.js.map +1 -0
  29. package/dist/stories/atoms/Icons/AvailabilityNoIcon.d.ts +3 -0
  30. package/dist/stories/atoms/Icons/AvailabilityNoIcon.js +7 -0
  31. package/dist/stories/atoms/Icons/AvailabilityNoIcon.js.map +1 -0
  32. package/dist/stories/atoms/Icons/AvailabilityNotSetIcon.d.ts +3 -0
  33. package/dist/stories/atoms/Icons/AvailabilityNotSetIcon.js +8 -0
  34. package/dist/stories/atoms/Icons/AvailabilityNotSetIcon.js.map +1 -0
  35. package/dist/stories/atoms/Icons/AvailabilityYesIcon.d.ts +3 -0
  36. package/dist/stories/atoms/Icons/AvailabilityYesIcon.js +7 -0
  37. package/dist/stories/atoms/Icons/AvailabilityYesIcon.js.map +1 -0
  38. package/dist/stories/atoms/Icons/CalendarIcon.d.ts +3 -0
  39. package/dist/stories/atoms/Icons/CalendarIcon.js +7 -0
  40. package/dist/stories/atoms/Icons/CalendarIcon.js.map +1 -0
  41. package/dist/stories/atoms/Icons/ClockIcon.d.ts +3 -0
  42. package/dist/stories/atoms/Icons/ClockIcon.js +9 -0
  43. package/dist/stories/atoms/Icons/ClockIcon.js.map +1 -0
  44. package/dist/stories/atoms/Icons/CloseIcon.d.ts +3 -0
  45. package/dist/stories/atoms/Icons/CloseIcon.js +7 -0
  46. package/dist/stories/atoms/Icons/CloseIcon.js.map +1 -0
  47. package/dist/stories/atoms/Icons/DeleteIcon.d.ts +3 -0
  48. package/dist/stories/atoms/Icons/DeleteIcon.js +11 -0
  49. package/dist/stories/atoms/Icons/DeleteIcon.js.map +1 -0
  50. package/dist/stories/atoms/Icons/EditIcon.d.ts +3 -0
  51. package/dist/stories/atoms/Icons/EditIcon.js +7 -0
  52. package/dist/stories/atoms/Icons/EditIcon.js.map +1 -0
  53. package/dist/stories/atoms/Icons/Icons.stories.d.ts +23 -0
  54. package/dist/stories/atoms/Icons/Icons.stories.js +178 -0
  55. package/dist/stories/atoms/Icons/Icons.stories.js.map +1 -0
  56. package/dist/stories/atoms/Icons/LeftChevronIcon.d.ts +3 -0
  57. package/dist/stories/atoms/Icons/LeftChevronIcon.js +7 -0
  58. package/dist/stories/atoms/Icons/LeftChevronIcon.js.map +1 -0
  59. package/dist/stories/atoms/Icons/LocationIcon.d.ts +3 -0
  60. package/dist/stories/atoms/Icons/LocationIcon.js +8 -0
  61. package/dist/stories/atoms/Icons/LocationIcon.js.map +1 -0
  62. package/dist/stories/atoms/Icons/MessageIcon.d.ts +3 -0
  63. package/dist/stories/atoms/Icons/MessageIcon.js +7 -0
  64. package/dist/stories/atoms/Icons/MessageIcon.js.map +1 -0
  65. package/dist/stories/atoms/Icons/RightChevronIcon.d.ts +3 -0
  66. package/dist/stories/atoms/Icons/RightChevronIcon.js +7 -0
  67. package/dist/stories/atoms/Icons/RightChevronIcon.js.map +1 -0
  68. package/dist/stories/atoms/Icons/SessionIcon.d.ts +3 -0
  69. package/dist/stories/atoms/Icons/SessionIcon.js +7 -0
  70. package/dist/stories/atoms/Icons/SessionIcon.js.map +1 -0
  71. package/dist/stories/atoms/Icons/SwapIcon.d.ts +3 -0
  72. package/dist/stories/atoms/Icons/SwapIcon.js +7 -0
  73. package/dist/stories/atoms/Icons/SwapIcon.js.map +1 -0
  74. package/dist/stories/atoms/Icons/VisibilityIcon.d.ts +3 -0
  75. package/dist/stories/atoms/Icons/VisibilityIcon.js +8 -0
  76. package/dist/stories/atoms/Icons/VisibilityIcon.js.map +1 -0
  77. package/dist/stories/atoms/Icons/VisibilityOffIcon.d.ts +3 -0
  78. package/dist/stories/atoms/Icons/VisibilityOffIcon.js +9 -0
  79. package/dist/stories/atoms/Icons/VisibilityOffIcon.js.map +1 -0
  80. package/dist/stories/atoms/Icons/WinnerIndicatorIcon.d.ts +3 -0
  81. package/dist/stories/atoms/Icons/WinnerIndicatorIcon.js +32 -0
  82. package/dist/stories/atoms/Icons/WinnerIndicatorIcon.js.map +1 -0
  83. package/dist/stories/atoms/Icons/sharedTypes.d.ts +9 -0
  84. package/dist/stories/atoms/Icons/sharedTypes.js +2 -0
  85. package/dist/stories/atoms/Icons/sharedTypes.js.map +1 -0
  86. package/dist/stories/atoms/Map/Map.d.ts +7 -0
  87. package/dist/stories/atoms/Map/Map.js +9 -0
  88. package/dist/stories/atoms/Map/Map.js.map +1 -0
  89. package/dist/stories/atoms/Map/Map.stories.d.ts +9 -0
  90. package/dist/stories/atoms/Map/Map.stories.js +36 -0
  91. package/dist/stories/atoms/Map/Map.stories.js.map +1 -0
  92. package/dist/stories/atoms/Typography/Typography.d.ts +49 -10
  93. package/dist/stories/atoms/Typography/Typography.js +143 -99
  94. package/dist/stories/atoms/Typography/Typography.js.map +1 -1
  95. package/dist/stories/atoms/Typography/Typography.stories.d.ts +37 -37
  96. package/dist/stories/atoms/Typography/Typography.stories.js +190 -190
  97. package/dist/stories/molecules/AvatarWithName/AvatarWithName.d.ts +27 -0
  98. package/dist/stories/molecules/AvatarWithName/AvatarWithName.js +21 -0
  99. package/dist/stories/molecules/AvatarWithName/AvatarWithName.js.map +1 -0
  100. package/dist/stories/molecules/AvatarWithName/AvatarWithName.stories.d.ts +15 -0
  101. package/dist/stories/molecules/AvatarWithName/AvatarWithName.stories.js +73 -0
  102. package/dist/stories/molecules/AvatarWithName/AvatarWithName.stories.js.map +1 -0
  103. package/dist/stories/molecules/Cards/Cards.stories.d.ts +7 -6
  104. package/dist/stories/molecules/Cards/Cards.stories.js +64 -26
  105. package/dist/stories/molecules/Cards/Cards.stories.js.map +1 -1
  106. package/dist/stories/molecules/Cards/ContactCard.d.ts +3 -9
  107. package/dist/stories/molecules/Cards/ContactCard.js +38 -38
  108. package/dist/stories/molecules/Cards/ContactCard.js.map +1 -1
  109. package/dist/stories/molecules/Cards/DrawCard.d.ts +3 -0
  110. package/dist/stories/molecules/Cards/DrawCard.js +117 -0
  111. package/dist/stories/molecules/Cards/DrawCard.js.map +1 -0
  112. package/dist/stories/molecules/Cards/Modals.stories.d.ts +5 -0
  113. package/dist/stories/molecules/Cards/Modals.stories.js +73 -0
  114. package/dist/stories/molecules/Cards/Modals.stories.js.map +1 -0
  115. package/dist/stories/molecules/Cards/TeamCard.d.ts +3 -7
  116. package/dist/stories/molecules/Cards/TeamCard.js +20 -20
  117. package/dist/stories/molecules/Cards/TeamCard.js.map +1 -1
  118. package/dist/stories/molecules/Cards/TeamDrawCard.d.ts +3 -0
  119. package/dist/stories/molecules/Cards/TeamDrawCard.js +75 -0
  120. package/dist/stories/molecules/Cards/TeamDrawCard.js.map +1 -0
  121. package/dist/stories/molecules/Cards/shared.d.ts +4 -9
  122. package/dist/stories/molecules/Cards/shared.js +12 -12
  123. package/dist/stories/molecules/Cards/sharedTypes.d.ts +59 -0
  124. package/dist/stories/molecules/Cards/sharedTypes.js +3 -0
  125. package/dist/stories/molecules/Cards/sharedTypes.js.map +1 -0
  126. package/dist/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.d.ts +27 -0
  127. package/dist/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.js +25 -0
  128. package/dist/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.js.map +1 -0
  129. package/dist/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.stories.d.ts +13 -0
  130. package/dist/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.stories.js +66 -0
  131. package/dist/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.stories.js.map +1 -0
  132. package/dist/stories/organisms/Modals/FullPageModal.d.ts +4 -0
  133. package/dist/stories/organisms/Modals/FullPageModal.js +60 -0
  134. package/dist/stories/organisms/Modals/FullPageModal.js.map +1 -0
  135. package/dist/stories/organisms/Modals/Modals.stories.d.ts +5 -0
  136. package/dist/stories/organisms/Modals/Modals.stories.js +74 -0
  137. package/dist/stories/organisms/Modals/Modals.stories.js.map +1 -0
  138. package/dist/stories/organisms/Modals/sharedTypes.d.ts +14 -0
  139. package/dist/stories/organisms/Modals/sharedTypes.js +2 -0
  140. package/dist/stories/organisms/Modals/sharedTypes.js.map +1 -0
  141. package/dist/stories/organisms/Tables/DrawCardTable.d.ts +3 -0
  142. package/dist/stories/organisms/Tables/DrawCardTable.js +59 -0
  143. package/dist/stories/organisms/Tables/DrawCardTable.js.map +1 -0
  144. package/dist/stories/organisms/Tables/SortableTable.d.ts +23 -0
  145. package/dist/stories/organisms/Tables/SortableTable.js +34 -0
  146. package/dist/stories/organisms/Tables/SortableTable.js.map +1 -0
  147. package/dist/stories/organisms/Tables/Tables.stories.d.ts +8 -0
  148. package/dist/stories/organisms/Tables/Tables.stories.js +91 -0
  149. package/dist/stories/organisms/Tables/Tables.stories.js.map +1 -0
  150. package/dist/stories/organisms/Tables/TeamDrawCardTable/DesktopTableRows.d.ts +3 -0
  151. package/dist/stories/organisms/Tables/TeamDrawCardTable/DesktopTableRows.js +52 -0
  152. package/dist/stories/organisms/Tables/TeamDrawCardTable/DesktopTableRows.js.map +1 -0
  153. package/dist/stories/organisms/Tables/TeamDrawCardTable/MobileTableRows.d.ts +3 -0
  154. package/dist/stories/organisms/Tables/TeamDrawCardTable/MobileTableRows.js +43 -0
  155. package/dist/stories/organisms/Tables/TeamDrawCardTable/MobileTableRows.js.map +1 -0
  156. package/dist/stories/organisms/Tables/TeamDrawCardTable/TeamDrawCardTable.d.ts +3 -0
  157. package/dist/stories/organisms/Tables/TeamDrawCardTable/TeamDrawCardTable.js +23 -0
  158. package/dist/stories/organisms/Tables/TeamDrawCardTable/TeamDrawCardTable.js.map +1 -0
  159. package/dist/stories/organisms/Tables/TeamDrawCardTable.d.ts +3 -0
  160. package/dist/stories/organisms/Tables/TeamDrawCardTable.js +126 -0
  161. package/dist/stories/organisms/Tables/TeamDrawCardTable.js.map +1 -0
  162. package/dist/stories/organisms/Tables/mockData.d.ts +69 -0
  163. package/dist/stories/organisms/Tables/mockData.js +98 -0
  164. package/dist/stories/organisms/Tables/mockData.js.map +1 -0
  165. package/dist/stories/organisms/Tables/sharedTypes.d.ts +15 -0
  166. package/dist/stories/organisms/Tables/sharedTypes.js +2 -0
  167. package/dist/stories/organisms/Tables/sharedTypes.js.map +1 -0
  168. package/dist/stories/utils/constants.d.ts +3 -0
  169. package/dist/stories/utils/constants.js +4 -0
  170. package/dist/stories/utils/constants.js.map +1 -0
  171. package/dist/stories/utils/useScreenSize.d.ts +4 -0
  172. package/dist/stories/utils/useScreenSize.js +28 -0
  173. package/dist/stories/utils/useScreenSize.js.map +1 -0
  174. package/dist/types/tableDataTypes.d.ts +38 -0
  175. package/dist/types/tableDataTypes.js +2 -0
  176. package/dist/types/tableDataTypes.js.map +1 -0
  177. package/infrastructure/azure-pipelines.yml +112 -112
  178. package/package.json +93 -94
  179. package/src/App.js +25 -25
  180. package/src/components.jsx +41 -41
  181. package/src/custom.d.ts +13 -13
  182. package/src/index.js +17 -17
  183. package/src/items.jsx +1 -1
  184. package/src/stories/assets/css/variables.css +14 -14
  185. package/src/stories/assets/icon-chat-blue.svg +10 -10
  186. package/src/stories/assets/icons/icon-add.svg +7 -7
  187. package/src/stories/assets/icons/icon-availability-maybe.svg +3 -3
  188. package/src/stories/assets/icons/icon-availability-no.svg +3 -3
  189. package/src/stories/assets/icons/icon-availability-not-set.svg +8 -8
  190. package/src/stories/assets/icons/icon-availability-yes.svg +3 -3
  191. package/src/stories/assets/icons/icon-calendar.svg +4 -4
  192. package/src/stories/assets/icons/icon-clock.svg +7 -7
  193. package/src/stories/assets/icons/icon-close.svg +3 -3
  194. package/src/stories/assets/icons/icon-delete.svg +9 -9
  195. package/src/stories/assets/icons/icon-edit.svg +3 -3
  196. package/src/stories/assets/icons/icon-location.svg +6 -6
  197. package/src/stories/assets/icons/icon-message.svg +3 -3
  198. package/src/stories/assets/icons/icon-session.svg +3 -3
  199. package/src/stories/assets/icons/icon-swap.svg +3 -3
  200. package/src/stories/assets/icons/icon-visibility-off.svg +7 -7
  201. package/src/stories/assets/icons/icon-visibility.svg +6 -6
  202. package/src/stories/atoms/Button/Button.stories.tsx +63 -63
  203. package/src/stories/atoms/Button/Button.tsx +145 -145
  204. package/src/stories/atoms/Icons/AddIcon.tsx +13 -13
  205. package/src/stories/atoms/Icons/AvailabilityMaybeIcon.tsx +11 -11
  206. package/src/stories/atoms/Icons/AvailabilityNoIcon.tsx +11 -11
  207. package/src/stories/atoms/Icons/AvailabilityNotSetIcon.tsx +12 -12
  208. package/src/stories/atoms/Icons/AvailabilityYesIcon.tsx +11 -11
  209. package/src/stories/atoms/Icons/CalendarIcon.tsx +11 -11
  210. package/src/stories/atoms/Icons/ClockIcon.tsx +14 -14
  211. package/src/stories/atoms/Icons/CloseIcon.tsx +11 -11
  212. package/src/stories/atoms/Icons/DeleteIcon.tsx +15 -15
  213. package/src/stories/atoms/Icons/EditIcon.tsx +11 -11
  214. package/src/stories/atoms/Icons/Icons.stories.tsx +218 -218
  215. package/src/stories/atoms/Icons/LeftChevronIcon.tsx +13 -13
  216. package/src/stories/atoms/Icons/LocationIcon.tsx +12 -12
  217. package/src/stories/atoms/Icons/MessageIcon.tsx +12 -12
  218. package/src/stories/atoms/Icons/RightChevronIcon.tsx +11 -11
  219. package/src/stories/atoms/Icons/SessionIcon.tsx +16 -16
  220. package/src/stories/atoms/Icons/SwapIcon.tsx +11 -11
  221. package/src/stories/atoms/Icons/VisibilityIcon.tsx +12 -12
  222. package/src/stories/atoms/Icons/VisibilityOffIcon.tsx +13 -13
  223. package/src/stories/atoms/Icons/WinnerIndicatorIcon.tsx +39 -39
  224. package/src/stories/atoms/Icons/sharedTypes.tsx +10 -10
  225. package/src/stories/atoms/Map/Map.stories.tsx +43 -43
  226. package/src/stories/atoms/Map/Map.tsx +25 -25
  227. package/src/stories/atoms/Typography/Typography.tsx +185 -185
  228. package/src/stories/molecules/AvatarWithName/AvatarWithName.stories.tsx +86 -86
  229. package/src/stories/molecules/AvatarWithName/AvatarWithName.tsx +68 -68
  230. package/src/stories/molecules/Cards/Cards.stories.tsx +76 -76
  231. package/src/stories/molecules/Cards/ContactCard.tsx +45 -45
  232. package/src/stories/molecules/Cards/DrawCard.tsx +211 -211
  233. package/src/stories/molecules/Cards/Modals.stories.tsx +137 -137
  234. package/src/stories/molecules/Cards/TeamCard.tsx +14 -14
  235. package/src/stories/molecules/Cards/TeamDrawCard.tsx +135 -135
  236. package/src/stories/molecules/Cards/sharedTypes.ts +67 -67
  237. package/src/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.stories.tsx +77 -77
  238. package/src/stories/molecules/SquareAvatarWithName/SquareAvatarWithName.tsx +84 -84
  239. package/src/stories/organisms/Modals/FullPageModal.tsx +93 -93
  240. package/src/stories/organisms/Modals/Modals.stories.tsx +138 -138
  241. package/src/stories/organisms/Modals/sharedTypes.ts +15 -15
  242. package/src/stories/organisms/Tables/DrawCardTable.tsx +92 -92
  243. package/src/stories/organisms/Tables/SortableTable.tsx +112 -112
  244. package/src/stories/organisms/Tables/Tables.stories.tsx +104 -104
  245. package/src/stories/organisms/Tables/TeamDrawCardTable/DesktopTableRows.tsx +102 -102
  246. package/src/stories/organisms/Tables/TeamDrawCardTable/MobileTableRows.tsx +67 -67
  247. package/src/stories/organisms/Tables/TeamDrawCardTable/TeamDrawCardTable.tsx +24 -24
  248. package/src/stories/organisms/Tables/mockData.tsx +129 -129
  249. package/src/stories/organisms/Tables/sharedTypes.ts +17 -17
  250. package/src/stories/utils/constants.ts +3 -3
  251. package/src/stories/utils/useScreenSize.ts +28 -28
  252. package/src/types/tableDataTypes.ts +42 -42
  253. package/tsconfig.json +23 -23
  254. package/dist/stories/Button.d.ts +0 -27
  255. package/dist/stories/Button.js +0 -51
  256. package/dist/stories/Button.js.map +0 -1
  257. package/dist/stories/Button.stories.d.ts +0 -15
  258. package/dist/stories/Button.stories.js +0 -34
  259. package/dist/stories/Button.stories.js.map +0 -1
  260. package/dist/stories/Header.d.ts +0 -19
  261. package/dist/stories/Header.js +0 -31
  262. package/dist/stories/Header.js.map +0 -1
  263. package/dist/stories/Header.stories.d.ts +0 -11
  264. package/dist/stories/Header.stories.js +0 -20
  265. package/dist/stories/Header.stories.js.map +0 -1
  266. package/dist/stories/Page.d.ts +0 -1
  267. package/dist/stories/Page.js +0 -38
  268. package/dist/stories/Page.js.map +0 -1
  269. package/dist/stories/Page.stories.d.ts +0 -11
  270. package/dist/stories/Page.stories.js +0 -30
  271. package/dist/stories/Page.stories.js.map +0 -1
  272. package/dist/stories/assets/comments.svg +0 -1
  273. package/dist/stories/assets/direction.svg +0 -1
  274. package/dist/stories/atoms/Button/index.d.ts +0 -1
  275. package/dist/stories/atoms/Button/index.js +0 -2
  276. package/dist/stories/atoms/Button/index.js.map +0 -1
  277. package/dist/stories/atoms/Button.d.ts +0 -7
  278. package/dist/stories/atoms/Button.js +0 -20
  279. package/dist/stories/atoms/Button.js.map +0 -1
  280. package/dist/stories/atoms/Button.stories.d.ts +0 -13
  281. package/dist/stories/atoms/Button.stories.js +0 -22
  282. package/dist/stories/atoms/Button.stories.js.map +0 -1
  283. package/dist/stories/atoms/Typography/index.d.ts +0 -1
  284. package/dist/stories/atoms/Typography/index.js +0 -2
  285. package/dist/stories/atoms/Typography/index.js.map +0 -1
@@ -1,112 +1,112 @@
1
- import React, { ComponentType, SyntheticEvent } from "react";
2
-
3
- import Table from "@mui/material/Table";
4
- import TableBody from "@mui/material/TableBody";
5
- import TableCell from "@mui/material/TableCell";
6
- import TableContainer from "@mui/material/TableContainer";
7
- import TableHead from "@mui/material/TableHead";
8
- import MuiTableRow from "@mui/material/TableRow";
9
- import TableSortLabel from "@mui/material/TableSortLabel";
10
- import Toolbar from "@mui/material/Toolbar";
11
- import Paper from "@mui/material/Paper";
12
-
13
- import { TableData } from "types/tableDataTypes";
14
- import Typography from '../../atoms/Typography/Typography';
15
-
16
- type Order = 'asc' | 'desc';
17
- type OrderProperty = string | number;
18
-
19
- interface HeadCell {
20
- id: string;
21
- label?: string;
22
- isSortingDisabled: boolean
23
- }
24
-
25
- export type SortableTableProps = {
26
- headCells: Array<HeadCell>;
27
- tableData: Array<TableData>;
28
- sortOrder: Order;
29
- sortByProperty: OrderProperty;
30
- rowComponent: ComponentType<{rowData: TableData, labelId: string}>;
31
- title?: string;
32
- onOrderPropertyChange?: (property: OrderProperty) => VoidFunction
33
- }
34
-
35
- function SortableTable({
36
- headCells,
37
- tableData,
38
- rowComponent,
39
- sortOrder,
40
- sortByProperty,
41
- title = '',
42
- onOrderPropertyChange,
43
- }: SortableTableProps) {
44
- const TableRow = rowComponent;
45
-
46
- const handleRequestSort = (property: OrderProperty) => (event: SyntheticEvent) => {
47
- event.preventDefault();
48
- if (onOrderPropertyChange) {
49
- onOrderPropertyChange(property);
50
- }
51
- };
52
-
53
- return (
54
- <Paper sx={{ width: "100%", mb: 2 }}>
55
- {title && (
56
- <Toolbar sx={{ pl: { sm: 2 }, pr: { xs: 1, sm: 1 } }}>
57
- <Typography
58
- category="secondary"
59
- size="large-medium"
60
- id="tableTitle"
61
- >
62
- {title}
63
- </Typography>
64
- </Toolbar>
65
- )}
66
- <TableContainer>
67
- <Table
68
- sx={{ minWidth: 750 }}
69
- aria-labelledby="tableTitle"
70
- size="medium"
71
- >
72
- <TableHead>
73
- <MuiTableRow>
74
- {headCells.map((headCell) => (
75
- <TableCell
76
- key={headCell.id}
77
- align="left"
78
- padding="normal"
79
- sortDirection={sortByProperty === headCell.id ? sortOrder : false}
80
- >
81
- <TableSortLabel
82
- disabled={headCell.isSortingDisabled}
83
- hideSortIcon={!headCell?.label}
84
- active={sortByProperty === headCell.id}
85
- direction={sortByProperty === headCell.id ? sortOrder : 'asc'}
86
- onClick={handleRequestSort(headCell.id)}
87
- >
88
- {headCell?.label}
89
- </TableSortLabel>
90
- </TableCell>
91
- ))}
92
- </MuiTableRow>
93
- </TableHead>
94
- <TableBody>
95
- {tableData && tableData.map((data: TableData, index: number) => {
96
- const labelId = `table-${index}`;
97
- return (
98
- <TableRow
99
- key={data.id}
100
- rowData={data}
101
- labelId={labelId}
102
- />
103
- );
104
- })}
105
- </TableBody>
106
- </Table>
107
- </TableContainer>
108
- </Paper>
109
- );
110
- }
111
-
112
- export default SortableTable;
1
+ import React, { ComponentType, SyntheticEvent } from "react";
2
+
3
+ import Table from "@mui/material/Table";
4
+ import TableBody from "@mui/material/TableBody";
5
+ import TableCell from "@mui/material/TableCell";
6
+ import TableContainer from "@mui/material/TableContainer";
7
+ import TableHead from "@mui/material/TableHead";
8
+ import MuiTableRow from "@mui/material/TableRow";
9
+ import TableSortLabel from "@mui/material/TableSortLabel";
10
+ import Toolbar from "@mui/material/Toolbar";
11
+ import Paper from "@mui/material/Paper";
12
+
13
+ import { TableData } from "types/tableDataTypes";
14
+ import Typography from '../../atoms/Typography/Typography';
15
+
16
+ type Order = 'asc' | 'desc';
17
+ type OrderProperty = string | number;
18
+
19
+ interface HeadCell {
20
+ id: string;
21
+ label?: string;
22
+ isSortingDisabled: boolean
23
+ }
24
+
25
+ export type SortableTableProps = {
26
+ headCells: Array<HeadCell>;
27
+ tableData: Array<TableData>;
28
+ sortOrder: Order;
29
+ sortByProperty: OrderProperty;
30
+ rowComponent: ComponentType<{rowData: TableData, labelId: string}>;
31
+ title?: string;
32
+ onOrderPropertyChange?: (property: OrderProperty) => VoidFunction
33
+ }
34
+
35
+ function SortableTable({
36
+ headCells,
37
+ tableData,
38
+ rowComponent,
39
+ sortOrder,
40
+ sortByProperty,
41
+ title = '',
42
+ onOrderPropertyChange,
43
+ }: SortableTableProps) {
44
+ const TableRow = rowComponent;
45
+
46
+ const handleRequestSort = (property: OrderProperty) => (event: SyntheticEvent) => {
47
+ event.preventDefault();
48
+ if (onOrderPropertyChange) {
49
+ onOrderPropertyChange(property);
50
+ }
51
+ };
52
+
53
+ return (
54
+ <Paper sx={{ width: "100%", mb: 2 }}>
55
+ {title && (
56
+ <Toolbar sx={{ pl: { sm: 2 }, pr: { xs: 1, sm: 1 } }}>
57
+ <Typography
58
+ category="secondary"
59
+ size="large-medium"
60
+ id="tableTitle"
61
+ >
62
+ {title}
63
+ </Typography>
64
+ </Toolbar>
65
+ )}
66
+ <TableContainer>
67
+ <Table
68
+ sx={{ minWidth: 750 }}
69
+ aria-labelledby="tableTitle"
70
+ size="medium"
71
+ >
72
+ <TableHead>
73
+ <MuiTableRow>
74
+ {headCells.map((headCell) => (
75
+ <TableCell
76
+ key={headCell.id}
77
+ align="left"
78
+ padding="normal"
79
+ sortDirection={sortByProperty === headCell.id ? sortOrder : false}
80
+ >
81
+ <TableSortLabel
82
+ disabled={headCell.isSortingDisabled}
83
+ hideSortIcon={!headCell?.label}
84
+ active={sortByProperty === headCell.id}
85
+ direction={sortByProperty === headCell.id ? sortOrder : 'asc'}
86
+ onClick={handleRequestSort(headCell.id)}
87
+ >
88
+ {headCell?.label}
89
+ </TableSortLabel>
90
+ </TableCell>
91
+ ))}
92
+ </MuiTableRow>
93
+ </TableHead>
94
+ <TableBody>
95
+ {tableData && tableData.map((data: TableData, index: number) => {
96
+ const labelId = `table-${index}`;
97
+ return (
98
+ <TableRow
99
+ key={data.id}
100
+ rowData={data}
101
+ labelId={labelId}
102
+ />
103
+ );
104
+ })}
105
+ </TableBody>
106
+ </Table>
107
+ </TableContainer>
108
+ </Paper>
109
+ );
110
+ }
111
+
112
+ export default SortableTable;
@@ -1,104 +1,104 @@
1
- import React from 'react';
2
- import TeamDrawCard from 'stories/molecules/Cards/TeamDrawCard';
3
- import DrawCard from '../../molecules/Cards/DrawCard';
4
- import DrawCardTable from './DrawCardTable';
5
- import TeamDrawCardTable from './TeamDrawCardTable/TeamDrawCardTable';
6
- import { DrawCardTableProps } from './sharedTypes';
7
- import {
8
- MOCK_HEAD_CELLS, mockRowComponent, MOCK_TABLE_DATA, SAMPLE_CARD_DATA, SAMPLE_TEAM_PAGE_CARD_DATA
9
- } from './mockData';
10
-
11
- const onOrderPropertyChange = () => {};
12
-
13
- // Default
14
- export default {
15
- title: 'Organisms/Tables',
16
- };
17
-
18
- // Templates
19
- function DrawCardTableTemplate(args: DrawCardTableProps) {
20
- return <DrawCardTable {...args} />;
21
- }
22
-
23
- function TeamDrawCardTableTemplate(args: DrawCardTableProps) {
24
- return <TeamDrawCardTable {...args} />;
25
- }
26
-
27
- const headerRows = [
28
- { name: 'Round 1' },
29
- { name: 'Quarterfinal' },
30
- { name: 'SemiFinal' },
31
- ];
32
-
33
- const tableRows = [
34
- [
35
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
36
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} locationLabel="hi" />,
37
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
38
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} locationLabel="hi" />,
39
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
40
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
41
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} locationLabel="hi" />,
42
- <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
43
- ],
44
- [
45
- <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} onViewClick={() => {}} />,
46
- <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
47
- <DrawCard isScorelessMatch emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
48
- <DrawCard isScorelessMatch emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
49
- ],
50
- [
51
- <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
52
- <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
53
- ],
54
- [
55
- <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
56
- ],
57
- ];
58
-
59
- const teamTableRows = [
60
- [
61
- <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
62
- <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
63
- <TeamDrawCard isScorelessMatch {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
64
- <TeamDrawCard isScorelessMatch {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
65
- ],
66
- [
67
- <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
68
- <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
69
- ],
70
- [
71
- <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
72
- ],
73
- ];
74
-
75
- // Stories
76
- export const DrawTable = DrawCardTableTemplate.bind({});
77
- DrawTable.args = {
78
- headerRows,
79
- tableRows,
80
- };
81
-
82
- export const TeamDrawTable = TeamDrawCardTableTemplate.bind({});
83
- TeamDrawTable.args = {
84
- headerRows,
85
- tableRows: teamTableRows,
86
- };
87
-
88
- export const MobileTeamDrawTable = TeamDrawCardTableTemplate.bind({});
89
- MobileTeamDrawTable.args = {
90
- headerRows,
91
- tableRows: teamTableRows,
92
- isMobile: true
93
- };
94
-
95
- export const SortableTable = DrawCardTableTemplate.bind({});
96
- SortableTable.args = {
97
- headCells: MOCK_HEAD_CELLS,
98
- sortOrder: 'asc',
99
- sortByProperty: 'player',
100
- title: 'Player Table',
101
- tableData: MOCK_TABLE_DATA,
102
- rowComponent: mockRowComponent,
103
- onOrderPropertyChange,
104
- };
1
+ import React from 'react';
2
+ import TeamDrawCard from '../../molecules/Cards/TeamDrawCard';
3
+ import DrawCard from '../../molecules/Cards/DrawCard';
4
+ import DrawCardTable from './DrawCardTable';
5
+ import TeamDrawCardTable from './TeamDrawCardTable/TeamDrawCardTable';
6
+ import { DrawCardTableProps } from './sharedTypes';
7
+ import {
8
+ MOCK_HEAD_CELLS, mockRowComponent, MOCK_TABLE_DATA, SAMPLE_CARD_DATA, SAMPLE_TEAM_PAGE_CARD_DATA
9
+ } from './mockData';
10
+
11
+ const onOrderPropertyChange = () => {};
12
+
13
+ // Default
14
+ export default {
15
+ title: 'Organisms/Tables',
16
+ };
17
+
18
+ // Templates
19
+ function DrawCardTableTemplate(args: DrawCardTableProps) {
20
+ return <DrawCardTable {...args} />;
21
+ }
22
+
23
+ function TeamDrawCardTableTemplate(args: DrawCardTableProps) {
24
+ return <TeamDrawCardTable {...args} />;
25
+ }
26
+
27
+ const headerRows = [
28
+ { name: 'Round 1' },
29
+ { name: 'Quarterfinal' },
30
+ { name: 'SemiFinal' },
31
+ ];
32
+
33
+ const tableRows = [
34
+ [
35
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
36
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} locationLabel="hi" />,
37
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
38
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} locationLabel="hi" />,
39
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
40
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
41
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} locationLabel="hi" />,
42
+ <DrawCard isSelectActive isFlexWidth emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
43
+ ],
44
+ [
45
+ <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} onViewClick={() => {}} />,
46
+ <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
47
+ <DrawCard isScorelessMatch emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
48
+ <DrawCard isScorelessMatch emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
49
+ ],
50
+ [
51
+ <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
52
+ <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
53
+ ],
54
+ [
55
+ <DrawCard emptyLabel="Select a team" {...SAMPLE_CARD_DATA} />,
56
+ ],
57
+ ];
58
+
59
+ const teamTableRows = [
60
+ [
61
+ <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
62
+ <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
63
+ <TeamDrawCard isScorelessMatch {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
64
+ <TeamDrawCard isScorelessMatch {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
65
+ ],
66
+ [
67
+ <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
68
+ <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
69
+ ],
70
+ [
71
+ <TeamDrawCard {...SAMPLE_TEAM_PAGE_CARD_DATA} />,
72
+ ],
73
+ ];
74
+
75
+ // Stories
76
+ export const DrawTable = DrawCardTableTemplate.bind({});
77
+ DrawTable.args = {
78
+ headerRows,
79
+ tableRows,
80
+ };
81
+
82
+ export const TeamDrawTable = TeamDrawCardTableTemplate.bind({});
83
+ TeamDrawTable.args = {
84
+ headerRows,
85
+ tableRows: teamTableRows,
86
+ };
87
+
88
+ export const MobileTeamDrawTable = TeamDrawCardTableTemplate.bind({});
89
+ MobileTeamDrawTable.args = {
90
+ headerRows,
91
+ tableRows: teamTableRows,
92
+ isMobile: true
93
+ };
94
+
95
+ export const SortableTable = DrawCardTableTemplate.bind({});
96
+ SortableTable.args = {
97
+ headCells: MOCK_HEAD_CELLS,
98
+ sortOrder: 'asc',
99
+ sortByProperty: 'player',
100
+ title: 'Player Table',
101
+ tableData: MOCK_TABLE_DATA,
102
+ rowComponent: mockRowComponent,
103
+ onOrderPropertyChange,
104
+ };
@@ -1,102 +1,102 @@
1
- import React from "react";
2
- import { styled } from "@mui/material/styles";
3
- import Grid from "@mui/material/Grid";
4
- import Box from "@mui/material/Box";
5
-
6
- import { TableRowProps } from '../sharedTypes';
7
- import Typography from "../../../atoms/Typography/Typography";
8
- import { teamDrawCardSideMargin, standardSideMargin } from "../../../utils/constants";
9
-
10
- const StyledHeader = styled(Grid)({
11
- alignItems: "center",
12
- justifyContent: "center",
13
- display: "flex"
14
- });
15
-
16
- const gridCommonStyles = {
17
- content: "''",
18
- position: "absolute",
19
- backgroundColor: "var(--cool-grey-600)",
20
- };
21
-
22
- const horizontalLineCommonStyles = {
23
- height: "1px",
24
- top: "50%",
25
- };
26
-
27
- const StyledGrid = styled(Grid)({
28
- position: "relative",
29
-
30
- "&:nth-last-child(-n+2) .team-draw-card": {
31
- "&:before": {
32
- ...gridCommonStyles,
33
- ...horizontalLineCommonStyles,
34
- width: `${teamDrawCardSideMargin}`,
35
- left: 0,
36
- transform: "translateX(-100%)"
37
- }
38
- },
39
- "&:nth-of-type(-n+2) .team-draw-card": {
40
- "&:after": {
41
- ...gridCommonStyles,
42
- ...horizontalLineCommonStyles,
43
- width: `calc(${standardSideMargin + 1}px)`,
44
- right: 0,
45
- transform: "translateX(100%)"
46
- }
47
- }
48
- });
49
-
50
- const GridSections = styled(Box)({
51
- display: "flex",
52
- alignItems: "center",
53
- position: 'relative',
54
- });
55
-
56
- export default function DesktopTableRows({
57
- headerRows, totalColumns, tableRows
58
- }: TableRowProps) {
59
- const formatTableRows = tableRows.map((row, index) => {
60
- if (index > 2) return; // Table can only support 3 columns
61
- const rowSectionsHeight = `${100 / tableRows[index].length}%`;
62
- const sectionAmount = tableRows[index].length;
63
- const isFirstRow = index === 0;
64
-
65
- return (
66
- <StyledGrid key={index} xs={totalColumns}>
67
- {[...Array(sectionAmount)].map((section, idx) => (
68
- <GridSections
69
- key={idx}
70
- sx={{
71
- height: rowSectionsHeight,
72
- '&:before': {
73
- display: isFirstRow ? 'none' : 'block',
74
- ...gridCommonStyles,
75
- height: `calc(50% + 1px)`,
76
- width: "1px",
77
- top: `calc(25% - 4px)`
78
- },
79
- }}
80
- >
81
- {row[idx]}
82
- </GridSections>
83
- ))}
84
- </StyledGrid>
85
- );
86
- });
87
-
88
- return (
89
- <>
90
- <Grid container sx={{ height: "60px" }}>
91
- {headerRows.map((row) => (
92
- <StyledHeader key={row.name} xs={totalColumns}>
93
- <Typography category="secondary" size="small-medium-cap">
94
- {row.name}
95
- </Typography>
96
- </StyledHeader>
97
- ))}
98
- </Grid>
99
- <Grid container>{formatTableRows}</Grid>
100
- </>
101
- );
102
- }
1
+ import React from "react";
2
+ import { styled } from "@mui/material/styles";
3
+ import Grid from "@mui/material/Grid";
4
+ import Box from "@mui/material/Box";
5
+
6
+ import { TableRowProps } from '../sharedTypes';
7
+ import Typography from "../../../atoms/Typography/Typography";
8
+ import { teamDrawCardSideMargin, standardSideMargin } from "../../../utils/constants";
9
+
10
+ const StyledHeader = styled(Grid)({
11
+ alignItems: "center",
12
+ justifyContent: "center",
13
+ display: "flex"
14
+ });
15
+
16
+ const gridCommonStyles = {
17
+ content: "''",
18
+ position: "absolute",
19
+ backgroundColor: "var(--cool-grey-600)",
20
+ };
21
+
22
+ const horizontalLineCommonStyles = {
23
+ height: "1px",
24
+ top: "50%",
25
+ };
26
+
27
+ const StyledGrid = styled(Grid)({
28
+ position: "relative",
29
+
30
+ "&:nth-last-child(-n+2) .team-draw-card": {
31
+ "&:before": {
32
+ ...gridCommonStyles,
33
+ ...horizontalLineCommonStyles,
34
+ width: `${teamDrawCardSideMargin}`,
35
+ left: 0,
36
+ transform: "translateX(-100%)"
37
+ }
38
+ },
39
+ "&:nth-of-type(-n+2) .team-draw-card": {
40
+ "&:after": {
41
+ ...gridCommonStyles,
42
+ ...horizontalLineCommonStyles,
43
+ width: `calc(${standardSideMargin + 1}px)`,
44
+ right: 0,
45
+ transform: "translateX(100%)"
46
+ }
47
+ }
48
+ });
49
+
50
+ const GridSections = styled(Box)({
51
+ display: "flex",
52
+ alignItems: "center",
53
+ position: 'relative',
54
+ });
55
+
56
+ export default function DesktopTableRows({
57
+ headerRows, totalColumns, tableRows
58
+ }: TableRowProps) {
59
+ const formatTableRows = tableRows.map((row, index) => {
60
+ if (index > 2) return; // Table can only support 3 columns
61
+ const rowSectionsHeight = `${100 / tableRows[index].length}%`;
62
+ const sectionAmount = tableRows[index].length;
63
+ const isFirstRow = index === 0;
64
+
65
+ return (
66
+ <StyledGrid key={index} xs={totalColumns}>
67
+ {[...Array(sectionAmount)].map((section, idx) => (
68
+ <GridSections
69
+ key={idx}
70
+ sx={{
71
+ height: rowSectionsHeight,
72
+ '&:before': {
73
+ display: isFirstRow ? 'none' : 'block',
74
+ ...gridCommonStyles,
75
+ height: `calc(50% + 1px)`,
76
+ width: "1px",
77
+ top: `calc(25% - 4px)`
78
+ },
79
+ }}
80
+ >
81
+ {row[idx]}
82
+ </GridSections>
83
+ ))}
84
+ </StyledGrid>
85
+ );
86
+ });
87
+
88
+ return (
89
+ <>
90
+ <Grid container sx={{ height: "60px" }}>
91
+ {headerRows.map((row) => (
92
+ <StyledHeader key={row.name} xs={totalColumns}>
93
+ <Typography category="secondary" size="small-medium-cap">
94
+ {row.name}
95
+ </Typography>
96
+ </StyledHeader>
97
+ ))}
98
+ </Grid>
99
+ <Grid container>{formatTableRows}</Grid>
100
+ </>
101
+ );
102
+ }