@oliasoft-open-source/react-ui-library 1.0.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 (317) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +125 -0
  3. package/.gitlab-ci.yml +45 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.prettierignore +3 -0
  6. package/.prettierrc +4 -0
  7. package/.storybook/main.js +36 -0
  8. package/.storybook/preview.js +40 -0
  9. package/.storybook/storybook.less +8 -0
  10. package/LICENSE +21 -0
  11. package/README.md +5 -0
  12. package/babel.config.js +31 -0
  13. package/index.js +76 -0
  14. package/jest.config.js +9 -0
  15. package/package.json +136 -0
  16. package/src/components/accordion/accordion.jsx +132 -0
  17. package/src/components/accordion/accordion.module.less +66 -0
  18. package/src/components/accordion/accordion.stories.jsx +171 -0
  19. package/src/components/accordion/chevron/chevron.jsx +12 -0
  20. package/src/components/accordion/chevron/chevron.module.less +12 -0
  21. package/src/components/accordion/helpers/accordion-with-default-toggle.jsx +106 -0
  22. package/src/components/accordion/helpers/accordion-with-default-toggle.module.less +24 -0
  23. package/src/components/actions/actions.jsx +129 -0
  24. package/src/components/actions/actions.module.less +44 -0
  25. package/src/components/actions/actions.shape.js +32 -0
  26. package/src/components/actions/actions.stories.jsx +79 -0
  27. package/src/components/badge/badge.jsx +58 -0
  28. package/src/components/badge/badge.module.less +55 -0
  29. package/src/components/badge/badge.stories.jsx +31 -0
  30. package/src/components/breadcrumb/breadcrumb.jsx +49 -0
  31. package/src/components/breadcrumb/breadcrumb.module.less +39 -0
  32. package/src/components/breadcrumb/breadcrumb.stories.jsx +45 -0
  33. package/src/components/breadcrumb/link.jsx +31 -0
  34. package/src/components/button/button.jsx +156 -0
  35. package/src/components/button/button.module.less +300 -0
  36. package/src/components/button/button.stories.jsx +74 -0
  37. package/src/components/button-group/button-group.jsx +140 -0
  38. package/src/components/button-group/button-group.module.less +24 -0
  39. package/src/components/button-group/button-group.stories-data.jsx +67 -0
  40. package/src/components/button-group/button-group.stories.jsx +63 -0
  41. package/src/components/buttons-and-links.stories.mdx +55 -0
  42. package/src/components/card/card.jsx +51 -0
  43. package/src/components/card/card.module.less +48 -0
  44. package/src/components/card/card.stories.jsx +39 -0
  45. package/src/components/check-box/check-box.jsx +92 -0
  46. package/src/components/check-box/check-box.module.less +101 -0
  47. package/src/components/check-box/check-box.stories.jsx +27 -0
  48. package/src/components/color/color.stories-data.jsx +71 -0
  49. package/src/components/color/color.stories.mdx +37 -0
  50. package/src/components/dialog/dialog.jsx +64 -0
  51. package/src/components/dialog/dialog.module.less +76 -0
  52. package/src/components/divider/divider.jsx +40 -0
  53. package/src/components/divider/divider.module.less +28 -0
  54. package/src/components/divider/divider.stories.jsx +50 -0
  55. package/src/components/drawer/drawer-tabs.jsx +43 -0
  56. package/src/components/drawer/drawer.jsx +150 -0
  57. package/src/components/drawer/drawer.module.less +167 -0
  58. package/src/components/drawer/drawer.stories.jsx +156 -0
  59. package/src/components/empty/empty.jsx +52 -0
  60. package/src/components/empty/empty.module.less +17 -0
  61. package/src/components/empty/empty.stories.jsx +26 -0
  62. package/src/components/file-input/file-input.jsx +101 -0
  63. package/src/components/file-input/file-input.module.less +3 -0
  64. package/src/components/file-input/file-input.stories.jsx +109 -0
  65. package/src/components/form/field.jsx +96 -0
  66. package/src/components/form/field.stories.jsx +101 -0
  67. package/src/components/form/form.module.less +30 -0
  68. package/src/components/form/form.stories.jsx +191 -0
  69. package/src/components/heading/heading.jsx +105 -0
  70. package/src/components/heading/heading.module.less +59 -0
  71. package/src/components/heading/heading.stories.jsx +60 -0
  72. package/src/components/icon/deprecated-icon.jsx +97 -0
  73. package/src/components/icon/icon.jsx +71 -0
  74. package/src/components/icon/icon.module.less +33 -0
  75. package/src/components/icon/icon.stories.jsx +37 -0
  76. package/src/components/icon/icons.example.module.less +4 -0
  77. package/src/components/input/input.jsx +167 -0
  78. package/src/components/input/input.module.less +94 -0
  79. package/src/components/input/input.stories.jsx +28 -0
  80. package/src/components/input-group/input-group-addon/input-group-addon.jsx +36 -0
  81. package/src/components/input-group/input-group-addon/input-group-addon.module.less +31 -0
  82. package/src/components/input-group/input-group.jsx +51 -0
  83. package/src/components/input-group/input-group.module.less +10 -0
  84. package/src/components/input-group/input-group.stories.jsx +77 -0
  85. package/src/components/input-validation.stories.mdx +61 -0
  86. package/src/components/inputs.stories.mdx +201 -0
  87. package/src/components/label/label.jsx +115 -0
  88. package/src/components/label/label.module.less +43 -0
  89. package/src/components/label/label.stories.jsx +60 -0
  90. package/src/components/layout/column/column.jsx +85 -0
  91. package/src/components/layout/column/styles.js +45 -0
  92. package/src/components/layout/column.stories.jsx +60 -0
  93. package/src/components/layout/examples/afe.stories.jsx +180 -0
  94. package/src/components/layout/examples/blowout.stories.jsx +68 -0
  95. package/src/components/layout/examples/casing-loads.stories.jsx +297 -0
  96. package/src/components/layout/examples/formation.stories.jsx +110 -0
  97. package/src/components/layout/examples/projects.stories.jsx +108 -0
  98. package/src/components/layout/examples/reservoirs.stories.jsx +211 -0
  99. package/src/components/layout/examples/site.stories.jsx +263 -0
  100. package/src/components/layout/flex/flex.jsx +48 -0
  101. package/src/components/layout/flex/flex.stories.jsx +54 -0
  102. package/src/components/layout/form-row/form-row.jsx +15 -0
  103. package/src/components/layout/form-row/form-row.module.less +11 -0
  104. package/src/components/layout/grid/grid.jsx +62 -0
  105. package/src/components/layout/grid/grid.stories.jsx +65 -0
  106. package/src/components/layout/page/page.jsx +42 -0
  107. package/src/components/layout/page/page.module.less +27 -0
  108. package/src/components/layout/page.stories.jsx +93 -0
  109. package/src/components/layout/placeholder.jsx +2 -0
  110. package/src/components/layout/print-header/print-header.jsx +22 -0
  111. package/src/components/layout/print-header/print-header.module.less +9 -0
  112. package/src/components/layout/row/row.jsx +75 -0
  113. package/src/components/layout/row/row.module.less +7 -0
  114. package/src/components/layout/spacer/spacer.jsx +26 -0
  115. package/src/components/layout/spacer/spacer.stories.jsx +50 -0
  116. package/src/components/layout-forms.stories.mdx +104 -0
  117. package/src/components/layout-general.stories.mdx +215 -0
  118. package/src/components/list/list-row/item-content.jsx +15 -0
  119. package/src/components/list/list-row/label.jsx +11 -0
  120. package/src/components/list/list-row/list-heading.jsx +52 -0
  121. package/src/components/list/list-row/list-row.jsx +128 -0
  122. package/src/components/list/list-row/list-subheading.jsx +72 -0
  123. package/src/components/list/list-row/meta-content.jsx +24 -0
  124. package/src/components/list/list-row/meta-count.jsx +10 -0
  125. package/src/components/list/list-row/name.jsx +45 -0
  126. package/src/components/list/list.jsx +276 -0
  127. package/src/components/list/list.module.less +256 -0
  128. package/src/components/list/list.stories-data.jsx +287 -0
  129. package/src/components/list/list.stories.jsx +458 -0
  130. package/src/components/list/toggle-narrow.jsx +13 -0
  131. package/src/components/loader/loader.jsx +63 -0
  132. package/src/components/loader/loader.module.less +63 -0
  133. package/src/components/loader/loader.stories.jsx +155 -0
  134. package/src/components/menu/index.js +7 -0
  135. package/src/components/menu/layer/divider.jsx +4 -0
  136. package/src/components/menu/layer/heading.jsx +15 -0
  137. package/src/components/menu/layer/layer.jsx +82 -0
  138. package/src/components/menu/layer/option.jsx +77 -0
  139. package/src/components/menu/layer/path.js +44 -0
  140. package/src/components/menu/layer/placementOptions.js +6 -0
  141. package/src/components/menu/layer/section.jsx +66 -0
  142. package/src/components/menu/menu.jsx +359 -0
  143. package/src/components/menu/menu.module.less +241 -0
  144. package/src/components/menu/menu.stories-data.jsx +168 -0
  145. package/src/components/menu/menu.stories.jsx +126 -0
  146. package/src/components/menu/menu.test.js +58 -0
  147. package/src/components/menu/trigger/button.jsx +50 -0
  148. package/src/components/menu/trigger/component.jsx +14 -0
  149. package/src/components/menu/trigger/text.jsx +25 -0
  150. package/src/components/menu/trigger/trigger.jsx +86 -0
  151. package/src/components/message/dismiss.jsx +26 -0
  152. package/src/components/message/message.jsx +137 -0
  153. package/src/components/message/message.module.less +114 -0
  154. package/src/components/message/message.stories.jsx +84 -0
  155. package/src/components/modal/modal.jsx +50 -0
  156. package/src/components/modal/modal.module.less +35 -0
  157. package/src/components/modal/modal.stories.jsx +159 -0
  158. package/src/components/option-dropdown/heading.jsx +6 -0
  159. package/src/components/option-dropdown/layer.jsx +81 -0
  160. package/src/components/option-dropdown/option-dropdown.jsx +53 -0
  161. package/src/components/option-dropdown/option-dropdown.module.less +50 -0
  162. package/src/components/option-dropdown/option-dropdown.stories.jsx +35 -0
  163. package/src/components/option-dropdown/option.jsx +13 -0
  164. package/src/components/pagination/pagination.jsx +139 -0
  165. package/src/components/pagination/pagination.module.less +11 -0
  166. package/src/components/pagination/pagination.stories.jsx +78 -0
  167. package/src/components/pagination/pagination.test.js +92 -0
  168. package/src/components/pagination/pagination.viewdata.js +66 -0
  169. package/src/components/pop-confirm/content.jsx +25 -0
  170. package/src/components/pop-confirm/pop-confirm.jsx +61 -0
  171. package/src/components/pop-confirm/pop-confirm.module.less +18 -0
  172. package/src/components/pop-confirm/pop-confirm.stories.jsx +53 -0
  173. package/src/components/popover/popover.jsx +112 -0
  174. package/src/components/popover/popover.module.less +22 -0
  175. package/src/components/popover/popover.stories.jsx +59 -0
  176. package/src/components/portal/portal.jsx +16 -0
  177. package/src/components/portal/portal.stories.jsx +69 -0
  178. package/src/components/progress-bar/progress-bar.jsx +64 -0
  179. package/src/components/progress-bar/progress-bar.module.less +64 -0
  180. package/src/components/progress-bar/progress-bar.stories.jsx +23 -0
  181. package/src/components/radio-button/radio-button.jsx +139 -0
  182. package/src/components/radio-button/radio-button.module.less +135 -0
  183. package/src/components/radio-button/radio-button.stories.jsx +37 -0
  184. package/src/components/radio-button/radio-input.jsx +52 -0
  185. package/src/components/select/custom-select/custom-select.jsx +440 -0
  186. package/src/components/select/custom-select/custom-select.module.less +123 -0
  187. package/src/components/select/custom-select/custom-select.reducer.js +157 -0
  188. package/src/components/select/custom-select/layer/heading.jsx +13 -0
  189. package/src/components/select/custom-select/layer/layer.jsx +73 -0
  190. package/src/components/select/custom-select/layer/option.jsx +54 -0
  191. package/src/components/select/custom-select/layer/placementOptions.js +7 -0
  192. package/src/components/select/custom-select/layer/section.jsx +35 -0
  193. package/src/components/select/custom-select/trigger/input.jsx +100 -0
  194. package/src/components/select/custom-select/trigger/trigger.jsx +155 -0
  195. package/src/components/select/custom-select/trigger/trigger.module.less +289 -0
  196. package/src/components/select/native-select/native-select.jsx +198 -0
  197. package/src/components/select/native-select/native-select.module.less +107 -0
  198. package/src/components/select/select.input.js +146 -0
  199. package/src/components/select/select.jsx +207 -0
  200. package/src/components/select/select.stories-data.jsx +92 -0
  201. package/src/components/select/select.stories.jsx +135 -0
  202. package/src/components/select/select.test.js +519 -0
  203. package/src/components/side-bar/container.module.less +29 -0
  204. package/src/components/side-bar/link.jsx +83 -0
  205. package/src/components/side-bar/sections.jsx +23 -0
  206. package/src/components/side-bar/side-bar.jsx +102 -0
  207. package/src/components/side-bar/side-bar.module.less +137 -0
  208. package/src/components/side-bar/side-bar.stories.jsx +101 -0
  209. package/src/components/slider/rc-slider.less +47 -0
  210. package/src/components/slider/slider-tooltip.jsx +20 -0
  211. package/src/components/slider/slider.jsx +233 -0
  212. package/src/components/slider/slider.module.less +40 -0
  213. package/src/components/slider/slider.stories.jsx +110 -0
  214. package/src/components/spinner/spinner.jsx +37 -0
  215. package/src/components/spinner/spinner.module.less +115 -0
  216. package/src/components/spinner/spinner.stories.jsx +24 -0
  217. package/src/components/table/cell/cell.jsx +614 -0
  218. package/src/components/table/cell/cell.module.less +152 -0
  219. package/src/components/table/footer/footer.jsx +66 -0
  220. package/src/components/table/footer/footer.module.less +14 -0
  221. package/src/components/table/helper.js +64 -0
  222. package/src/components/table/helper.test.js +166 -0
  223. package/src/components/table/icon/icon.module.less +31 -0
  224. package/src/components/table/row/expanded-content-row.jsx +16 -0
  225. package/src/components/table/row/row.jsx +253 -0
  226. package/src/components/table/row/row.module.less +62 -0
  227. package/src/components/table/table-scroll-wrapper.jsx +48 -0
  228. package/src/components/table/table.jsx +232 -0
  229. package/src/components/table/table.module.less +145 -0
  230. package/src/components/table/table.stories-data.jsx +752 -0
  231. package/src/components/table/table.stories.jsx +814 -0
  232. package/src/components/table/table.test.js +30 -0
  233. package/src/components/table/table.variables.less +19 -0
  234. package/src/components/table/table.viewdata.js +26 -0
  235. package/src/components/table/title/title.jsx +30 -0
  236. package/src/components/table/title/title.module.less +9 -0
  237. package/src/components/tabs/content.jsx +14 -0
  238. package/src/components/tabs/label.jsx +50 -0
  239. package/src/components/tabs/tabs.jsx +191 -0
  240. package/src/components/tabs/tabs.module.less +73 -0
  241. package/src/components/tabs/tabs.stories.jsx +110 -0
  242. package/src/components/text/text.jsx +64 -0
  243. package/src/components/text/text.module.less +45 -0
  244. package/src/components/text/text.stories.jsx +31 -0
  245. package/src/components/text-link/text-link.jsx +23 -0
  246. package/src/components/text-link/text-link.stories.jsx +20 -0
  247. package/src/components/textarea/textarea.jsx +126 -0
  248. package/src/components/textarea/textarea.module.less +55 -0
  249. package/src/components/textarea/textarea.stories.jsx +26 -0
  250. package/src/components/toaster/toaster.jsx +39 -0
  251. package/src/components/toaster/toaster.less +17 -0
  252. package/src/components/toaster/toaster.stories.jsx +116 -0
  253. package/src/components/toggle/toggle.jsx +65 -0
  254. package/src/components/toggle/toggle.module.less +139 -0
  255. package/src/components/toggle/toggle.stories.jsx +26 -0
  256. package/src/components/tooltip/tooltip-layer.jsx +72 -0
  257. package/src/components/tooltip/tooltip.jsx +108 -0
  258. package/src/components/tooltip/tooltip.module.less +28 -0
  259. package/src/components/tooltip/tooltip.stories.jsx +71 -0
  260. package/src/components/top-bar/element/element.jsx +72 -0
  261. package/src/components/top-bar/element/link.jsx +29 -0
  262. package/src/components/top-bar/title.jsx +24 -0
  263. package/src/components/top-bar/top-bar.jsx +79 -0
  264. package/src/components/top-bar/top-bar.module.less +191 -0
  265. package/src/components/top-bar/top-bar.stories.jsx +137 -0
  266. package/src/components/top-bar/warning.jsx +6 -0
  267. package/src/components/tree/tree-item.jsx +79 -0
  268. package/src/components/tree/tree-placeholder.jsx +6 -0
  269. package/src/components/tree/tree.jsx +129 -0
  270. package/src/components/tree/tree.module.less +33 -0
  271. package/src/components/tree/tree.stories-data.jsx +89 -0
  272. package/src/components/tree/tree.stories.jsx +106 -0
  273. package/src/docs/components/page/page.jsx +16 -0
  274. package/src/docs/config/config.js +1 -0
  275. package/src/docs/html/favicon.png +0 -0
  276. package/src/docs/html/index.html +11 -0
  277. package/src/docs/navigation/footer/footer.jsx +48 -0
  278. package/src/docs/navigation/header/header.jsx +39 -0
  279. package/src/docs/navigation/header/header.module.less +32 -0
  280. package/src/docs/navigation/routes/routes.jsx +16 -0
  281. package/src/docs/start.jsx +12 -0
  282. package/src/docs/views/main/main.jsx +209 -0
  283. package/src/docs/views/main/main.module.less +14 -0
  284. package/src/docs/views/not-found/not-found.jsx +5 -0
  285. package/src/helpers/disabled-context.js +8 -0
  286. package/src/helpers/styles.js +68 -0
  287. package/src/helpers/text.js +6 -0
  288. package/src/helpers/types.js +5 -0
  289. package/src/hooks/index.js +3 -0
  290. package/src/hooks/use-focus.js +11 -0
  291. package/src/hooks/use-keyboard-event.js +16 -0
  292. package/src/hooks/use-window-width.js +20 -0
  293. package/src/images/icons/icon-drop.png +0 -0
  294. package/src/images/icons/icon-share.png +0 -0
  295. package/src/images/icons/icons8-junction.svg +4 -0
  296. package/src/images/logo.png +0 -0
  297. package/src/images/logo.svg +13 -0
  298. package/src/images/oliasoft-logo.svg +1 -0
  299. package/src/style/colors.less +26 -0
  300. package/src/style/external.less +10 -0
  301. package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
  302. package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
  303. package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
  304. package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
  305. package/src/style/fonts.less +27 -0
  306. package/src/style/global.less +51 -0
  307. package/src/style/mixins.less +67 -0
  308. package/src/style/reset/reset.less +34 -0
  309. package/src/style/shared.less +25 -0
  310. package/src/style/theme.dark.less +37 -0
  311. package/src/style/theme.default.less +74 -0
  312. package/src/style/variables.less +49 -0
  313. package/webpack/webpack.common.js +39 -0
  314. package/webpack/webpack.common.rules.js +102 -0
  315. package/webpack/webpack.dev.js +22 -0
  316. package/webpack/webpack.prod.js +23 -0
  317. package/webpack/webpack.resolve.js +22 -0
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cx from 'classnames';
4
+ import { FaQuestionCircle, FaBook } from 'react-icons/fa';
5
+ import { Icon } from '../icon/icon';
6
+ import { Tooltip } from '../tooltip/tooltip';
7
+ import styles from './heading.module.less';
8
+
9
+ export const IconWrapper = ({
10
+ onClick,
11
+ icon,
12
+ isHelp,
13
+ isLock,
14
+ isFaint,
15
+ testId,
16
+ }) => {
17
+ return (
18
+ onClick && (
19
+ <span
20
+ onClick={(evt) => {
21
+ evt.stopPropagation();
22
+ if (onClick) {
23
+ onClick(evt);
24
+ }
25
+ }}
26
+ className={cx(
27
+ styles.icon,
28
+ isHelp ? styles.help : '',
29
+ isLock ? styles.lock : '',
30
+ isFaint ? styles.faint : '',
31
+ )}
32
+ data-testid={testId}
33
+ >
34
+ <Icon icon={icon} />
35
+ </span>
36
+ )
37
+ );
38
+ };
39
+
40
+ export const Heading = ({
41
+ children,
42
+ onClickHelp,
43
+ onClick,
44
+ onIconClick,
45
+ icon,
46
+ libraryIcon,
47
+ marginBottom,
48
+ top,
49
+ testId,
50
+ }) => {
51
+ return (
52
+ <div
53
+ className={cx(styles.heading, top ? styles.top : '')}
54
+ style={{ marginBottom }}
55
+ onClick={(evt) => {
56
+ if (onClick) {
57
+ onClick(evt);
58
+ }
59
+ }}
60
+ data-testid={testId}
61
+ >
62
+ {children}
63
+ <div className={styles.icons}>
64
+ {icon && <IconWrapper onClick={onIconClick} icon={icon} />}
65
+ {onClickHelp && (
66
+ <IconWrapper
67
+ onClick={onClickHelp}
68
+ icon={<FaQuestionCircle />}
69
+ isHelp
70
+ />
71
+ )}
72
+ {libraryIcon && (
73
+ <Tooltip text={libraryIcon?.tooltip ?? ''}>
74
+ <IconWrapper onClick={libraryIcon.onClick} icon={<FaBook />} />
75
+ </Tooltip>
76
+ )}
77
+ </div>
78
+ </div>
79
+ );
80
+ };
81
+
82
+ Heading.defaultProps = {
83
+ onClick: null,
84
+ onClickHelp: null,
85
+ onIconClick: null,
86
+ icon: null,
87
+ libraryIcon: null,
88
+ marginBottom: null,
89
+ top: false,
90
+ testId: null,
91
+ };
92
+
93
+ Heading.propTypes = {
94
+ onClick: PropTypes.func,
95
+ onClickHelp: PropTypes.func,
96
+ onIconClick: PropTypes.func,
97
+ icon: PropTypes.node,
98
+ libraryIcon: PropTypes.shape({
99
+ onClick: PropTypes.func,
100
+ tooltip: PropTypes.string,
101
+ }),
102
+ marginBottom: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
103
+ top: PropTypes.bool,
104
+ testId: PropTypes.string,
105
+ };
@@ -0,0 +1,59 @@
1
+ @import '../../style/variables.less';
2
+
3
+ .heading {
4
+ color: var(--color-text);
5
+ font-weight: 600;
6
+ display: flex;
7
+ align-items: center;
8
+ user-select: none;
9
+ padding: 0;
10
+
11
+ &.top {
12
+ font-size: 18px;
13
+ margin-bottom: 20px;
14
+ line-height: 1.2;
15
+ }
16
+
17
+ &:not(.top) {
18
+ font-size: 13px;
19
+ line-height: 20px;
20
+ color: var(--color-text-muted);
21
+ text-transform: uppercase;
22
+ letter-spacing: 0.1em;
23
+ }
24
+ }
25
+
26
+ .icons {
27
+ display: inline-flex;
28
+
29
+ > * {
30
+ margin-left: 8px;
31
+ }
32
+ }
33
+
34
+ .icon {
35
+ color: var(--color-text-faint);
36
+ cursor: pointer;
37
+ line-height: 0;
38
+ font-size: 13px;
39
+ display: flex;
40
+ align-items: center;
41
+
42
+ &.lock {
43
+ color: var(--color-text);
44
+ }
45
+
46
+ &.faint {
47
+ color: var(--color-text-faint);
48
+ }
49
+
50
+ &:hover,
51
+ &:focus {
52
+ color: var(--color-text-primary-hover);
53
+ }
54
+
55
+ &:active,
56
+ &.active {
57
+ color: var(--color-text-primary-active);
58
+ }
59
+ }
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import { FaCheckCircle, FaPlus } from 'react-icons/fa';
3
+ import { Heading, Flex } from '../../..';
4
+
5
+ export default {
6
+ title: 'Basic/Heading',
7
+ component: Heading,
8
+ args: {
9
+ children: 'Heading',
10
+ top: false,
11
+ },
12
+ };
13
+
14
+ const Template = (args) => (
15
+ <Heading
16
+ // eslint-disable-next-line react/jsx-props-no-spreading
17
+ {...args}
18
+ />
19
+ );
20
+
21
+ export const Default = Template.bind({});
22
+
23
+ export const Top = Template.bind({});
24
+ Top.args = {
25
+ top: true,
26
+ };
27
+
28
+ export const CustomMargin = Template.bind({});
29
+ CustomMargin.args = {
30
+ marginBottom: 50,
31
+ };
32
+
33
+ export const Help = Template.bind({});
34
+ Help.args = {
35
+ onClickHelp: () => console.log('help!'),
36
+ };
37
+
38
+ export const LibraryIcon = Template.bind({});
39
+ LibraryIcon.args = {
40
+ libraryIcon: {
41
+ onClick: () => {},
42
+ tooltip: 'Edit in library',
43
+ },
44
+ };
45
+
46
+ export const CustomIcon = Template.bind({});
47
+ CustomIcon.args = {
48
+ icon: <FaPlus />,
49
+ onIconClick: () => console.log('clicked icon!'),
50
+ };
51
+
52
+ export const JSXContent = Template.bind({});
53
+ JSXContent.args = {
54
+ children: (
55
+ <Flex alignItems="center" gap="10px">
56
+ Subheading
57
+ <FaCheckCircle />
58
+ </Flex>
59
+ ),
60
+ };
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import {
3
+ FaArrowDown,
4
+ FaArrowLeft,
5
+ FaArrowRight,
6
+ FaArrowUp,
7
+ FaChartLine,
8
+ FaCheck,
9
+ FaChevronDown,
10
+ FaChevronUp,
11
+ FaClone,
12
+ FaEdit,
13
+ FaEye,
14
+ FaEyeSlash,
15
+ FaFileImport, // vertically flipped reply (used in import context)
16
+ FaMinus,
17
+ FaPencilAlt, //pencil
18
+ FaPlus,
19
+ FaQuestion,
20
+ FaRegCircle, // for not found
21
+ FaRegCopy, // copy outline
22
+ FaSortAmountDown,
23
+ FaSortAmountUp,
24
+ FaStar,
25
+ FaSync,
26
+ FaTable,
27
+ FaTimes,
28
+ FaTrash,
29
+ FaUndo,
30
+ } from 'react-icons/fa';
31
+
32
+ export const DeprecatedIcon = ({ icon }) => {
33
+ switch (icon) {
34
+ case 'arrow down':
35
+ return <FaArrowDown />;
36
+ case 'arrow left':
37
+ return <FaArrowLeft />;
38
+ case 'arrow right':
39
+ return <FaArrowRight />;
40
+ case 'arrow up':
41
+ return <FaArrowUp />;
42
+ case 'chart line':
43
+ return <FaChartLine />;
44
+ case 'check':
45
+ case 'checkmark':
46
+ return <FaCheck />;
47
+ case 'close':
48
+ case 'times':
49
+ return <FaTimes />;
50
+ case 'question':
51
+ return <FaQuestion />;
52
+ case 'sort amount down':
53
+ return <FaSortAmountDown />;
54
+ case 'table':
55
+ return <FaTable />;
56
+ case 'trash':
57
+ return <FaTrash />;
58
+ case 'minus':
59
+ return <FaMinus />;
60
+ case 'add':
61
+ case 'plus':
62
+ return <FaPlus />;
63
+ case 'pencil':
64
+ return <FaPencilAlt />;
65
+ case 'edit':
66
+ case 'edit outline':
67
+ return <FaEdit />;
68
+ case 'chevron up':
69
+ return <FaChevronUp />;
70
+ case 'chevron down':
71
+ return <FaChevronDown />;
72
+ case 'undo':
73
+ return <FaUndo />;
74
+ case 'eye':
75
+ return <FaEye />;
76
+ case 'eye slash':
77
+ return <FaEyeSlash />;
78
+ case 'star':
79
+ return <FaStar />;
80
+ case 'clone':
81
+ case 'orange clone':
82
+ return <FaClone />;
83
+ case 'sort amount up':
84
+ return <FaSortAmountUp />;
85
+ case 'copy':
86
+ case 'copy outline':
87
+ return <FaRegCopy />;
88
+ case 'vertically flipped reply':
89
+ return <FaFileImport />;
90
+ case 'refresh':
91
+ return <FaSync />;
92
+ case '':
93
+ return null;
94
+ default:
95
+ return <FaRegCircle />; //just a default icon so it's obvious when missing
96
+ }
97
+ };
@@ -0,0 +1,71 @@
1
+ import React, { isValidElement, useContext } from 'react';
2
+ import cx from 'classnames';
3
+ import PropTypes from 'prop-types';
4
+ import { ReactSVG } from 'react-svg';
5
+ import { DeprecatedIcon } from './deprecated-icon';
6
+ import styles from './icon.module.less';
7
+ import { DisabledContext } from '../../helpers/disabled-context';
8
+
9
+ /*
10
+ Icon wrapper component to support different icon formats:
11
+ - react-icons (default recommendation)
12
+ - SVG (for special cases)
13
+ - deprecated string names (for backwards compatibility with Semantic UI)
14
+ */
15
+
16
+ export const Icon = ({ icon, onClick, clickable, color, size, testId }) => {
17
+ const disabledContext = useContext(DisabledContext);
18
+
19
+ return (
20
+ <div
21
+ className={cx(
22
+ styles.wrapper,
23
+ (clickable || onClick) && !disabledContext ? styles.clickable : '',
24
+ )}
25
+ style={{
26
+ color,
27
+ fill: color,
28
+ fontSize: size || 'inherit',
29
+ width: size || 'auto',
30
+ height: size || 'auto',
31
+ }}
32
+ onClick={(evt) => (onClick && !disabledContext ? onClick(evt) : {})}
33
+ data-testid={testId}
34
+ >
35
+ {isValidElement(icon) ? (
36
+ icon //react-icon
37
+ ) : typeof icon === 'string' && icon.includes('.svg') ? (
38
+ <ReactSVG
39
+ className={styles.customSvg}
40
+ beforeInjection={(svg) => {
41
+ if (size) {
42
+ svg.setAttribute('width', size);
43
+ svg.setAttribute('height', size);
44
+ }
45
+ }}
46
+ src={icon}
47
+ /> //SVG
48
+ ) : typeof icon === 'string' && icon.includes('.png') ? (
49
+ <img alt="icon" className={styles.customPng} src={icon} />
50
+ ) : typeof icon === 'string' ? (
51
+ <DeprecatedIcon icon={icon} /> //deprecated Semantic UI string name
52
+ ) : null}
53
+ </div>
54
+ );
55
+ };
56
+
57
+ Icon.defaultProps = {
58
+ clickable: false,
59
+ onClick: null,
60
+ testId: '',
61
+ };
62
+
63
+ Icon.propTypes = {
64
+ icon: PropTypes.oneOfType([
65
+ PropTypes.node, //JSX (react-icons)
66
+ PropTypes.string, //SVG (or deprecated string name)
67
+ ]).isRequired,
68
+ onClick: PropTypes.func,
69
+ clickable: PropTypes.bool,
70
+ testId: PropTypes.string,
71
+ };
@@ -0,0 +1,33 @@
1
+ @import '../../style/variables.less';
2
+
3
+ .wrapper {
4
+ color: inherit;
5
+ fill: inherit;
6
+ display: inline-flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+
10
+ .customSvg {
11
+ line-height: 0; // Strips unneccessary whitespace
12
+ }
13
+
14
+ .customPng {
15
+ max-width: 100%;
16
+ max-height: 100%;
17
+ object-fit: contain;
18
+ }
19
+ }
20
+
21
+ .clickable {
22
+ cursor: pointer;
23
+
24
+ &:hover {
25
+ color: var(--color-text-primary-hover) !important;
26
+ fill: var(--color-text-primary-hover) !important;
27
+ }
28
+
29
+ &:active {
30
+ color: var(--color-text-primary-active) !important;
31
+ fill: var(--color-text-primary-active) !important;
32
+ }
33
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { FaAngleDoubleRight } from 'react-icons/fa';
3
+ import { Icon } from '../../..';
4
+ import svgIcon from '../../images/icons/icons8-junction.svg';
5
+
6
+ export default {
7
+ title: 'Basic/Icon',
8
+ component: Icon,
9
+ argTypes: {
10
+ color: { control: 'text' },
11
+ size: { control: 'text' },
12
+ },
13
+ args: {
14
+ icon: <FaAngleDoubleRight />,
15
+ },
16
+ };
17
+
18
+ const Template = (args) => (
19
+ <Icon
20
+ // eslint-disable-next-line react/jsx-props-no-spreading
21
+ {...args}
22
+ />
23
+ );
24
+
25
+ export const Default = Template.bind({});
26
+
27
+ export const Size = Template.bind({});
28
+ Size.args = { size: '100px' };
29
+
30
+ export const Color = Template.bind({});
31
+ Color.args = { color: 'var(--color-text-primary)' };
32
+
33
+ export const CustomSVG = Template.bind({});
34
+ CustomSVG.args = { icon: svgIcon, size: '14px' };
35
+
36
+ export const Clickable = Template.bind({});
37
+ Clickable.args = { onClick: () => {} };
@@ -0,0 +1,4 @@
1
+ .middleAlignedInline {
2
+ display: flex;
3
+ align-items: center;
4
+ }
@@ -0,0 +1,167 @@
1
+ import React, { forwardRef, useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cx from 'classnames';
4
+ import styles from './input.module.less';
5
+ import { Tooltip } from '../tooltip/tooltip';
6
+ import { isStringNumberOrNode } from '../../helpers/types';
7
+ import { DisabledContext } from '../../helpers/disabled-context';
8
+
9
+ /*
10
+ Gets the width when you want to set it based on the number of characters
11
+ Replacement for input size property which is hard to style
12
+ */
13
+ export const widthOfCharacters = (characterCount) => {
14
+ const padding = '15px';
15
+ const multiplier = '0.675em';
16
+ return `calc((${characterCount} * ${multiplier}) + (2 * ${padding}))`;
17
+ };
18
+
19
+ export const Input = forwardRef(
20
+ (
21
+ {
22
+ error,
23
+ tooltip,
24
+ isInTable,
25
+ width: propWidth,
26
+ small,
27
+ onChange,
28
+ size,
29
+ placeholder,
30
+ value,
31
+ onKeyPress,
32
+ onFocus,
33
+ onBlur,
34
+ name,
35
+ type,
36
+ tabIndex,
37
+ disabled,
38
+ right,
39
+ warning,
40
+ groupOrder,
41
+ maxTooltipWidth,
42
+ testId,
43
+ },
44
+ ref,
45
+ ) => {
46
+ const disabledContext = useContext(DisabledContext);
47
+ const order = (() => {
48
+ if (groupOrder) {
49
+ switch (groupOrder) {
50
+ case 'first':
51
+ return styles.groupOrderFirst;
52
+ case 'last':
53
+ return styles.groupOrderLast;
54
+ default:
55
+ return styles.groupOrderMiddle;
56
+ }
57
+ }
58
+ return '';
59
+ })();
60
+
61
+ const width = propWidth || (size ? 'auto' : '100%');
62
+
63
+ return (
64
+ <div style={{ width }} className={order}>
65
+ <Tooltip
66
+ error={!!error}
67
+ warning={!!warning}
68
+ text={tooltip || error || warning}
69
+ enabled={
70
+ (tooltip && isStringNumberOrNode(tooltip)) ||
71
+ (error && isStringNumberOrNode(error)) ||
72
+ (warning && isStringNumberOrNode(warning)) ||
73
+ false
74
+ }
75
+ maxWidth={maxTooltipWidth}
76
+ display="block"
77
+ placement="bottom-center"
78
+ >
79
+ <input
80
+ type={type}
81
+ size={size || 20}
82
+ placeholder={placeholder}
83
+ value={value}
84
+ onChange={onChange}
85
+ onKeyPress={onKeyPress}
86
+ onFocus={onFocus}
87
+ onBlur={onBlur}
88
+ name={name}
89
+ tabIndex={tabIndex}
90
+ autoComplete="off"
91
+ disabled={disabled || disabledContext}
92
+ className={cx(
93
+ styles.input,
94
+ error ? styles.error : warning ? styles.warning : '',
95
+ right ? styles.right : '',
96
+ small ? styles.small : '',
97
+ isInTable ? styles.isInTable : '',
98
+ )}
99
+ style={{ width }}
100
+ ref={ref}
101
+ data-testid={testId}
102
+ />
103
+ </Tooltip>
104
+ </div>
105
+ );
106
+ },
107
+ );
108
+
109
+ Input.defaultProps = {
110
+ error: null,
111
+ warning: null,
112
+ tooltip: null,
113
+ name: undefined,
114
+ type: 'text',
115
+ onChange: () => {},
116
+ onKeyPress: () => {},
117
+ onFocus: () => {},
118
+ onBlur: () => {},
119
+ placeholder: '',
120
+ small: false,
121
+ tabIndex: 0,
122
+ value: '',
123
+ disabled: false,
124
+ right: false,
125
+ groupOrder: null,
126
+ maxTooltipWidth: undefined,
127
+ width: undefined,
128
+ testId: undefined,
129
+ //deprecated props
130
+ size: null, //use width instead
131
+ };
132
+
133
+ Input.propTypes = {
134
+ error: PropTypes.oneOfType([
135
+ PropTypes.string,
136
+ PropTypes.number,
137
+ PropTypes.node,
138
+ ]),
139
+ warning: PropTypes.oneOfType([
140
+ PropTypes.string,
141
+ PropTypes.number,
142
+ PropTypes.node,
143
+ ]),
144
+ tooltip: PropTypes.oneOfType([
145
+ PropTypes.string,
146
+ PropTypes.number,
147
+ PropTypes.node,
148
+ ]),
149
+ name: PropTypes.string,
150
+ type: PropTypes.string,
151
+ onChange: PropTypes.func,
152
+ onKeyPress: PropTypes.func,
153
+ onFocus: PropTypes.func,
154
+ onBlur: PropTypes.func,
155
+ small: PropTypes.bool,
156
+ placeholder: PropTypes.string,
157
+ tabIndex: PropTypes.number,
158
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
159
+ disabled: PropTypes.bool,
160
+ right: PropTypes.bool,
161
+ groupOrder: PropTypes.string,
162
+ maxTooltipWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
163
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
164
+ testId: PropTypes.string,
165
+ //deprecated props:
166
+ size: PropTypes.number, //use width instead
167
+ };