@luscii-healthtech/web-ui 2.9.0 → 2.10.2

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 (287) hide show
  1. package/dist/components/Avatar/Avatar.d.ts +11 -11
  2. package/dist/components/CenteredHero/CenteredHero.d.ts +1 -1
  3. package/dist/components/Container/types/FlexContainerProps.type.d.ts +3 -2
  4. package/dist/components/Datepicker/Datepicker.d.ts +12 -11
  5. package/dist/components/Dropdown/Dropdown.d.ts +17 -7
  6. package/dist/components/ErrorBlock/ErrorBlock.d.ts +3 -3
  7. package/dist/components/Form/form.transformer.d.ts +3 -20
  8. package/dist/components/Form/form.types.d.ts +5 -5
  9. package/dist/components/InfoBlock/InfoBlock.d.ts +4 -4
  10. package/dist/components/Input/SearchInput.d.ts +1 -1
  11. package/dist/components/Line/Line.d.ts +4 -4
  12. package/dist/components/Menu/Menu.d.ts +6 -0
  13. package/dist/components/MultiSelect/MultiSelect.d.ts +7 -7
  14. package/dist/components/Page/CRUDPage.d.ts +13 -13
  15. package/dist/components/Page/Page.d.ts +13 -13
  16. package/dist/components/PaginationMenu/PaginationMenu.utils.d.ts +1 -1
  17. package/dist/components/Radio/Radio.d.ts +5 -1
  18. package/dist/components/RadioGroup/RadioGroup.d.ts +9 -10
  19. package/dist/components/Select/LegacySelect.d.ts +8 -9
  20. package/dist/components/Select/SelectV2.d.ts +1 -1
  21. package/dist/components/Switcher/Switcher.d.ts +6 -6
  22. package/dist/components/Switcher/SwitcherItem.d.ts +7 -7
  23. package/dist/components/Text/LegacyText.d.ts +18 -18
  24. package/dist/components/TextEditor/TextEditor.d.ts +4 -4
  25. package/dist/components/Textarea/Textarea.d.ts +16 -16
  26. package/dist/components/Title/LegacyTitle.d.ts +10 -10
  27. package/dist/web-ui-tailwind.css +8 -0
  28. package/dist/web-ui.cjs.development.js +81 -74
  29. package/dist/web-ui.cjs.development.js.map +1 -1
  30. package/dist/web-ui.cjs.production.min.js +1 -1
  31. package/dist/web-ui.cjs.production.min.js.map +1 -1
  32. package/dist/web-ui.esm.js +81 -74
  33. package/dist/web-ui.esm.js.map +1 -1
  34. package/package.json +7 -3
  35. package/src/assets/add.svg +0 -5
  36. package/src/assets/add_hover.svg +0 -4
  37. package/src/assets/arrow-down-icon.svg +0 -3
  38. package/src/assets/big-menu-icon-hover.svg +0 -6
  39. package/src/assets/big-menu-icon.svg +0 -6
  40. package/src/assets/check-cross-icon.svg +0 -7
  41. package/src/assets/check-icon-primary.svg +0 -5
  42. package/src/assets/check-icon.svg +0 -3
  43. package/src/assets/chevron-double.svg +0 -3
  44. package/src/assets/close.svg +0 -3
  45. package/src/assets/color-variant-cross.svg +0 -3
  46. package/src/assets/cross-dark.svg +0 -3
  47. package/src/assets/delete.svg +0 -4
  48. package/src/assets/delete_hover.svg +0 -4
  49. package/src/assets/edit.svg +0 -6
  50. package/src/assets/edit_hover.svg +0 -6
  51. package/src/assets/error-icon.svg +0 -7
  52. package/src/assets/grid-view-icon-active.svg +0 -6
  53. package/src/assets/grid-view-icon.svg +0 -6
  54. package/src/assets/groups.svg +0 -3
  55. package/src/assets/hamburger.svg +0 -5
  56. package/src/assets/happy-star.svg +0 -9
  57. package/src/assets/hcps.svg +0 -3
  58. package/src/assets/indeterminate-icon.svg +0 -3
  59. package/src/assets/info-icon.svg +0 -6
  60. package/src/assets/left-arrow-blue.svg +0 -3
  61. package/src/assets/left-arrow-grey.svg +0 -3
  62. package/src/assets/list-view-icon-active.svg +0 -3
  63. package/src/assets/list-view-icon.svg +0 -3
  64. package/src/assets/loading.svg +0 -16
  65. package/src/assets/modal-close-icon-active.svg +0 -9
  66. package/src/assets/modal-close-icon.svg +0 -9
  67. package/src/assets/no-open-alerts.svg +0 -19
  68. package/src/assets/patients.svg +0 -3
  69. package/src/assets/phone-mockup.svg +0 -9
  70. package/src/assets/programs.svg +0 -3
  71. package/src/assets/right-arrow-blue.svg +0 -3
  72. package/src/assets/right-arrow-grey.svg +0 -3
  73. package/src/assets/search-cancel.svg +0 -3
  74. package/src/assets/search-not-found.svg +0 -70
  75. package/src/assets/search.svg +0 -3
  76. package/src/assets/spinner-gray.svg +0 -6
  77. package/src/assets/spinner.svg +0 -5
  78. package/src/assets/starIcon.svg +0 -3
  79. package/src/assets/success-icon.svg +0 -6
  80. package/src/components/Accordion/Accordion.tsx +0 -33
  81. package/src/components/Accordion/AccordionItem.tsx +0 -50
  82. package/src/components/Avatar/Avatar.js +0 -81
  83. package/src/components/Avatar/Avatar.scss +0 -153
  84. package/src/components/Badge/Badge.tsx +0 -23
  85. package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -46
  86. package/src/components/Button/Button.examples.md +0 -46
  87. package/src/components/Button/Button.tsx +0 -200
  88. package/src/components/Button/Button.types.ts +0 -41
  89. package/src/components/Button/ButtonIcon.tsx +0 -42
  90. package/src/components/ButtonV2/ButtonProps.type.ts +0 -44
  91. package/src/components/ButtonV2/ButtonV2.tsx +0 -97
  92. package/src/components/ButtonV2/PrimaryButton.tsx +0 -25
  93. package/src/components/ButtonV2/SecondaryButton.tsx +0 -26
  94. package/src/components/ButtonV2/TertiaryButton.tsx +0 -26
  95. package/src/components/Carousel/Carousel.tsx +0 -52
  96. package/src/components/Carousel/GliderContainer.scss +0 -13
  97. package/src/components/Carousel/GliderContainer.tsx +0 -22
  98. package/src/components/CenteredHero/CenteredHero.tsx +0 -63
  99. package/src/components/CheckBoxListModal/CheckboxListModal.tsx +0 -180
  100. package/src/components/Checkbox/Checkbox.scss +0 -125
  101. package/src/components/Checkbox/Checkbox.tsx +0 -147
  102. package/src/components/CheckboxList/CheckboxGroup.tsx +0 -120
  103. package/src/components/CheckboxList/CheckboxList.tsx +0 -46
  104. package/src/components/CheckboxList/CheckboxList.types.ts +0 -47
  105. package/src/components/CheckboxList/CheckboxListItem.tsx +0 -54
  106. package/src/components/ConfirmationDialog/ConfirmationDialog.scss +0 -15
  107. package/src/components/ConfirmationDialog/ConfirmationDialog.tsx +0 -84
  108. package/src/components/Container/FlexColumn.tsx +0 -18
  109. package/src/components/Container/FlexContainer.tsx +0 -46
  110. package/src/components/Container/FlexRow.tsx +0 -18
  111. package/src/components/Container/types/FlexContainerProps.type.ts +0 -18
  112. package/src/components/Datepicker/Datepicker.js +0 -96
  113. package/src/components/Datepicker/Datepicker.scss +0 -332
  114. package/src/components/Dropdown/Dropdown.js +0 -416
  115. package/src/components/Dropdown/Dropdown.scss +0 -83
  116. package/src/components/EmptyListMessage/EmptyListMessage.tsx +0 -34
  117. package/src/components/ErrorBlock/ErrorBlock.js +0 -24
  118. package/src/components/ErrorBlock/ErrorBlock.scss +0 -20
  119. package/src/components/Form/Form.tsx +0 -138
  120. package/src/components/Form/FormFieldDecorator.tsx +0 -66
  121. package/src/components/Form/FormInput.tsx +0 -47
  122. package/src/components/Form/FormRadioGroup.tsx +0 -23
  123. package/src/components/Form/FormSelect.tsx +0 -32
  124. package/src/components/Form/form.transformer.ts +0 -9
  125. package/src/components/Form/form.types.ts +0 -139
  126. package/src/components/Icons/AddIcon.tsx +0 -29
  127. package/src/components/Icons/AlertsIcon.tsx +0 -39
  128. package/src/components/Icons/BellIcon.tsx +0 -39
  129. package/src/components/Icons/ChartIcon.tsx +0 -22
  130. package/src/components/Icons/ChatBoxIcon.tsx +0 -23
  131. package/src/components/Icons/CheckIcon.tsx +0 -26
  132. package/src/components/Icons/ChevronDoubleIcon.tsx +0 -25
  133. package/src/components/Icons/ChevronDownIcon.tsx +0 -20
  134. package/src/components/Icons/ChevronRightIcon.tsx +0 -20
  135. package/src/components/Icons/CrossIcon.tsx +0 -24
  136. package/src/components/Icons/DeleteIcon.tsx +0 -23
  137. package/src/components/Icons/DownArrowIcon.tsx +0 -23
  138. package/src/components/Icons/DragIcon.tsx +0 -25
  139. package/src/components/Icons/DynamicIcon.tsx +0 -25
  140. package/src/components/Icons/EditIcon.tsx +0 -23
  141. package/src/components/Icons/EmptyIcon.tsx +0 -29
  142. package/src/components/Icons/EmptyStateDashboardIcon.tsx +0 -130
  143. package/src/components/Icons/ExclamationMarkIcon.tsx +0 -23
  144. package/src/components/Icons/EyeIcon.tsx +0 -23
  145. package/src/components/Icons/GearIcon.tsx +0 -23
  146. package/src/components/Icons/GroupIcon.tsx +0 -23
  147. package/src/components/Icons/HamburgerIcon.tsx +0 -31
  148. package/src/components/Icons/HeartIcon.tsx +0 -23
  149. package/src/components/Icons/ImageIcon.tsx +0 -23
  150. package/src/components/Icons/LeftArrowIcon.tsx +0 -23
  151. package/src/components/Icons/LightBulbIcon.tsx +0 -31
  152. package/src/components/Icons/LockIcon.tsx +0 -23
  153. package/src/components/Icons/MessagesIcon.tsx +0 -23
  154. package/src/components/Icons/NotesIcon.tsx +0 -23
  155. package/src/components/Icons/PinIcon.tsx +0 -23
  156. package/src/components/Icons/PrintIcon.tsx +0 -22
  157. package/src/components/Icons/RightArrowIcon.tsx +0 -23
  158. package/src/components/Icons/SearchCancelIcon.tsx +0 -23
  159. package/src/components/Icons/SearchIcon.tsx +0 -23
  160. package/src/components/Icons/SmallCircleIcon.tsx +0 -21
  161. package/src/components/Icons/SmallDiamondIcon.tsx +0 -31
  162. package/src/components/Icons/SmallSquareIcon.tsx +0 -21
  163. package/src/components/Icons/SpaceRocketIcon.tsx +0 -23
  164. package/src/components/Icons/StarIcon.tsx +0 -23
  165. package/src/components/Icons/WarningIcon.tsx +0 -24
  166. package/src/components/Icons/types/IconProps.type.ts +0 -5
  167. package/src/components/InfoBlock/InfoBlock.js +0 -24
  168. package/src/components/InfoBlock/InfoBlock.scss +0 -20
  169. package/src/components/InfoField/InfoField.tsx +0 -94
  170. package/src/components/Input/Input.css +0 -3
  171. package/src/components/Input/Input.tsx +0 -211
  172. package/src/components/Input/SearchInput.tsx +0 -24
  173. package/src/components/Line/Line.js +0 -38
  174. package/src/components/List/List.scss +0 -23
  175. package/src/components/List/List.tsx +0 -138
  176. package/src/components/List/List.types.ts +0 -41
  177. package/src/components/List/ListItem.tsx +0 -89
  178. package/src/components/List/ListItemSkeleton.tsx +0 -26
  179. package/src/components/List/ListSkeleton.scss +0 -5
  180. package/src/components/List/ListSkeleton.tsx +0 -30
  181. package/src/components/LoadingIndicator/LoadingIndicator.scss +0 -50
  182. package/src/components/LoadingIndicator/LoadingIndicator.tsx +0 -46
  183. package/src/components/Menu/Menu.js +0 -74
  184. package/src/components/Menu/Menu.scss +0 -27
  185. package/src/components/Modal/Modal.scss +0 -117
  186. package/src/components/Modal/Modal.tsx +0 -104
  187. package/src/components/Modal/ModalWithButtons.tsx +0 -34
  188. package/src/components/MultiSelect/MultiSelect.js +0 -117
  189. package/src/components/MultiSelect/MultiSelect.scss +0 -29
  190. package/src/components/MultiSelect/MultiSelectUtils.js +0 -23
  191. package/src/components/NavMenu/NavLayout.tsx +0 -40
  192. package/src/components/NavMenu/NavMenu.tsx +0 -39
  193. package/src/components/NavMenu/NavMenu.utils.ts +0 -6
  194. package/src/components/NavMenu/NavMenuContent.tsx +0 -23
  195. package/src/components/NavMenu/NavMenuItem.tsx +0 -102
  196. package/src/components/NotificationBanner/NotificationBanner.tsx +0 -104
  197. package/src/components/Page/CRUDPage.js +0 -123
  198. package/src/components/Page/CRUDPage.scss +0 -32
  199. package/src/components/Page/Page.js +0 -102
  200. package/src/components/Page/Page.scss +0 -59
  201. package/src/components/PageHeader/PageHeader.tsx +0 -51
  202. package/src/components/PaginationMenu/PaginationMenu.tsx +0 -47
  203. package/src/components/PaginationMenu/PaginationMenu.types.ts +0 -46
  204. package/src/components/PaginationMenu/PaginationMenu.utils.ts +0 -49
  205. package/src/components/PaginationMenu/PaginationMenuLarge.tsx +0 -96
  206. package/src/components/PaginationMenu/PaginationMenuSmall.tsx +0 -43
  207. package/src/components/PreviewPhone/PreviewPhone.tsx +0 -52
  208. package/src/components/PreviewPhone/useWindowDimensions.js +0 -26
  209. package/src/components/Radio/Radio.js +0 -102
  210. package/src/components/Radio/Radio.scss +0 -58
  211. package/src/components/Radio/RadioV2.css +0 -15
  212. package/src/components/Radio/RadioV2.tsx +0 -87
  213. package/src/components/RadioGroup/RadioGroup.js +0 -66
  214. package/src/components/RadioGroup/RadioGroup.scss +0 -37
  215. package/src/components/RadioGroup/RadioGroupV2.tsx +0 -35
  216. package/src/components/Section/Section.scss +0 -74
  217. package/src/components/Section/Section.tsx +0 -68
  218. package/src/components/Section/SectionItem.scss +0 -20
  219. package/src/components/Section/SectionItem.tsx +0 -26
  220. package/src/components/Section/SectionItemWithContent.tsx +0 -30
  221. package/src/components/Select/LegacySelect.js +0 -114
  222. package/src/components/Select/Select.scss +0 -29
  223. package/src/components/Select/Select.tsx +0 -151
  224. package/src/components/Select/SelectV2.tsx +0 -171
  225. package/src/components/Select/options.transformer.ts +0 -36
  226. package/src/components/Select/select.utils.spec.ts +0 -63
  227. package/src/components/Select/select.utils.ts +0 -45
  228. package/src/components/SettingsMenuButton/SettingsMenuButton.tsx +0 -111
  229. package/src/components/Spinner/Spinner.tsx +0 -23
  230. package/src/components/Steps/Step.tsx +0 -31
  231. package/src/components/Steps/Steps.tsx +0 -24
  232. package/src/components/Switcher/Switcher.js +0 -58
  233. package/src/components/Switcher/SwitcherItem.js +0 -61
  234. package/src/components/Switcher/SwitcherItem.scss +0 -67
  235. package/src/components/TabLinks/TabLinks.tsx +0 -63
  236. package/src/components/Tabbar/Tabbar.tsx +0 -60
  237. package/src/components/Tabbar/TabbarItem.tsx +0 -66
  238. package/src/components/Table/Table.tsx +0 -91
  239. package/src/components/Table/Table.types.ts +0 -28
  240. package/src/components/Table/Table.utils.ts +0 -23
  241. package/src/components/Table/TableBody.tsx +0 -57
  242. package/src/components/Table/TableBodyRow.tsx +0 -47
  243. package/src/components/Table/TableBodyRowDataCell.tsx +0 -76
  244. package/src/components/Table/TableFooter.tsx +0 -21
  245. package/src/components/Table/TableHeader.tsx +0 -28
  246. package/src/components/Tag/Tag.tsx +0 -58
  247. package/src/components/Tag/Tag.utils.ts +0 -4
  248. package/src/components/Tag/TagGroup.tsx +0 -29
  249. package/src/components/Text/LegacyText.js +0 -78
  250. package/src/components/Text/Text.scss +0 -67
  251. package/src/components/Text/Text.tsx +0 -131
  252. package/src/components/TextEditor/TextEditor.js +0 -61
  253. package/src/components/TextEditor/TextEditor.scss +0 -14
  254. package/src/components/TextEditorV2/TextEditorV2.js +0 -52
  255. package/src/components/TextEditorV2/TextEditorV2.scss +0 -110
  256. package/src/components/TextLink/TextLink.tsx +0 -42
  257. package/src/components/Textarea/Textarea.js +0 -108
  258. package/src/components/Textarea/Textarea.scss +0 -56
  259. package/src/components/Timeline/Timeline.tsx +0 -28
  260. package/src/components/Timeline/TimelineStep.tsx +0 -36
  261. package/src/components/Title/LegacyTitle.js +0 -64
  262. package/src/components/Title/Title.scss +0 -6
  263. package/src/components/Title/Title.tsx +0 -62
  264. package/src/components/Toaster/Toaster.scss +0 -57
  265. package/src/components/Toaster/Toaster.tsx +0 -100
  266. package/src/components/Toaster/toast-elements-getter.ts +0 -72
  267. package/src/components/Toaster/toast-progress-animator.ts +0 -53
  268. package/src/components/Toaster/toast.ts +0 -112
  269. package/src/components/ViewItem/ViewItem.tsx +0 -85
  270. package/src/custom.d.ts +0 -4
  271. package/src/index.tsx +0 -170
  272. package/src/styles/_colors.scss +0 -59
  273. package/src/styles/_layout.scss +0 -64
  274. package/src/styles/_shadows.scss +0 -19
  275. package/src/styles/_skeleton.scss +0 -63
  276. package/src/styles/_typography.scss +0 -8
  277. package/src/styles/_utils.scss +0 -45
  278. package/src/styles/fonts/avenir/3A0AF8_0_0.eot +0 -0
  279. package/src/styles/fonts/avenir/3A0AF8_0_0.ttf +0 -0
  280. package/src/styles/fonts/avenir/3A0AF8_0_0.woff +0 -0
  281. package/src/styles/fonts/avenir/3A0AF8_0_0.woff2 +0 -0
  282. package/src/styles/fonts/avenir/3A0AF8_1_0.eot +0 -0
  283. package/src/styles/fonts/avenir/3A0AF8_1_0.ttf +0 -0
  284. package/src/styles/fonts/avenir/3A0AF8_1_0.woff +0 -0
  285. package/src/styles/fonts/avenir/3A0AF8_1_0.woff2 +0 -0
  286. package/src/types/general.types.ts +0 -11
  287. package/src/utils/useOutsideClick.js +0 -19
@@ -1,30 +0,0 @@
1
- import React from "react";
2
- import classNames from "classnames";
3
-
4
- import Text from "../Text/Text";
5
-
6
- import SectionItem, { SectionItemProps } from "./SectionItem";
7
-
8
- interface SectionItemWithContentProps extends Omit<SectionItemProps, "children"> {
9
- text: string;
10
- icon?: string;
11
- iconClass?: string;
12
- }
13
-
14
- function SectionItemWithContent(
15
- props: SectionItemWithContentProps
16
- ): JSX.Element {
17
- const { text, icon, className, iconClass, onClick, ...rest } = props;
18
-
19
- const mergedClasses = classNames("cweb-section-text-item", className);
20
- const iconClasses = classNames("w-6 h-6 mr-4", iconClass);
21
-
22
- return (
23
- <SectionItem className={mergedClasses} onClick={onClick} {...rest}>
24
- {icon && <img className={iconClasses} src={icon} alt="" />}
25
- <Text text={text} />
26
- </SectionItem>
27
- );
28
- }
29
-
30
- export default SectionItemWithContent;
@@ -1,114 +0,0 @@
1
- import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
- import PropTypes from "prop-types";
3
- import { components } from "react-select";
4
- import classNames from "classnames";
5
-
6
- import { findValue } from "./select.utils";
7
- import Select from "./Select";
8
-
9
- LegacySelect.propTypes = {
10
- className: PropTypes.string,
11
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
12
- name: PropTypes.string.isRequired,
13
- placeholder: PropTypes.string,
14
- options: PropTypes.arrayOf(
15
- PropTypes.shape({
16
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
17
- text: PropTypes.string.isRequired,
18
- disabled: PropTypes.bool,
19
- })
20
- ).isRequired,
21
- onChange: PropTypes.func.isRequired,
22
- };
23
-
24
- /**
25
- * For legacy purposes this functional component behaves a certain manner that is expected by Forms that still use it.
26
- * @deprecated use Select instead
27
- */
28
- function LegacySelect({
29
- className,
30
- value,
31
- name,
32
- placeholder = "Placeholder text",
33
- options,
34
- onChange,
35
- isDisabled = false,
36
- isSearchable = false,
37
- ...otherProps
38
- }) {
39
- const transformedOptions = useMemo(() => options.map((option) => ({ label: option.text, ...option })), [options]);
40
- const selectRef = useRef(null);
41
-
42
- const [innerValue, setInnerValue] = useState(findValue(value, transformedOptions));
43
-
44
- useEffect(() => {
45
- if (value !== innerValue?.value) {
46
- // there is a change triggered from the parents
47
- setInnerValue(findValue(value, transformedOptions));
48
- }
49
- }, [value, transformedOptions]);
50
-
51
- // Why: https://github.com/JedWatson/react-select/issues/3149
52
- const getDataAttributes = () => {
53
- const dataProps = {};
54
-
55
- for (const prop in otherProps) {
56
- if (prop.includes("data-")) {
57
- dataProps[prop] = otherProps[prop];
58
- }
59
- }
60
-
61
- return dataProps;
62
- };
63
-
64
- const CustomContainer = (commonProps) => (
65
- <components.SelectContainer
66
- {...commonProps}
67
- innerProps={Object.assign({}, commonProps.innerProps, {
68
- ...getDataAttributes(),
69
- })}
70
- />
71
- );
72
-
73
- const handleChange = useCallback(
74
- (changedValue) => {
75
- setInnerValue(changedValue);
76
- const { value: extractedValue, ...rest } = changedValue;
77
- // all components in the app expect this select to behave as
78
- // a html select so we need to pass a lookalike object in the callback
79
- onChange &&
80
- onChange({
81
- // making sure no legacy implementation breaks
82
- preventDefault: () => undefined,
83
- target: { name, value: extractedValue, ...rest },
84
- currentTarget: { name, value: extractedValue, ...rest },
85
- });
86
-
87
- selectRef.current?.blur();
88
- },
89
- [setInnerValue, onChange]
90
- );
91
-
92
- const containerClassName = classNames("cweb-select h-11", className);
93
-
94
- // We can easily transform it here, because all forms expect this to be a normal html select.
95
-
96
- return (
97
- <Select
98
- {...otherProps}
99
- ref={selectRef}
100
- className={containerClassName}
101
- name={name}
102
- isDisabled={isDisabled}
103
- value={innerValue}
104
- onChange={handleChange}
105
- placeholder={placeholder}
106
- options={transformedOptions}
107
- isOptionDisabled={(option) => option.disabled}
108
- components={{ SelectContainer: CustomContainer }}
109
- isSearchable={isSearchable}
110
- />
111
- );
112
- }
113
-
114
- export default LegacySelect;
@@ -1,29 +0,0 @@
1
- .customized-select {
2
- // postcss-url cannot make sense of the inline styles in emotion, so we need to
3
- // extract the background customization to a css file
4
- [class*="IndicatorsContainer"] {
5
- background: url(../../assets/chevron-double.svg) no-repeat center;
6
- opacity: 0.5;
7
- transition: opacity 0.3s ease-in-out;
8
- // hiding the default indicator
9
- svg {
10
- display: none;
11
- }
12
-
13
- margin-right: 0.75rem;
14
- }
15
-
16
- [class*="MenuList"] {
17
- [class*="option"]::after {
18
- position: absolute;
19
- content: "";
20
- background: url(../../assets/check-icon-primary.svg) no-repeat center;
21
- // This needs to match the proportional
22
- // padding in this element.
23
- // 0.75rem -> 12px
24
- right: 12px;
25
- height: 1rem;
26
- width: 1rem;
27
- }
28
- }
29
- }
@@ -1,151 +0,0 @@
1
- import type { Props, StylesConfig, GroupBase } from "react-select";
2
- import ReactSelect, { mergeStyles, SelectInstance } from "react-select";
3
- import React, { Ref } from "react";
4
- import classNames from "classnames";
5
- import Select from "react-select/base";
6
-
7
- /**
8
- * Exceptional case for this file:
9
- * We use postcss-url to inline and base64 our image assets.
10
- * But the library can only see as far as css files.
11
- * When javascript gets in the way (react-select uses a package called `emotion` for styles), postcss-url cannot
12
- * bundle the svg assets used here, and we end up with some broken style.
13
- */
14
- import "./Select.scss";
15
-
16
- function generateCustomStyles<
17
- Option,
18
- IsMulti extends boolean,
19
- Group extends GroupBase<Option>
20
- >(hasError: boolean, isIE11: boolean): StylesConfig<Option, IsMulti, Group> {
21
- return {
22
- option: (baseStyles, state) => {
23
- return {
24
- ...baseStyles,
25
- fontWeight: state.isSelected ? "bold" : "normal",
26
- fontSize: "14px",
27
- backgroundColor: "none",
28
- color: "inherit",
29
- position: "relative",
30
- padding: "0.75rem",
31
- opacity: state.isDisabled ? "0.5" : 1,
32
- transition: "background-color 0.3s ease-in-out",
33
- "&:hover": {
34
- // tailwind blue-50
35
- backgroundColor: state.isSelected ? "transparent" : "#F2FAFD",
36
- },
37
- // The static styles of this pseudo-element is in ./Select.scss
38
- "&:after": {
39
- visibility: state.isSelected ? "visible" : "hidden",
40
- },
41
- pointerEvents: state.isDisabled ? "none" : "auto",
42
- };
43
- },
44
- container: (baseStyles) => {
45
- return { ...baseStyles, flexGrow: isIE11 ? 0.5 : "initial" };
46
- },
47
- control: (baseStyles, state) => {
48
- const defaultBorderColor = state.isFocused ? "#045baa" : "#D1D5DB";
49
- const validatedBorderColor = hasError ? "#c53030" : defaultBorderColor;
50
-
51
- const defaultOutline = hasError
52
- ? "rgba(255, 98, 102, 0.3)"
53
- : "rgba(0, 159, 227, 0.3)";
54
- const validatedOutline = `4px solid ${
55
- state.isFocused ? defaultOutline : "transparent"
56
- }`;
57
-
58
- return {
59
- ...baseStyles,
60
- fontSize: "14px",
61
- transition: "border 0.3s ease-in-out",
62
- height: isIE11 ? "50px" : "2.75rem",
63
-
64
- // primary outline
65
- outline: validatedOutline,
66
-
67
- borderColor: validatedBorderColor,
68
- borderWidth: "1px !important",
69
- borderStyle: "solid",
70
- borderRadius: "4px",
71
-
72
- boxShadow: "0px 1px 2px rgba(0, 0, 0, 0.05)",
73
-
74
- "&:hover": {
75
- borderColor: "#9CA3AF",
76
- // selector for the chevron
77
- '> [class*="IndicatorsContainer"]': {
78
- opacity: 1,
79
- },
80
- },
81
- };
82
- },
83
- // The placeholder has the following css prop: grid-area: 1/1/2/3;
84
- // And grid-area doesn't work on IE11, so we need to style it slightly different.
85
- placeholder: (baseStyles) => ({
86
- ...baseStyles,
87
- fontWeight: 100,
88
- color: "#6B7280",
89
- paddingTop: isIE11 ? "1.2rem" : undefined,
90
- }),
91
- singleValue: (baseStyles) => {
92
- return {
93
- ...baseStyles,
94
- paddingTop: isIE11 ? "1.2rem" : undefined,
95
- fontSize: "14px",
96
- };
97
- },
98
- indicatorSeparator: () => ({
99
- display: "none",
100
- }),
101
- // The indicatorContainer styles is added via the `Select.scss` file.
102
- menu: (baseStyles) => ({
103
- ...baseStyles,
104
- zIndex: 20,
105
- }),
106
- };
107
- }
108
-
109
- type CustomSelect = <
110
- Option,
111
- IsMulti extends boolean,
112
- Group extends GroupBase<Option>
113
- >(
114
- props: Props<Option, IsMulti, Group>,
115
- ref: React.RefAttributes<SelectInstance<Option, IsMulti, Group>>
116
- ) => React.ReactElement;
117
-
118
- /**
119
- * @deprecated: use SelectV2 instead
120
- */
121
- const CustomSelect = React.forwardRef(
122
- <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
123
- props: Props<Option, IsMulti, Group>,
124
- ref: Ref<Select<Option, IsMulti, Group>>
125
- ) => {
126
- const { className, styles } = props;
127
-
128
- const hasError = className?.includes("has-error") || false;
129
- const isIE11 =
130
- "MSInputMethodContext" in window && "documentMode" in document;
131
- const customStyles = generateCustomStyles<Option, IsMulti, Group>(
132
- hasError,
133
- isIE11
134
- );
135
- const mergedStyles = mergeStyles<Option, IsMulti, Group>(
136
- customStyles,
137
- styles
138
- );
139
-
140
- return (
141
- <ReactSelect<Option, IsMulti, Group>
142
- {...props}
143
- ref={ref}
144
- className={classNames("customized-select", className)}
145
- styles={mergedStyles}
146
- />
147
- );
148
- }
149
- ) as CustomSelect;
150
-
151
- export default CustomSelect;
@@ -1,171 +0,0 @@
1
- import type {
2
- MultiValue,
3
- OptionsOrGroups,
4
- Props,
5
- StylesConfig,
6
- GroupBase, Options,
7
- } from "react-select";
8
- import ReactSelect, { mergeStyles } from "react-select";
9
- import React from "react";
10
- import classNames from "classnames";
11
-
12
-
13
-
14
- /**
15
- * Exceptional case for this file:
16
- * We use postcss-url to inline and base64 our image assets.
17
- * But the library can only see as far as css files.
18
- * When javascript gets in the way (react-select uses a package called `emotion` for styles), postcss-url cannot
19
- * bundle the svg assets used here, and we end up with some broken style.
20
- */
21
- import "./Select.scss";
22
-
23
- function generateCustomStyles<Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
24
- hasError: boolean,
25
- isIE11: boolean,
26
- ): StylesConfig<Option, IsMulti, Group> {
27
- return {
28
- option: (baseStyles, state) => {
29
- return {
30
- ...baseStyles,
31
- fontWeight: state.isSelected ? "bold" : "normal",
32
- fontSize: "14px",
33
- backgroundColor: "none",
34
- color: "inherit",
35
- position: "relative",
36
- padding: "0.75rem",
37
- opacity: state.isDisabled ? "0.5" : 1,
38
- "&:after": {
39
- visibility: state.isSelected ? "visible" : "hidden",
40
- },
41
- transition: "background-color 0.3s ease-in-out",
42
- "&:hover": {
43
- // tailwind blue-50
44
- backgroundColor: state.isSelected ? "transparent" : "#F2FAFD",
45
- },
46
- pointerEvents: state.isDisabled ? "none" : "auto",
47
- };
48
- },
49
- container: (baseStyles) => {
50
- return { ...baseStyles, flexGrow: isIE11 ? 0.5 : "initial" };
51
- },
52
- control: (baseStyles, state) => {
53
- const defaultBorderColor = state.isFocused ? "#045baa" : "#D1D5DB";
54
- const validatedBorderColor = hasError ? "#c53030" : defaultBorderColor;
55
-
56
- const defaultOutline = hasError ? "rgba(255, 98, 102, 0.3)" : "rgba(0, 159, 227, 0.3)";
57
- const validatedOutline = `4px solid ${state.isFocused ? defaultOutline : "transparent"}`;
58
-
59
- return {
60
- ...baseStyles,
61
- fontSize: "14px",
62
- transition: "border 0.3s ease-in-out",
63
- height: isIE11 ? "50px" : "2.75rem",
64
-
65
- // primary outline
66
- outline: validatedOutline,
67
-
68
- borderColor: validatedBorderColor,
69
- borderWidth: "1px !important",
70
- borderStyle: "solid",
71
- borderRadius: "4px",
72
-
73
- boxShadow: "0px 1px 2px rgba(0, 0, 0, 0.05)",
74
-
75
- "&:hover": {
76
- borderColor: "#9CA3AF",
77
- // selector for the chevron
78
- "> [class*=\"IndicatorsContainer\"]": {
79
- opacity: 1,
80
- },
81
- },
82
- };
83
- },
84
- // The placeholder has the following css prop: grid-area: 1/1/2/3;
85
- // And grid-area doesn't work on IE11, so we need to style it slightly different.
86
- placeholder: (baseStyles) => ({
87
- ...baseStyles,
88
- fontWeight: 100,
89
- color: "#6B7280",
90
- paddingTop: isIE11 ? "1.2rem" : undefined,
91
- }),
92
- singleValue: (baseStyles) => {
93
- return {
94
- ...baseStyles,
95
- paddingTop: isIE11 ? "1.2rem" : undefined,
96
- fontSize: "14px",
97
- };
98
- },
99
- indicatorSeparator: () => ({
100
- display: "none",
101
- }),
102
- menu: (baseStyles) => ({
103
- ...baseStyles,
104
- zIndex: 20,
105
- }),
106
- };
107
- }
108
-
109
- // All the options require a value to work in the wrapper
110
- interface OptionMinimal {
111
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
- value: any;
113
- label?: string;
114
- }
115
-
116
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
- export interface SelectProps<Option extends OptionMinimal = OptionMinimal, IsMulti extends boolean = any, Group extends GroupBase<Option> = GroupBase<Option>> extends Props<Option, IsMulti, Group> {
118
- isError?: boolean;
119
- }
120
-
121
- /**
122
- * A wrapper around react-select to style it according to our design specification.
123
- *
124
- * In addition, the value is taken out of the option, instead of returning the complete option.
125
- *
126
- * Care when using grouped options: the value of the options overspanning all groups need to be unique!
127
- * For instance, if you have an option with value "chocolate" in both the groups "flavor" and "dip", then you get unforeseen errors.
128
- * This is a problem within react-select itself, not our wrapper.
129
- *
130
- * Care when using defaultValue: this still requires the complete Option (instead of the value of the Option).
131
- * So far there wasn't a use-case for this.
132
- */
133
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
- export const Select = React.forwardRef(<Option extends OptionMinimal, IsMulti extends boolean, Group extends GroupBase<Option>>(
135
- { isError = false, styles, options, onChange, value, isMulti, className, ...otherProps }: SelectProps<Option, IsMulti, Group>,
136
- innerRef,
137
- ) => {
138
- const isIE11 = "MSInputMethodContext" in window && "documentMode" in document;
139
- const customStyles = generateCustomStyles<Option, IsMulti, Group>(isError, isIE11);
140
- const mergedStyles = mergeStyles<Option, IsMulti, Group>(customStyles, styles);
141
-
142
- // the options can be either a list of options or a grouped list of options
143
- // this is a typechecker to verify it is the case.
144
- const isOptionsGrouped = !options ? false : (options as OptionsOrGroups<Option, Group>)
145
- .reduce((acc, o) => acc || ("options" in o && !("values" in o)), false);
146
- // we subsequently flatmap to ensure it's always a list of options
147
- const flatmappedOptions = !options ? [] : isOptionsGrouped
148
- ? (options as Group[]).flatMap((g) => g.options)
149
- : options as Options<Option>;
150
-
151
- // based on: https://stackoverflow.com/a/70022957
152
- const onChangeWrapped = !onChange ? undefined : isMulti
153
- ? (val, a) => onChange(val.map((v) => v.value), a)
154
- : (val, a) => onChange(val?.value, a);
155
- // TODO: how can we report the error if a value was given that is not within the options?
156
- const valueWrapped = (!value || !options) ? value : isMulti
157
- ? flatmappedOptions.filter((o) => (value as MultiValue<Option>).includes(o.value))
158
- : flatmappedOptions.find((o) => o.value === value);
159
-
160
- return <ReactSelect
161
- {...otherProps}
162
- ref={innerRef}
163
- styles={mergedStyles}
164
- options={options}
165
- onChange={onChangeWrapped}
166
- value={valueWrapped}
167
- isMulti={isMulti}
168
- className={classNames("customized-select", className)}
169
- />;
170
- },
171
- );
@@ -1,36 +0,0 @@
1
- interface DropdownItem {
2
- id: string;
3
- text: string;
4
- key: string;
5
- type: string;
6
- }
7
-
8
- interface DropdownGroupedItem {
9
- groupKey: string;
10
- title: string;
11
- subItems: DropdownItem[];
12
- }
13
-
14
- export const transformSubitemToSelectOption = (subItem: DropdownItem): Record<string, unknown> => {
15
- return { ...subItem, label: subItem.text, value: subItem.id };
16
- };
17
-
18
- export const transformToSelectOptions = (
19
- items: Array<DropdownGroupedItem | DropdownItem>
20
- ): Array<Record<string, unknown>> => {
21
- const groupedItems = items
22
- .filter((option): option is DropdownGroupedItem => "groupKey" in option)
23
- .map((option) => ({
24
- label: option.title,
25
- options: option.subItems.map(transformSubitemToSelectOption),
26
- }));
27
-
28
- const singleItems = items
29
- .filter((option): option is DropdownItem => !("groupKey" in option))
30
- .map((option) => ({
31
- value: option.id,
32
- label: option.text,
33
- }));
34
-
35
- return [...singleItems, ...groupedItems];
36
- };
@@ -1,63 +0,0 @@
1
- import { findValue } from "./select.utils";
2
-
3
- describe("findValue", () => {
4
- const options: Record<string, string | number>[] = [
5
- {
6
- label: "Nausea - 018678f2-f5ab-401d-957e-b94db30347f3",
7
- text: "Nausea - 018678f2-f5ab-401d-957e-b94db30347f3",
8
- value: '{"type":"instrument","uuid":"018678f2-f5ab-401d-957e-b94db30347f3"}',
9
- },
10
- {
11
- label: "Pain - 34c30d2e-7e1e-4c13-b066-ebf4897debbf",
12
- text: "Pain - 34c30d2e-7e1e-4c13-b066-ebf4897debbf",
13
- value: '{"type":"instrument","uuid":"34c30d2e-7e1e-4c13-b066-ebf4897debbf"}',
14
- },
15
- {
16
- label: "Temperature - 38c85570-cc6e-41d8-aeb1-a84a11de6158",
17
- text: "Temperature - 38c85570-cc6e-41d8-aeb1-a84a11de6158",
18
- value: '{"type":"instrument","uuid":"38c85570-cc6e-41d8-aeb1-a84a11de6158"}',
19
- },
20
- {
21
- label: "Body Temperature - f712cc98-fb78-4f3d-b6b5-eb74cb95cb3e",
22
- text: "Body Temperature - f712cc98-fb78-4f3d-b6b5-eb74cb95cb3e",
23
- value: '{"type":"instrument","uuid":"f712cc98-fb78-4f3d-b6b5-eb74cb95cb3e"}',
24
- },
25
- ];
26
-
27
- it("can find a filled value", () => {
28
- const expected = options[0];
29
-
30
- expect(findValue('{"type":"instrument","uuid":"018678f2-f5ab-401d-957e-b94db30347f3"}', options)).toBe(expected);
31
- });
32
-
33
- it("if no value passed, it returns null", () => {
34
- expect(findValue(null, options)).toEqual(null);
35
- expect(findValue(undefined, options)).toEqual(null);
36
- });
37
-
38
- it("if value passed is empty but options have an empty value, it finds it", () => {
39
- const optionsWithEmpty = [...options];
40
- optionsWithEmpty.unshift({
41
- label: "-- None --",
42
- text: "-- None --",
43
- value: "",
44
- });
45
-
46
- const expected = optionsWithEmpty[0];
47
-
48
- expect(findValue("", optionsWithEmpty)).toEqual(expected);
49
- });
50
-
51
- it("if value passed is zero but options have a zero, it finds it", () => {
52
- const optionsWithZero = [...options];
53
- optionsWithZero.unshift({
54
- label: "-- None --",
55
- text: "-- None --",
56
- value: 0,
57
- });
58
-
59
- const expected = optionsWithZero[0];
60
-
61
- expect(findValue(0, optionsWithZero)).toEqual(expected);
62
- });
63
- });
@@ -1,45 +0,0 @@
1
- /**
2
- * This is specifically because of the workflow form, that uses a stringified object as a value.
3
- * @param valueParam The alleged object value
4
- * @returns true if value is indeed an object
5
- */
6
- const isValueObject = (valueParam: string | number) => {
7
- if (typeof valueParam === "number") {
8
- return false;
9
- }
10
-
11
- try {
12
- const allegedObject = JSON.parse(valueParam);
13
- return Object.keys(allegedObject).length > 0;
14
- } catch {
15
- // if the parsing breaks, it is probably not an object
16
- return false;
17
- }
18
- };
19
-
20
- /**
21
- * react-select needs an exact match of the object we are using in the options in order to know what has been set
22
- * that's why we have to filter it
23
- * @param {*} value - The value we need to set in the selector
24
- * @returns the object having the passed value
25
- */
26
- export const findValue = (value: any, options: any[]): any => {
27
- // There are values that can be found with "" or 0, and they
28
- // don't need to be evaluated as false in the check below
29
- if (value === null || value === undefined) {
30
- return null;
31
- }
32
-
33
- let foundValue = null;
34
-
35
- if (isValueObject(value)) {
36
- foundValue = options.find((option) => JSON.stringify(option.value) === JSON.stringify(value));
37
- return foundValue;
38
- }
39
-
40
- foundValue = options.find((option: any) => {
41
- return option.value?.toString() === value?.toString();
42
- });
43
-
44
- return foundValue;
45
- };