@luscii-healthtech/web-ui 0.1.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 (311) hide show
  1. package/README.md +181 -0
  2. package/dist/components/Acknowledgement/Acknowledgement.d.ts +22 -0
  3. package/dist/components/Avatar/Avatar.d.ts +29 -0
  4. package/dist/components/Badge/Badge.d.ts +7 -0
  5. package/dist/components/Button/Button.d.ts +5 -0
  6. package/dist/components/Button/Button.types.d.ts +32 -0
  7. package/dist/components/Button/ButtonIcon.d.ts +7 -0
  8. package/dist/components/ButtonV2/ButtonV2.d.ts +13 -0
  9. package/dist/components/ButtonV2/PrimaryButton.d.ts +12 -0
  10. package/dist/components/ButtonV2/SecondaryButton.d.ts +8 -0
  11. package/dist/components/ButtonV2/TertiaryButton.d.ts +8 -0
  12. package/dist/components/Carousel/Carousel.d.ts +8 -0
  13. package/dist/components/Carousel/GliderContainer.d.ts +7 -0
  14. package/dist/components/CenteredHero/CenteredHero.d.ts +22 -0
  15. package/dist/components/Checkbox/Checkbox.d.ts +17 -0
  16. package/dist/components/ConfirmationDialog/ConfirmationDialog.d.ts +33 -0
  17. package/dist/components/Datepicker/Datepicker.d.ts +24 -0
  18. package/dist/components/Dropdown/Dropdown.d.ts +47 -0
  19. package/dist/components/EmptyListMessage/EmptyListMessage.d.ts +14 -0
  20. package/dist/components/ErrorBlock/ErrorBlock.d.ts +13 -0
  21. package/dist/components/Icons/AddIcon.d.ts +3 -0
  22. package/dist/components/Icons/AlertsIcon.d.ts +6 -0
  23. package/dist/components/Icons/BellIcon.d.ts +6 -0
  24. package/dist/components/Icons/ChartIcon.d.ts +3 -0
  25. package/dist/components/Icons/ChatBox.d.ts +5 -0
  26. package/dist/components/Icons/CheckIcon.d.ts +2 -0
  27. package/dist/components/Icons/ChevronIcon.d.ts +8 -0
  28. package/dist/components/Icons/CrossIcon.d.ts +7 -0
  29. package/dist/components/Icons/DeleteIcon.d.ts +6 -0
  30. package/dist/components/Icons/DownArrowIcon.d.ts +6 -0
  31. package/dist/components/Icons/DragIcon.d.ts +3 -0
  32. package/dist/components/Icons/EditIcon.d.ts +6 -0
  33. package/dist/components/Icons/EmptyStateDashboardIcon.d.ts +2 -0
  34. package/dist/components/Icons/ExclamationMarkIcon.d.ts +6 -0
  35. package/dist/components/Icons/EyeIcon.d.ts +3 -0
  36. package/dist/components/Icons/GearIcon.d.ts +3 -0
  37. package/dist/components/Icons/GroupIcon.d.ts +3 -0
  38. package/dist/components/Icons/HeartIcon.d.ts +6 -0
  39. package/dist/components/Icons/LeftArrowIcon.d.ts +6 -0
  40. package/dist/components/Icons/LightBulbIcon.d.ts +6 -0
  41. package/dist/components/Icons/LockIcon.d.ts +6 -0
  42. package/dist/components/Icons/MessagesIcon.d.ts +6 -0
  43. package/dist/components/Icons/NotesIcon.d.ts +6 -0
  44. package/dist/components/Icons/PinIcon.d.ts +6 -0
  45. package/dist/components/Icons/PrintIcon.d.ts +3 -0
  46. package/dist/components/Icons/RightArrowIcon.d.ts +6 -0
  47. package/dist/components/Icons/SmallCircleIcon.d.ts +6 -0
  48. package/dist/components/Icons/SmallDiamondIcon.d.ts +6 -0
  49. package/dist/components/Icons/SmallSquareIcon.d.ts +6 -0
  50. package/dist/components/Icons/SpaceRocketIcon.d.ts +6 -0
  51. package/dist/components/Icons/types/IconProps.type.d.ts +3 -0
  52. package/dist/components/InfoBlock/InfoBlock.d.ts +14 -0
  53. package/dist/components/InfoField/InfoField.d.ts +18 -0
  54. package/dist/components/Input/Input.d.ts +44 -0
  55. package/dist/components/Line/Line.d.ts +14 -0
  56. package/dist/components/ListItem/ListItem.d.ts +9 -0
  57. package/dist/components/ListTable/ListTable.d.ts +35 -0
  58. package/dist/components/ListTable/ListTableCell.d.ts +10 -0
  59. package/dist/components/ListTable/ListTableHeader.d.ts +7 -0
  60. package/dist/components/ListTable/ListTableRow.d.ts +9 -0
  61. package/dist/components/LoadingIndicator/LoadingIndicator.d.ts +11 -0
  62. package/dist/components/Menu/Menu.d.ts +14 -0
  63. package/dist/components/Modal/Modal.d.ts +31 -0
  64. package/dist/components/Modal/ModalWithButtons.d.ts +9 -0
  65. package/dist/components/MultiSelect/MultiSelect.d.ts +25 -0
  66. package/dist/components/MultiSelect/MultiSelectUtils.d.ts +1 -0
  67. package/dist/components/NavMenu/NavLayout.d.ts +20 -0
  68. package/dist/components/NavMenu/NavMenu.d.ts +1 -0
  69. package/dist/components/NavMenu/NavMenuContent.d.ts +7 -0
  70. package/dist/components/NavMenu/NavMenuItem.d.ts +15 -0
  71. package/dist/components/NotificationBanner/NotificationBanner.d.ts +22 -0
  72. package/dist/components/Page/CRUDPage.d.ts +43 -0
  73. package/dist/components/Page/Page.d.ts +58 -0
  74. package/dist/components/PaginationMenu/PaginationMenu.d.ts +20 -0
  75. package/dist/components/PaginationMenu/PaginationMenuLarge.d.ts +13 -0
  76. package/dist/components/PaginationMenu/PaginationMenuSmall.d.ts +8 -0
  77. package/dist/components/PreviewPhone/PreviewPhone.d.ts +7 -0
  78. package/dist/components/PreviewPhone/useWindowDimensions.d.ts +4 -0
  79. package/dist/components/Radio/Radio.d.ts +18 -0
  80. package/dist/components/RadioGroup/RadioGroup.d.ts +31 -0
  81. package/dist/components/Section/Section.d.ts +15 -0
  82. package/dist/components/Select/LegacySelect.d.ts +32 -0
  83. package/dist/components/Select/Select.d.ts +6 -0
  84. package/dist/components/Select/options.transformer.d.ts +14 -0
  85. package/dist/components/Select/select.utils.d.ts +7 -0
  86. package/dist/components/SettingsMenuButton/SettingsMenuButton.d.ts +16 -0
  87. package/dist/components/Spinner/Spinner.d.ts +6 -0
  88. package/dist/components/Steps/Step.d.ts +10 -0
  89. package/dist/components/Steps/Steps.d.ts +11 -0
  90. package/dist/components/Switcher/Switcher.d.ts +26 -0
  91. package/dist/components/Switcher/SwitcherItem.d.ts +24 -0
  92. package/dist/components/TabLinks/TabLinks.d.ts +14 -0
  93. package/dist/components/Tabbar/Tabbar.d.ts +10 -0
  94. package/dist/components/Tabbar/TabbarItem.d.ts +15 -0
  95. package/dist/components/Tag/Tag.d.ts +17 -0
  96. package/dist/components/Tag/TagGroup.d.ts +13 -0
  97. package/dist/components/Text/LegacyText.d.ts +37 -0
  98. package/dist/components/Text/Text.d.ts +27 -0
  99. package/dist/components/TextEditor/TextEditor.d.ts +14 -0
  100. package/dist/components/TextEditorV2/TextEditorV2.d.ts +6 -0
  101. package/dist/components/TextLink/TextLink.d.ts +11 -0
  102. package/dist/components/TextListItem/TextListItem.d.ts +12 -0
  103. package/dist/components/Textarea/Textarea.d.ts +22 -0
  104. package/dist/components/Title/LegacyTitle.d.ts +22 -0
  105. package/dist/components/Title/Title.d.ts +14 -0
  106. package/dist/components/ViewItem/ViewItem.d.ts +16 -0
  107. package/dist/index.d.ts +8 -0
  108. package/dist/index.js +8 -0
  109. package/dist/types/general.types.d.ts +7 -0
  110. package/dist/utils/useOutsideClick.d.ts +2 -0
  111. package/dist/web-ui.cjs.development.js +23 -0
  112. package/dist/web-ui.cjs.development.js.map +1 -0
  113. package/dist/web-ui.cjs.production.min.js +2 -0
  114. package/dist/web-ui.cjs.production.min.js.map +1 -0
  115. package/dist/web-ui.esm.js +17 -0
  116. package/dist/web-ui.esm.js.map +1 -0
  117. package/package.json +122 -0
  118. package/src/assets/add.svg +5 -0
  119. package/src/assets/add_hover.svg +4 -0
  120. package/src/assets/big-menu-icon-hover.svg +6 -0
  121. package/src/assets/big-menu-icon.svg +6 -0
  122. package/src/assets/check-cross-icon.svg +7 -0
  123. package/src/assets/check-icon-primary.svg +5 -0
  124. package/src/assets/check-icon.svg +3 -0
  125. package/src/assets/chevron-double.svg +3 -0
  126. package/src/assets/close.svg +3 -0
  127. package/src/assets/color-variant-cross.svg +3 -0
  128. package/src/assets/cross-dark.svg +3 -0
  129. package/src/assets/delete.svg +4 -0
  130. package/src/assets/delete_hover.svg +4 -0
  131. package/src/assets/edit.svg +6 -0
  132. package/src/assets/edit_hover.svg +6 -0
  133. package/src/assets/error-icon.svg +7 -0
  134. package/src/assets/grid-view-icon-active.svg +6 -0
  135. package/src/assets/grid-view-icon.svg +6 -0
  136. package/src/assets/groups.svg +3 -0
  137. package/src/assets/hamburger.svg +5 -0
  138. package/src/assets/happy-star.svg +9 -0
  139. package/src/assets/hcps.svg +3 -0
  140. package/src/assets/info-icon.svg +6 -0
  141. package/src/assets/left-arrow-blue.svg +3 -0
  142. package/src/assets/left-arrow-grey.svg +3 -0
  143. package/src/assets/list-view-icon-active.svg +3 -0
  144. package/src/assets/list-view-icon.svg +3 -0
  145. package/src/assets/loading.svg +16 -0
  146. package/src/assets/modal-close-icon-active.svg +9 -0
  147. package/src/assets/modal-close-icon.svg +9 -0
  148. package/src/assets/no-open-alerts.svg +19 -0
  149. package/src/assets/patients.svg +3 -0
  150. package/src/assets/phone-mockup.svg +9 -0
  151. package/src/assets/programs.svg +3 -0
  152. package/src/assets/right-arrow-blue.svg +3 -0
  153. package/src/assets/right-arrow-grey.svg +3 -0
  154. package/src/assets/search-cancel.svg +3 -0
  155. package/src/assets/search-not-found.svg +70 -0
  156. package/src/assets/search.svg +3 -0
  157. package/src/assets/spinner-gray.svg +6 -0
  158. package/src/assets/spinner.svg +6 -0
  159. package/src/assets/starIcon.svg +3 -0
  160. package/src/assets/success-icon.svg +7 -0
  161. package/src/components/Acknowledgement/Acknowledgement.js +61 -0
  162. package/src/components/Acknowledgement/Acknowledgement.scss +49 -0
  163. package/src/components/Avatar/Avatar.js +81 -0
  164. package/src/components/Avatar/Avatar.scss +153 -0
  165. package/src/components/Badge/Badge.tsx +23 -0
  166. package/src/components/Button/Button.examples.md +46 -0
  167. package/src/components/Button/Button.tsx +200 -0
  168. package/src/components/Button/Button.types.ts +41 -0
  169. package/src/components/Button/ButtonIcon.tsx +42 -0
  170. package/src/components/ButtonV2/ButtonV2.tsx +91 -0
  171. package/src/components/ButtonV2/PrimaryButton.tsx +43 -0
  172. package/src/components/ButtonV2/SecondaryButton.tsx +31 -0
  173. package/src/components/ButtonV2/TertiaryButton.tsx +31 -0
  174. package/src/components/Carousel/Carousel.tsx +52 -0
  175. package/src/components/Carousel/GliderContainer.scss +13 -0
  176. package/src/components/Carousel/GliderContainer.tsx +22 -0
  177. package/src/components/CenteredHero/CenteredHero.js +50 -0
  178. package/src/components/Checkbox/Checkbox.scss +115 -0
  179. package/src/components/Checkbox/Checkbox.tsx +114 -0
  180. package/src/components/ConfirmationDialog/ConfirmationDialog.scss +15 -0
  181. package/src/components/ConfirmationDialog/ConfirmationDialog.tsx +84 -0
  182. package/src/components/Datepicker/Datepicker.js +96 -0
  183. package/src/components/Datepicker/Datepicker.scss +331 -0
  184. package/src/components/Dropdown/Dropdown.js +364 -0
  185. package/src/components/Dropdown/Dropdown.scss +83 -0
  186. package/src/components/EmptyListMessage/EmptyListMessage.tsx +34 -0
  187. package/src/components/ErrorBlock/ErrorBlock.js +24 -0
  188. package/src/components/ErrorBlock/ErrorBlock.scss +20 -0
  189. package/src/components/Icons/AddIcon.tsx +27 -0
  190. package/src/components/Icons/AlertsIcon.tsx +26 -0
  191. package/src/components/Icons/BellIcon.tsx +26 -0
  192. package/src/components/Icons/ChartIcon.tsx +20 -0
  193. package/src/components/Icons/ChatBox.tsx +23 -0
  194. package/src/components/Icons/CheckIcon.tsx +23 -0
  195. package/src/components/Icons/ChevronIcon.tsx +30 -0
  196. package/src/components/Icons/CrossIcon.tsx +26 -0
  197. package/src/components/Icons/DeleteIcon.tsx +23 -0
  198. package/src/components/Icons/DownArrowIcon.tsx +17 -0
  199. package/src/components/Icons/DragIcon.tsx +23 -0
  200. package/src/components/Icons/EditIcon.tsx +23 -0
  201. package/src/components/Icons/EmptyStateDashboardIcon.tsx +130 -0
  202. package/src/components/Icons/ExclamationMarkIcon.tsx +23 -0
  203. package/src/components/Icons/EyeIcon.tsx +21 -0
  204. package/src/components/Icons/GearIcon.tsx +21 -0
  205. package/src/components/Icons/GroupIcon.tsx +21 -0
  206. package/src/components/Icons/HeartIcon.tsx +23 -0
  207. package/src/components/Icons/LeftArrowIcon.tsx +23 -0
  208. package/src/components/Icons/LightBulbIcon.tsx +28 -0
  209. package/src/components/Icons/LockIcon.tsx +23 -0
  210. package/src/components/Icons/MessagesIcon.tsx +23 -0
  211. package/src/components/Icons/NotesIcon.tsx +23 -0
  212. package/src/components/Icons/PinIcon.tsx +23 -0
  213. package/src/components/Icons/PrintIcon.tsx +15 -0
  214. package/src/components/Icons/RightArrowIcon.tsx +23 -0
  215. package/src/components/Icons/SmallCircleIcon.tsx +21 -0
  216. package/src/components/Icons/SmallDiamondIcon.tsx +31 -0
  217. package/src/components/Icons/SmallSquareIcon.tsx +21 -0
  218. package/src/components/Icons/SpaceRocketIcon.tsx +23 -0
  219. package/src/components/Icons/types/IconProps.type.ts +3 -0
  220. package/src/components/InfoBlock/InfoBlock.js +24 -0
  221. package/src/components/InfoBlock/InfoBlock.scss +20 -0
  222. package/src/components/InfoField/InfoField.tsx +86 -0
  223. package/src/components/Input/Input.examples.md +94 -0
  224. package/src/components/Input/Input.js +141 -0
  225. package/src/components/Line/Line.js +38 -0
  226. package/src/components/ListItem/ListItem.scss +20 -0
  227. package/src/components/ListItem/ListItem.tsx +26 -0
  228. package/src/components/ListTable/ListTable.tsx +157 -0
  229. package/src/components/ListTable/ListTableCell.tsx +67 -0
  230. package/src/components/ListTable/ListTableHeader.tsx +33 -0
  231. package/src/components/ListTable/ListTableRow.tsx +46 -0
  232. package/src/components/LoadingIndicator/LoadingIndicator.scss +50 -0
  233. package/src/components/LoadingIndicator/LoadingIndicator.tsx +44 -0
  234. package/src/components/Menu/Menu.js +74 -0
  235. package/src/components/Menu/Menu.scss +27 -0
  236. package/src/components/Modal/Modal.scss +117 -0
  237. package/src/components/Modal/Modal.tsx +104 -0
  238. package/src/components/Modal/ModalWithButtons.tsx +34 -0
  239. package/src/components/MultiSelect/MultiSelect.js +117 -0
  240. package/src/components/MultiSelect/MultiSelect.scss +29 -0
  241. package/src/components/MultiSelect/MultiSelectUtils.js +23 -0
  242. package/src/components/NavMenu/NavLayout.tsx +40 -0
  243. package/src/components/NavMenu/NavMenu.js +35 -0
  244. package/src/components/NavMenu/NavMenuContent.tsx +23 -0
  245. package/src/components/NavMenu/NavMenuItem.tsx +96 -0
  246. package/src/components/NotificationBanner/NotificationBanner.tsx +57 -0
  247. package/src/components/Page/CRUDPage.js +123 -0
  248. package/src/components/Page/CRUDPage.scss +32 -0
  249. package/src/components/Page/Page.js +102 -0
  250. package/src/components/Page/Page.scss +59 -0
  251. package/src/components/PaginationMenu/PaginationMenu.js +31 -0
  252. package/src/components/PaginationMenu/PaginationMenuLarge.tsx +94 -0
  253. package/src/components/PaginationMenu/PaginationMenuSmall.tsx +40 -0
  254. package/src/components/PreviewPhone/PreviewPhone.tsx +53 -0
  255. package/src/components/PreviewPhone/useWindowDimensions.js +26 -0
  256. package/src/components/Radio/Radio.js +99 -0
  257. package/src/components/Radio/Radio.scss +58 -0
  258. package/src/components/RadioGroup/RadioGroup.js +63 -0
  259. package/src/components/RadioGroup/RadioGroup.scss +37 -0
  260. package/src/components/Section/Section.scss +74 -0
  261. package/src/components/Section/Section.tsx +67 -0
  262. package/src/components/Select/LegacySelect.js +114 -0
  263. package/src/components/Select/Select.examples.md +161 -0
  264. package/src/components/Select/Select.tsx +136 -0
  265. package/src/components/Select/options.transformer.ts +36 -0
  266. package/src/components/Select/select.utils.spec.ts +63 -0
  267. package/src/components/Select/select.utils.ts +45 -0
  268. package/src/components/SettingsMenuButton/SettingsMenuButton.tsx +111 -0
  269. package/src/components/Spinner/Spinner.tsx +23 -0
  270. package/src/components/Steps/Step.tsx +22 -0
  271. package/src/components/Steps/Steps.tsx +24 -0
  272. package/src/components/Switcher/Switcher.js +58 -0
  273. package/src/components/Switcher/SwitcherItem.js +61 -0
  274. package/src/components/Switcher/SwitcherItem.scss +67 -0
  275. package/src/components/TabLinks/TabLinks.tsx +63 -0
  276. package/src/components/Tabbar/Tabbar.tsx +29 -0
  277. package/src/components/Tabbar/TabbarItem.tsx +53 -0
  278. package/src/components/Tag/Tag.tsx +39 -0
  279. package/src/components/Tag/TagGroup.tsx +25 -0
  280. package/src/components/Text/LegacyText.js +78 -0
  281. package/src/components/Text/Text.scss +67 -0
  282. package/src/components/Text/Text.tsx +81 -0
  283. package/src/components/TextEditor/TextEditor.js +61 -0
  284. package/src/components/TextEditor/TextEditor.scss +14 -0
  285. package/src/components/TextEditorV2/TextEditorV2.js +58 -0
  286. package/src/components/TextEditorV2/TextEditorV2.scss +110 -0
  287. package/src/components/TextLink/TextLink.tsx +42 -0
  288. package/src/components/TextListItem/TextListItem.js +31 -0
  289. package/src/components/TextListItem/TextListItem.scss +10 -0
  290. package/src/components/Textarea/Textarea.js +108 -0
  291. package/src/components/Textarea/Textarea.scss +56 -0
  292. package/src/components/Title/LegacyTitle.js +64 -0
  293. package/src/components/Title/Title.scss +65 -0
  294. package/src/components/Title/Title.tsx +57 -0
  295. package/src/components/ViewItem/ViewItem.tsx +73 -0
  296. package/src/index.tsx +14 -0
  297. package/src/styles/_colors.scss +59 -0
  298. package/src/styles/_layout.scss +64 -0
  299. package/src/styles/_shadows.scss +19 -0
  300. package/src/styles/_typography.scss +8 -0
  301. package/src/styles/_utils.scss +45 -0
  302. package/src/styles/fonts/avenir/3A0AF8_0_0.eot +0 -0
  303. package/src/styles/fonts/avenir/3A0AF8_0_0.ttf +0 -0
  304. package/src/styles/fonts/avenir/3A0AF8_0_0.woff +0 -0
  305. package/src/styles/fonts/avenir/3A0AF8_0_0.woff2 +0 -0
  306. package/src/styles/fonts/avenir/3A0AF8_1_0.eot +0 -0
  307. package/src/styles/fonts/avenir/3A0AF8_1_0.ttf +0 -0
  308. package/src/styles/fonts/avenir/3A0AF8_1_0.woff +0 -0
  309. package/src/styles/fonts/avenir/3A0AF8_1_0.woff2 +0 -0
  310. package/src/types/general.types.ts +11 -0
  311. package/src/utils/useOutsideClick.js +19 -0
@@ -0,0 +1,364 @@
1
+ import React, { PureComponent } from "react";
2
+ import PropTypes from "prop-types";
3
+ import classNames from "classnames";
4
+
5
+ import chevronDouble from "../../assets/chevron-double.svg";
6
+ import checkmark from "../../assets/check-icon-primary.svg";
7
+ import { Text } from "../Text/Text";
8
+
9
+ import "./Dropdown.scss";
10
+
11
+ const ITEM_QUERY_FIELD_NAMES = {
12
+ ID: "id",
13
+ HIGHLIGHT_INDEX: "highlightIndex",
14
+ };
15
+
16
+ const keyCodes = {
17
+ ARROW_DOWN: 40,
18
+ ARROW_UP: 38,
19
+ ENTER: 13,
20
+ TAB: 9,
21
+ SHIFT: 16,
22
+ ESC: 27,
23
+ };
24
+
25
+ class Dropdown extends PureComponent {
26
+ static addHighlightIndexToItems = (items) => {
27
+ let index = 0;
28
+
29
+ return items.map((item) => {
30
+ if (!item.subItems) {
31
+ const currentIndex = index;
32
+ index = index + 1;
33
+
34
+ return {
35
+ ...item,
36
+ highlightIndex: currentIndex,
37
+ };
38
+ } else {
39
+ return {
40
+ ...item,
41
+ subItems: item.subItems.map((subItem) => {
42
+ const currentIndex = index;
43
+ index = index + 1;
44
+
45
+ return {
46
+ ...subItem,
47
+ highlightIndex: currentIndex,
48
+ };
49
+ }),
50
+ };
51
+ }
52
+ });
53
+ };
54
+
55
+ static getTotalItemCount = (items) => {
56
+ return items.reduce((acc, item) => {
57
+ if (!item.subItems) {
58
+ return acc + 1;
59
+ } else {
60
+ return acc + item.subItems.length;
61
+ }
62
+ }, 0);
63
+ };
64
+
65
+ constructor(props) {
66
+ super(props);
67
+
68
+ const items = Dropdown.addHighlightIndexToItems(props.items);
69
+ const selectedItem = props.initialSelectedItemId
70
+ ? this.findItem(items, ITEM_QUERY_FIELD_NAMES.ID, props.initialSelectedItemId)
71
+ : null;
72
+
73
+ this.state = {
74
+ totalItemCount: Dropdown.getTotalItemCount(items),
75
+ isDropdownOpen: false,
76
+ highlightIndex: null,
77
+ selectedItem,
78
+ items,
79
+ };
80
+ }
81
+
82
+ static getDerivedStateFromProps(nextProps, prevState) {
83
+ const items = Dropdown.addHighlightIndexToItems(nextProps.items);
84
+
85
+ return {
86
+ ...prevState,
87
+ items: items,
88
+ totalItemCount: Dropdown.getTotalItemCount(items),
89
+ };
90
+ }
91
+
92
+ componentDidMount() {
93
+ document.addEventListener("mousedown", this.handleClickOutside);
94
+ }
95
+
96
+ componentWillUnmount() {
97
+ document.removeEventListener("mousedown", this.handleClickOutside);
98
+ }
99
+
100
+ handleClickOutside = (event) => {
101
+ if (this.rootRef && !this.rootRef.contains(event.target)) {
102
+ this.closeDropdown();
103
+ }
104
+ };
105
+
106
+ handleKeyDown = (event) => {
107
+ const { items, isDropdownOpen, highlightIndex } = this.state;
108
+
109
+ if (event.keyCode === keyCodes.ENTER) {
110
+ event.preventDefault();
111
+
112
+ if (isDropdownOpen) {
113
+ this.closeDropdown();
114
+ this.setSelectedItem(this.findItem(items, ITEM_QUERY_FIELD_NAMES.HIGHLIGHT_INDEX, highlightIndex));
115
+ this.rootRef.blur();
116
+ } else {
117
+ this.openDropdown();
118
+ }
119
+ } else if (event.keyCode === keyCodes.TAB) {
120
+ if (event.shiftKey) {
121
+ this.decreaseHighlightIndexIfPossible();
122
+ } else {
123
+ this.increaseHighlightIndexIfPossible();
124
+ }
125
+ } else if (event.keyCode === keyCodes.ARROW_UP) {
126
+ event.preventDefault();
127
+
128
+ this.decreaseHighlightIndexIfPossible();
129
+ } else if (event.keyCode === keyCodes.ARROW_DOWN) {
130
+ event.preventDefault();
131
+
132
+ if (isDropdownOpen) {
133
+ this.increaseHighlightIndexIfPossible();
134
+ } else {
135
+ this.openDropdown();
136
+ }
137
+ } else if (event.keyCode === keyCodes.ESC) {
138
+ this.closeDropdown();
139
+ this.rootRef.blur();
140
+ }
141
+ };
142
+
143
+ findItem = (items, fieldName, fieldValue) => {
144
+ let selectedItem;
145
+
146
+ for (let i = 0; i < items.length; i++) {
147
+ const item = items[i];
148
+
149
+ if (item[fieldName] === fieldValue) {
150
+ selectedItem = item;
151
+ } else if (item.subItems) {
152
+ for (let j = 0; j < item.subItems.length; j++) {
153
+ const subItem = item.subItems[j];
154
+
155
+ if (
156
+ (fieldName === ITEM_QUERY_FIELD_NAMES.ID && subItem.key === fieldValue) ||
157
+ subItem[fieldName] === fieldValue
158
+ ) {
159
+ selectedItem = subItem;
160
+ break;
161
+ }
162
+ }
163
+ }
164
+
165
+ if (selectedItem) {
166
+ break;
167
+ }
168
+ }
169
+
170
+ return selectedItem;
171
+ };
172
+
173
+ openDropdown = () => {
174
+ this.setState((prevState) => {
175
+ return {
176
+ isDropdownOpen: true,
177
+ highlightIndex: prevState.selectedItem ? prevState.selectedItem.highlightIndex : 0,
178
+ };
179
+ });
180
+ };
181
+
182
+ closeDropdown = () => {
183
+ this.setState({
184
+ isDropdownOpen: false,
185
+ highlightIndex: null,
186
+ });
187
+ };
188
+
189
+ setSelectedItem = (item) => {
190
+ this.setState({
191
+ selectedItem: item,
192
+ });
193
+ };
194
+
195
+ findSelectedItem = (selectedIndex) => {
196
+ return this.rootRef.querySelectorAll(".dropdown-list-item")[selectedIndex];
197
+ };
198
+
199
+ scrollToHighlightedItem = (selectedIndex) => {
200
+ const selectedItem = this.findSelectedItem(selectedIndex);
201
+ if (this.dropdownListRef.scrollTo) {
202
+ this.dropdownListRef.scrollTo(0, selectedItem.offsetTop);
203
+ }
204
+ };
205
+
206
+ increaseHighlightIndexIfPossible = () => {
207
+ this.setState((prevState) => {
208
+ const newHighlightIndex =
209
+ prevState.highlightIndex < prevState.totalItemCount - 1
210
+ ? prevState.highlightIndex + 1
211
+ : prevState.highlightIndex;
212
+
213
+ if (newHighlightIndex !== prevState.highlightIndex) {
214
+ this.scrollToHighlightedItem(newHighlightIndex);
215
+ }
216
+
217
+ return {
218
+ highlightIndex: newHighlightIndex,
219
+ };
220
+ });
221
+ };
222
+
223
+ decreaseHighlightIndexIfPossible = () => {
224
+ this.setState((prevState) => {
225
+ const newHighlightIndex = prevState.highlightIndex > 0 ? prevState.highlightIndex - 1 : prevState.highlightIndex;
226
+
227
+ if (newHighlightIndex !== prevState.highlightIndex) {
228
+ this.scrollToHighlightedItem(newHighlightIndex);
229
+ }
230
+
231
+ return {
232
+ highlightIndex: newHighlightIndex,
233
+ };
234
+ });
235
+ };
236
+
237
+ selectItem = (item) => {
238
+ const { onItemSelect } = this.props;
239
+
240
+ this.closeDropdown();
241
+ this.setSelectedItem(item);
242
+
243
+ onItemSelect(item);
244
+ };
245
+
246
+ renderIndividualItem = (item) => {
247
+ const { highlightIndex } = this.state;
248
+ const isItemSelected = item.highlightIndex === highlightIndex;
249
+
250
+ const itemClassName = classNames("dropdown-list-item p-3", {
251
+ "is-selected": isItemSelected,
252
+ "flex flex-row justify-between space-x-2": isItemSelected,
253
+ });
254
+ const textType = isItemSelected ? "strong" : "base";
255
+
256
+ return (
257
+ <div className={itemClassName} key={item.id} tabIndex="0" onClick={() => this.selectItem(item)}>
258
+ <Text data-test-id={item.text} text={item.text} type={textType} truncate />
259
+ <img className={classNames({ hidden: !isItemSelected })} src={checkmark} alt="checked" />
260
+ </div>
261
+ );
262
+ };
263
+
264
+ renderGroupedItems = (item) => {
265
+ return (
266
+ <div className="dropdown-list-item-group" key={item.groupKey}>
267
+ {item.title && (
268
+ <div className="p-3 bg-main-background" tabIndex="-1">
269
+ <Text
270
+ className="uppercase"
271
+ data-test-id={item.text}
272
+ text={item.title}
273
+ type="sm"
274
+ color="gray-500"
275
+ truncate
276
+ />
277
+ </div>
278
+ )}
279
+ {item.subItems.map((subItem) => this.renderIndividualItem(subItem))}
280
+ </div>
281
+ );
282
+ };
283
+
284
+ renderItems = () => {
285
+ const { items } = this.state;
286
+
287
+ return (
288
+ <div
289
+ className={classNames("dropdown-list", { wider: this.props.wider })}
290
+ ref={(element) => (this.dropdownListRef = element)}
291
+ >
292
+ {items.map((item) => (item.subItems ? this.renderGroupedItems(item) : this.renderIndividualItem(item)))}
293
+ </div>
294
+ );
295
+ };
296
+
297
+ render() {
298
+ // eslint-disable-next-line no-unused-vars
299
+ const {
300
+ placeholder = "",
301
+ className,
302
+ initialSelectedItemId,
303
+ onItemSelect,
304
+ items,
305
+ wider,
306
+ ...otherProps
307
+ } = this.props;
308
+ const { selectedItem, isDropdownOpen } = this.state;
309
+ const containerClassName = classNames("cweb-dropdown", className, { "is-open": isDropdownOpen });
310
+ const onDropdownClick = isDropdownOpen ? this.closeDropdown : this.openDropdown;
311
+
312
+ return (
313
+ <div
314
+ className={classNames(containerClassName)}
315
+ tabIndex="0"
316
+ ref={(element) => (this.rootRef = element)}
317
+ onKeyDown={this.handleKeyDown}
318
+ >
319
+ <div
320
+ {...otherProps}
321
+ className={classNames("dropdown-header space-x-2 border border-solid p-3 cursor-pointer", {
322
+ "border-primary-dark": isDropdownOpen,
323
+ "border-input-border hover:border-input-border-dark": !isDropdownOpen,
324
+ })}
325
+ onClick={onDropdownClick}
326
+ >
327
+ <Text className="dropdown-header-title" text={selectedItem ? selectedItem.text : placeholder} truncate />
328
+ <img className="dropdown-header-icon" src={chevronDouble} alt="browse icon" />
329
+ </div>
330
+ {this.renderItems()}
331
+ </div>
332
+ );
333
+ }
334
+ }
335
+
336
+ Dropdown.propTypes = {
337
+ items: PropTypes.arrayOf(
338
+ PropTypes.oneOfType([
339
+ PropTypes.shape({
340
+ id: PropTypes.string.isRequired,
341
+ text: PropTypes.string.isRequired,
342
+ key: PropTypes.string.isRequired,
343
+ }),
344
+ PropTypes.shape({
345
+ subItems: PropTypes.arrayOf(
346
+ PropTypes.shape({
347
+ id: PropTypes.string.isRequired,
348
+ text: PropTypes.string.isRequired,
349
+ key: PropTypes.string.isRequired,
350
+ })
351
+ ).isRequired,
352
+ title: PropTypes.string,
353
+ groupKey: PropTypes.string.isRequired,
354
+ }),
355
+ ])
356
+ ).isRequired,
357
+ initialSelectedItemId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
358
+ placeholder: PropTypes.string,
359
+ className: PropTypes.string,
360
+ onItemSelect: PropTypes.func.isRequired,
361
+ wider: PropTypes.bool,
362
+ };
363
+
364
+ export default Dropdown;
@@ -0,0 +1,83 @@
1
+ @import "../../styles/colors";
2
+ @import "../../styles/typography";
3
+ @import "../../styles/layout";
4
+ @import "../../styles/utils";
5
+
6
+ .cweb-dropdown {
7
+ $list-item-title-padding: 15px 12px;
8
+
9
+ @mixin dropdown-list-item() {
10
+ cursor: pointer;
11
+ }
12
+
13
+ @include flexbox-vertical();
14
+ position: relative;
15
+
16
+ outline: none;
17
+ border-radius: 4px;
18
+
19
+ &:focus {
20
+ outline: 4px solid rgba(0, 159, 227, 0.3);
21
+ }
22
+
23
+ > .dropdown-header {
24
+ @include flexbox-horizontal(center, space-between);
25
+
26
+ align-self: stretch;
27
+ height: $default-height;
28
+ border-radius: $default-border-radius;
29
+ transition: all 0.4s ease;
30
+
31
+ > .dropdown-header-icon {
32
+ opacity: 0.5;
33
+ transition: opacity 0.3s ease-in-out;
34
+ }
35
+
36
+ &:hover {
37
+ > .dropdown-header-icon {
38
+ opacity: 1;
39
+ }
40
+ }
41
+ }
42
+
43
+ > .dropdown-list {
44
+ box-shadow: 0px 2px 4px -2px rgba(0, 0, 0, 0.56);
45
+
46
+ display: none;
47
+ position: absolute;
48
+ top: 100%;
49
+ z-index: 1;
50
+ width: 100%;
51
+ max-height: 360px;
52
+ overflow-y: auto;
53
+ align-self: stretch;
54
+ margin-top: 8px;
55
+ padding: 0;
56
+ background-color: #ffffff;
57
+ list-style: none;
58
+
59
+ border: 1px solid $input-border;
60
+ border-radius: 4px;
61
+
62
+ > .dropdown-list-item {
63
+ @include dropdown-list-item();
64
+ }
65
+
66
+ > .dropdown-list-item-group {
67
+ > .dropdown-list-item {
68
+ @include dropdown-list-item();
69
+ }
70
+ }
71
+ }
72
+
73
+ &.is-open {
74
+ > .dropdown-list {
75
+ display: block;
76
+ margin-bottom: 32px;
77
+
78
+ &.wider {
79
+ width: 200%;
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+
4
+ import NoOpenAlertsImage from "../../assets/no-open-alerts.svg";
5
+ import SearchNotFoundImage from "../../assets/search-not-found.svg";
6
+ import HappyStarImage from "../../assets/happy-star.svg";
7
+ import { Text } from "../Text/Text";
8
+
9
+ const imageSrc = {
10
+ "no-open-alerts": NoOpenAlertsImage,
11
+ "search-not-found": SearchNotFoundImage,
12
+ "no-notes-found": HappyStarImage,
13
+ };
14
+
15
+ interface EmptyListMessageProps {
16
+ text: string;
17
+ imageName?: keyof typeof imageSrc;
18
+ dataTestId?: string;
19
+ className?: string;
20
+ }
21
+
22
+ export const EmptyListMessage = ({
23
+ text,
24
+ imageName,
25
+ dataTestId = "empty-list-message",
26
+ className,
27
+ }: EmptyListMessageProps): JSX.Element => {
28
+ return (
29
+ <div className={classNames("flex flex-col items-center", className)} data-test-id={dataTestId}>
30
+ {imageName && <img className="mb-2.5" alt="" src={imageSrc[imageName]} />}
31
+ <Text className="text-center" text={text} />
32
+ </div>
33
+ );
34
+ };
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import classNames from "classnames";
4
+
5
+ import Text from "../Text/Text";
6
+
7
+ import "./ErrorBlock.scss";
8
+
9
+ ErrorBlock.propTypes = {
10
+ message: PropTypes.string.isRequired,
11
+ className: PropTypes.string,
12
+ };
13
+
14
+ function ErrorBlock({ message, className = "", ...otherProps }) {
15
+ const containerClassName = classNames("cweb-error-block", className);
16
+
17
+ return (
18
+ <div className={containerClassName}>
19
+ <Text {...otherProps} className="cweb-error-block-message" text={message} />
20
+ </div>
21
+ );
22
+ }
23
+
24
+ export default ErrorBlock;
@@ -0,0 +1,20 @@
1
+ @import '../../styles/colors';
2
+
3
+ .cweb-error-block {
4
+ position: relative;
5
+ padding: 16px 16px 16px 56px;
6
+ background-color: $color-negative-support;
7
+ border-radius: 8px;
8
+
9
+ &:before {
10
+ content: "";
11
+ position: absolute;
12
+ left: 16px;
13
+ top: 14px;
14
+ z-index: 1;
15
+ width: 24px;
16
+ height: 23px;
17
+ background: url("../../assets/error-icon.svg") no-repeat center;
18
+ background-size: contain;
19
+ }
20
+ }
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+
3
+ import { IconProps } from "./types/IconProps.type";
4
+
5
+ export const AddIcon = (props: IconProps): JSX.Element => {
6
+ return (
7
+ <svg
8
+ className={props.className}
9
+ width="24"
10
+ height="24"
11
+ viewBox="0 0 24 24"
12
+ fill="none"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ >
15
+ <rect x="10" y="2" width="4" height="20" rx="2" fill="currentColor" />
16
+ <rect
17
+ x="22"
18
+ y="10"
19
+ width="4"
20
+ height="20"
21
+ rx="2"
22
+ transform="rotate(90 22 10)"
23
+ fill="currentColor"
24
+ />
25
+ </svg>
26
+ );
27
+ };
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+
3
+ interface AlertsIconProps {
4
+ className?: string;
5
+ }
6
+
7
+ export const AlertsIcon = (props: AlertsIconProps): JSX.Element => {
8
+ return (
9
+ <svg
10
+ className={props.className}
11
+ width="24"
12
+ height="24"
13
+ viewBox="0 0 24 24"
14
+ fill="none"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ >
17
+ <path
18
+ d="M14 19.5C14 20.163 13.7893 20.7989 13.4142 21.2678C13.0391 21.7366 12.5304 22 12 22C11.4696 22 10.9609 21.7366 10.5858 21.2678C10.2107 20.7989 10 20.163 10 19.5L14 19.5Z"
19
+ fill="currentColor"
20
+ />
21
+ <path d="M10 4C10 2.89543 10.8954 2 12 2C13.1046 2 14 2.89543 14 4V5H10V4Z" fill="currentColor" />
22
+ <path d="M5 11C5 7.13401 8.13401 4 12 4C15.866 4 19 7.13401 19 11V17H5V11Z" fill="currentColor" />
23
+ <rect x="3" y="15.5" width="18" height="2.5" rx="1.25" fill="currentColor" />
24
+ </svg>
25
+ );
26
+ };
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+
3
+ interface BellIconProps {
4
+ className?: string;
5
+ }
6
+
7
+ export const BellIcon = (props: BellIconProps): JSX.Element => {
8
+ return (
9
+ <svg
10
+ className={props.className}
11
+ width="24"
12
+ height="24"
13
+ viewBox="0 0 24 24"
14
+ fill="none"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ >
17
+ <path
18
+ d="M14 19.5C14 20.163 13.7893 20.7989 13.4142 21.2678C13.0391 21.7366 12.5304 22 12 22C11.4696 22 10.9609 21.7366 10.5858 21.2678C10.2107 20.7989 10 20.163 10 19.5L14 19.5Z"
19
+ fill="currentColor"
20
+ />
21
+ <path d="M10 4C10 2.89543 10.8954 2 12 2C13.1046 2 14 2.89543 14 4V5H10V4Z" fill="currentColor" />
22
+ <path d="M5 11C5 7.13401 8.13401 4 12 4C15.866 4 19 7.13401 19 11V17H5V11Z" fill="currentColor" />
23
+ <rect x="3" y="15.5" width="18" height="2.5" rx="1.25" fill="currentColor" />
24
+ </svg>
25
+ );
26
+ };
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+
3
+ import { IconProps } from "./types/IconProps.type";
4
+
5
+ export const ChartIcon = (props: IconProps): JSX.Element => {
6
+ return (
7
+ <svg
8
+ className={props.className}
9
+ width="24"
10
+ height="24"
11
+ viewBox="0 0 24 24"
12
+ fill="none"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ >
15
+ <rect x="2" y="7" width="5" height="15" rx="2.5" fill="currentColor" />
16
+ <rect x="9" y="3" width="5" height="19" rx="2.5" fill="currentColor" />
17
+ <rect x="16" y="10" width="5" height="12" rx="2.5" fill="currentColor" />
18
+ </svg>
19
+ );
20
+ };
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+
3
+ export interface IconProps {
4
+ className?: string;
5
+ }
6
+
7
+ export const ChatBox = (props: IconProps): JSX.Element => {
8
+ return (
9
+ <svg
10
+ width="20"
11
+ className={props.className}
12
+ height="19"
13
+ viewBox="0 0 20 19"
14
+ fill="none"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ >
17
+ <path
18
+ d="M18 0H2C0.9 0 0 0.9 0 2V17.59C0 18.48 1.08 18.93 1.71 18.3L4 16H18C19.1 16 20 15.1 20 14V2C20 0.9 19.1 0 18 0ZM11.57 9.57L10.45 12.01C10.27 12.4 9.72 12.4 9.54 12.01L8.42 9.57L5.98 8.45C5.59 8.27 5.59 7.72 5.98 7.54L8.42 6.42L9.54 3.98C9.72 3.59 10.27 3.59 10.45 3.98L11.57 6.42L14.01 7.54C14.4 7.72 14.4 8.27 14.01 8.45L11.57 9.57Z"
19
+ fill="currentColor"
20
+ />
21
+ </svg>
22
+ );
23
+ };
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+
3
+ import { IconProps } from "./GroupIcon";
4
+
5
+ export const CheckIcon = (props: IconProps): JSX.Element => {
6
+ return (
7
+ <svg
8
+ className={props.className}
9
+ width="24"
10
+ height="24"
11
+ viewBox="0 0 24 24"
12
+ fill="none"
13
+ xmlns="http://www.w3.org/2000/svg"
14
+ >
15
+ <path
16
+ fillRule="evenodd"
17
+ clipRule="evenodd"
18
+ d="M18.7071 7.29289C19.0976 7.68342 19.0976 8.31658 18.7071 8.70711L10.7071 16.7071C10.3166 17.0976 9.68342 17.0976 9.29289 16.7071L5.29289 12.7071C4.90237 12.3166 4.90237 11.6834 5.29289 11.2929C5.68342 10.9024 6.31658 10.9024 6.70711 11.2929L10 14.5858L17.2929 7.29289C17.6834 6.90237 18.3166 6.90237 18.7071 7.29289Z"
19
+ fill="currentColor"
20
+ />
21
+ </svg>
22
+ );
23
+ };