@oliasoft-open-source/react-ui-library 2.4.7 → 3.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 (320) hide show
  1. package/README.md +0 -1
  2. package/dist/global.css +21840 -0
  3. package/dist/index.js +43567 -0
  4. package/package.json +37 -55
  5. package/.eslintignore +0 -2
  6. package/.eslintrc.js +0 -125
  7. package/.gitlab-ci.yml +0 -76
  8. package/.husky/pre-commit +0 -4
  9. package/.prettierignore +0 -3
  10. package/.prettierrc +0 -4
  11. package/.storybook/main.js +0 -36
  12. package/.storybook/preview.js +0 -40
  13. package/.storybook/storybook.less +0 -8
  14. package/babel.config.js +0 -31
  15. package/index.js +0 -76
  16. package/jest.config.js +0 -9
  17. package/scripts/send-mattermost-message.sh +0 -21
  18. package/src/components/accordion/accordion.jsx +0 -132
  19. package/src/components/accordion/accordion.module.less +0 -66
  20. package/src/components/accordion/accordion.stories.jsx +0 -171
  21. package/src/components/accordion/chevron/chevron.jsx +0 -12
  22. package/src/components/accordion/chevron/chevron.module.less +0 -12
  23. package/src/components/accordion/helpers/accordion-with-default-toggle.jsx +0 -106
  24. package/src/components/accordion/helpers/accordion-with-default-toggle.module.less +0 -24
  25. package/src/components/actions/actions.jsx +0 -129
  26. package/src/components/actions/actions.module.less +0 -44
  27. package/src/components/actions/actions.shape.js +0 -32
  28. package/src/components/actions/actions.stories.jsx +0 -79
  29. package/src/components/badge/badge.jsx +0 -58
  30. package/src/components/badge/badge.module.less +0 -55
  31. package/src/components/badge/badge.stories.jsx +0 -31
  32. package/src/components/breadcrumb/breadcrumb.jsx +0 -49
  33. package/src/components/breadcrumb/breadcrumb.module.less +0 -39
  34. package/src/components/breadcrumb/breadcrumb.stories.jsx +0 -45
  35. package/src/components/breadcrumb/link.jsx +0 -31
  36. package/src/components/button/button.jsx +0 -156
  37. package/src/components/button/button.module.less +0 -300
  38. package/src/components/button/button.stories.jsx +0 -74
  39. package/src/components/button-group/button-group.jsx +0 -140
  40. package/src/components/button-group/button-group.module.less +0 -24
  41. package/src/components/button-group/button-group.stories-data.jsx +0 -67
  42. package/src/components/button-group/button-group.stories.jsx +0 -63
  43. package/src/components/buttons-and-links.stories.mdx +0 -55
  44. package/src/components/card/card.jsx +0 -51
  45. package/src/components/card/card.module.less +0 -48
  46. package/src/components/card/card.stories.jsx +0 -39
  47. package/src/components/check-box/check-box.jsx +0 -92
  48. package/src/components/check-box/check-box.module.less +0 -101
  49. package/src/components/check-box/check-box.stories.jsx +0 -27
  50. package/src/components/color/color.stories-data.jsx +0 -71
  51. package/src/components/color/color.stories.mdx +0 -37
  52. package/src/components/dialog/dialog.jsx +0 -77
  53. package/src/components/dialog/dialog.module.less +0 -76
  54. package/src/components/divider/divider.jsx +0 -40
  55. package/src/components/divider/divider.module.less +0 -28
  56. package/src/components/divider/divider.stories.jsx +0 -50
  57. package/src/components/drawer/drawer-resize-wrapper.jsx +0 -76
  58. package/src/components/drawer/drawer-tabs.jsx +0 -44
  59. package/src/components/drawer/drawer.jsx +0 -161
  60. package/src/components/drawer/drawer.module.less +0 -217
  61. package/src/components/drawer/drawer.stories.jsx +0 -296
  62. package/src/components/empty/empty.jsx +0 -52
  63. package/src/components/empty/empty.module.less +0 -17
  64. package/src/components/empty/empty.stories.jsx +0 -26
  65. package/src/components/file-input/file-input.jsx +0 -101
  66. package/src/components/file-input/file-input.module.less +0 -3
  67. package/src/components/file-input/file-input.stories.jsx +0 -109
  68. package/src/components/form/field.jsx +0 -96
  69. package/src/components/form/field.stories.jsx +0 -101
  70. package/src/components/form/form.module.less +0 -30
  71. package/src/components/form/form.stories.jsx +0 -191
  72. package/src/components/heading/heading.jsx +0 -105
  73. package/src/components/heading/heading.module.less +0 -59
  74. package/src/components/heading/heading.stories.jsx +0 -60
  75. package/src/components/icon/deprecated-icon.jsx +0 -97
  76. package/src/components/icon/icon.jsx +0 -71
  77. package/src/components/icon/icon.module.less +0 -33
  78. package/src/components/icon/icon.stories.jsx +0 -37
  79. package/src/components/icon/icons.example.module.less +0 -4
  80. package/src/components/input/input.jsx +0 -167
  81. package/src/components/input/input.module.less +0 -94
  82. package/src/components/input/input.stories.jsx +0 -28
  83. package/src/components/input-group/input-group-addon/input-group-addon.jsx +0 -36
  84. package/src/components/input-group/input-group-addon/input-group-addon.module.less +0 -31
  85. package/src/components/input-group/input-group.jsx +0 -51
  86. package/src/components/input-group/input-group.module.less +0 -10
  87. package/src/components/input-group/input-group.stories.jsx +0 -77
  88. package/src/components/input-validation.stories.mdx +0 -61
  89. package/src/components/inputs.stories.mdx +0 -201
  90. package/src/components/label/label.jsx +0 -115
  91. package/src/components/label/label.module.less +0 -43
  92. package/src/components/label/label.stories.jsx +0 -60
  93. package/src/components/layout/column/column.jsx +0 -85
  94. package/src/components/layout/column/styles.js +0 -45
  95. package/src/components/layout/column.stories.jsx +0 -60
  96. package/src/components/layout/examples/afe.stories.jsx +0 -180
  97. package/src/components/layout/examples/blowout.stories.jsx +0 -68
  98. package/src/components/layout/examples/casing-loads.stories.jsx +0 -297
  99. package/src/components/layout/examples/formation.stories.jsx +0 -110
  100. package/src/components/layout/examples/projects.stories.jsx +0 -108
  101. package/src/components/layout/examples/reservoirs.stories.jsx +0 -211
  102. package/src/components/layout/examples/site.stories.jsx +0 -263
  103. package/src/components/layout/flex/flex.jsx +0 -48
  104. package/src/components/layout/flex/flex.stories.jsx +0 -59
  105. package/src/components/layout/form-row/form-row.jsx +0 -15
  106. package/src/components/layout/form-row/form-row.module.less +0 -11
  107. package/src/components/layout/grid/grid.jsx +0 -62
  108. package/src/components/layout/grid/grid.stories.jsx +0 -67
  109. package/src/components/layout/page/page.jsx +0 -42
  110. package/src/components/layout/page/page.module.less +0 -27
  111. package/src/components/layout/page.stories.jsx +0 -93
  112. package/src/components/layout/placeholder.jsx +0 -2
  113. package/src/components/layout/print-header/print-header.jsx +0 -22
  114. package/src/components/layout/print-header/print-header.module.less +0 -9
  115. package/src/components/layout/row/row.jsx +0 -75
  116. package/src/components/layout/row/row.module.less +0 -7
  117. package/src/components/layout/spacer/spacer.jsx +0 -26
  118. package/src/components/layout/spacer/spacer.stories.jsx +0 -50
  119. package/src/components/layout-forms.stories.mdx +0 -104
  120. package/src/components/layout-general.stories.mdx +0 -215
  121. package/src/components/list/list-row/item-content.jsx +0 -15
  122. package/src/components/list/list-row/label.jsx +0 -11
  123. package/src/components/list/list-row/list-heading.jsx +0 -52
  124. package/src/components/list/list-row/list-row.jsx +0 -128
  125. package/src/components/list/list-row/list-subheading.jsx +0 -72
  126. package/src/components/list/list-row/meta-content.jsx +0 -24
  127. package/src/components/list/list-row/meta-count.jsx +0 -10
  128. package/src/components/list/list-row/name.jsx +0 -45
  129. package/src/components/list/list.jsx +0 -276
  130. package/src/components/list/list.module.less +0 -256
  131. package/src/components/list/list.stories-data.jsx +0 -287
  132. package/src/components/list/list.stories.jsx +0 -458
  133. package/src/components/list/toggle-narrow.jsx +0 -13
  134. package/src/components/loader/loader.jsx +0 -63
  135. package/src/components/loader/loader.module.less +0 -63
  136. package/src/components/loader/loader.stories.jsx +0 -155
  137. package/src/components/menu/index.js +0 -7
  138. package/src/components/menu/layer/divider.jsx +0 -4
  139. package/src/components/menu/layer/heading.jsx +0 -15
  140. package/src/components/menu/layer/layer.jsx +0 -82
  141. package/src/components/menu/layer/option.jsx +0 -77
  142. package/src/components/menu/layer/path.js +0 -44
  143. package/src/components/menu/layer/placementOptions.js +0 -6
  144. package/src/components/menu/layer/section.jsx +0 -66
  145. package/src/components/menu/menu.jsx +0 -359
  146. package/src/components/menu/menu.module.less +0 -241
  147. package/src/components/menu/menu.stories-data.jsx +0 -168
  148. package/src/components/menu/menu.stories.jsx +0 -126
  149. package/src/components/menu/menu.test.js +0 -58
  150. package/src/components/menu/trigger/button.jsx +0 -50
  151. package/src/components/menu/trigger/component.jsx +0 -14
  152. package/src/components/menu/trigger/text.jsx +0 -25
  153. package/src/components/menu/trigger/trigger.jsx +0 -86
  154. package/src/components/message/dismiss.jsx +0 -26
  155. package/src/components/message/message.jsx +0 -137
  156. package/src/components/message/message.module.less +0 -114
  157. package/src/components/message/message.stories.jsx +0 -84
  158. package/src/components/modal/modal.jsx +0 -50
  159. package/src/components/modal/modal.module.less +0 -39
  160. package/src/components/modal/modal.stories.jsx +0 -162
  161. package/src/components/option-dropdown/heading.jsx +0 -6
  162. package/src/components/option-dropdown/layer.jsx +0 -81
  163. package/src/components/option-dropdown/option-dropdown.jsx +0 -53
  164. package/src/components/option-dropdown/option-dropdown.module.less +0 -50
  165. package/src/components/option-dropdown/option-dropdown.stories.jsx +0 -35
  166. package/src/components/option-dropdown/option.jsx +0 -13
  167. package/src/components/pagination/pagination.jsx +0 -139
  168. package/src/components/pagination/pagination.module.less +0 -11
  169. package/src/components/pagination/pagination.stories.jsx +0 -78
  170. package/src/components/pagination/pagination.test.js +0 -92
  171. package/src/components/pagination/pagination.viewdata.js +0 -66
  172. package/src/components/pop-confirm/content.jsx +0 -25
  173. package/src/components/pop-confirm/pop-confirm.jsx +0 -61
  174. package/src/components/pop-confirm/pop-confirm.module.less +0 -18
  175. package/src/components/pop-confirm/pop-confirm.stories.jsx +0 -53
  176. package/src/components/popover/popover.jsx +0 -112
  177. package/src/components/popover/popover.module.less +0 -22
  178. package/src/components/popover/popover.stories.jsx +0 -59
  179. package/src/components/portal/portal.jsx +0 -16
  180. package/src/components/portal/portal.stories.jsx +0 -69
  181. package/src/components/progress-bar/progress-bar.jsx +0 -64
  182. package/src/components/progress-bar/progress-bar.module.less +0 -64
  183. package/src/components/progress-bar/progress-bar.stories.jsx +0 -23
  184. package/src/components/radio-button/radio-button.jsx +0 -139
  185. package/src/components/radio-button/radio-button.module.less +0 -135
  186. package/src/components/radio-button/radio-button.stories.jsx +0 -37
  187. package/src/components/radio-button/radio-input.jsx +0 -52
  188. package/src/components/select/custom-select/custom-select.jsx +0 -440
  189. package/src/components/select/custom-select/custom-select.module.less +0 -123
  190. package/src/components/select/custom-select/custom-select.reducer.js +0 -157
  191. package/src/components/select/custom-select/layer/heading.jsx +0 -13
  192. package/src/components/select/custom-select/layer/layer.jsx +0 -73
  193. package/src/components/select/custom-select/layer/option.jsx +0 -54
  194. package/src/components/select/custom-select/layer/placementOptions.js +0 -7
  195. package/src/components/select/custom-select/layer/section.jsx +0 -35
  196. package/src/components/select/custom-select/trigger/input.jsx +0 -100
  197. package/src/components/select/custom-select/trigger/trigger.jsx +0 -155
  198. package/src/components/select/custom-select/trigger/trigger.module.less +0 -289
  199. package/src/components/select/native-select/native-select.jsx +0 -198
  200. package/src/components/select/native-select/native-select.module.less +0 -107
  201. package/src/components/select/select.input.js +0 -146
  202. package/src/components/select/select.jsx +0 -207
  203. package/src/components/select/select.stories-data.jsx +0 -92
  204. package/src/components/select/select.stories.jsx +0 -135
  205. package/src/components/select/select.test.js +0 -519
  206. package/src/components/side-bar/container.module.less +0 -29
  207. package/src/components/side-bar/link.jsx +0 -83
  208. package/src/components/side-bar/sections.jsx +0 -23
  209. package/src/components/side-bar/side-bar.jsx +0 -102
  210. package/src/components/side-bar/side-bar.module.less +0 -137
  211. package/src/components/side-bar/side-bar.stories.jsx +0 -101
  212. package/src/components/slider/rc-slider.less +0 -47
  213. package/src/components/slider/slider-tooltip.jsx +0 -20
  214. package/src/components/slider/slider.jsx +0 -233
  215. package/src/components/slider/slider.module.less +0 -40
  216. package/src/components/slider/slider.stories.jsx +0 -110
  217. package/src/components/spinner/spinner.jsx +0 -37
  218. package/src/components/spinner/spinner.module.less +0 -115
  219. package/src/components/spinner/spinner.stories.jsx +0 -24
  220. package/src/components/table/cell/cell.jsx +0 -617
  221. package/src/components/table/cell/cell.module.less +0 -164
  222. package/src/components/table/footer/footer.jsx +0 -66
  223. package/src/components/table/footer/footer.module.less +0 -14
  224. package/src/components/table/helper.js +0 -64
  225. package/src/components/table/helper.test.js +0 -166
  226. package/src/components/table/icon/icon.module.less +0 -31
  227. package/src/components/table/row/expanded-content-row.jsx +0 -16
  228. package/src/components/table/row/row.jsx +0 -253
  229. package/src/components/table/row/row.module.less +0 -62
  230. package/src/components/table/table-scroll-wrapper.jsx +0 -49
  231. package/src/components/table/table.jsx +0 -234
  232. package/src/components/table/table.module.less +0 -146
  233. package/src/components/table/table.stories-data.jsx +0 -874
  234. package/src/components/table/table.stories.jsx +0 -759
  235. package/src/components/table/table.test.js +0 -30
  236. package/src/components/table/table.variables.less +0 -11
  237. package/src/components/table/table.viewdata.js +0 -26
  238. package/src/components/table/title/title.jsx +0 -30
  239. package/src/components/table/title/title.module.less +0 -11
  240. package/src/components/tabs/content.jsx +0 -14
  241. package/src/components/tabs/label.jsx +0 -50
  242. package/src/components/tabs/tabs.jsx +0 -191
  243. package/src/components/tabs/tabs.module.less +0 -73
  244. package/src/components/tabs/tabs.stories.jsx +0 -110
  245. package/src/components/text/text.jsx +0 -64
  246. package/src/components/text/text.module.less +0 -45
  247. package/src/components/text/text.stories.jsx +0 -31
  248. package/src/components/text-link/text-link.jsx +0 -23
  249. package/src/components/text-link/text-link.stories.jsx +0 -20
  250. package/src/components/textarea/textarea.jsx +0 -126
  251. package/src/components/textarea/textarea.module.less +0 -55
  252. package/src/components/textarea/textarea.stories.jsx +0 -26
  253. package/src/components/toaster/toaster.jsx +0 -39
  254. package/src/components/toaster/toaster.less +0 -17
  255. package/src/components/toaster/toaster.stories.jsx +0 -116
  256. package/src/components/toggle/toggle.jsx +0 -65
  257. package/src/components/toggle/toggle.module.less +0 -139
  258. package/src/components/toggle/toggle.stories.jsx +0 -26
  259. package/src/components/tooltip/tooltip-layer.jsx +0 -72
  260. package/src/components/tooltip/tooltip.jsx +0 -108
  261. package/src/components/tooltip/tooltip.module.less +0 -28
  262. package/src/components/tooltip/tooltip.stories.jsx +0 -71
  263. package/src/components/top-bar/element/element.jsx +0 -72
  264. package/src/components/top-bar/element/link.jsx +0 -29
  265. package/src/components/top-bar/title.jsx +0 -24
  266. package/src/components/top-bar/top-bar.jsx +0 -79
  267. package/src/components/top-bar/top-bar.module.less +0 -190
  268. package/src/components/top-bar/top-bar.stories.jsx +0 -137
  269. package/src/components/top-bar/warning.jsx +0 -6
  270. package/src/components/tree/tree-item.jsx +0 -79
  271. package/src/components/tree/tree-placeholder.jsx +0 -6
  272. package/src/components/tree/tree.jsx +0 -129
  273. package/src/components/tree/tree.module.less +0 -33
  274. package/src/components/tree/tree.stories-data.jsx +0 -89
  275. package/src/components/tree/tree.stories.jsx +0 -106
  276. package/src/docs/components/page/page.jsx +0 -16
  277. package/src/docs/config/config.js +0 -1
  278. package/src/docs/html/favicon.png +0 -0
  279. package/src/docs/html/index.html +0 -11
  280. package/src/docs/navigation/footer/footer.jsx +0 -48
  281. package/src/docs/navigation/header/header.jsx +0 -39
  282. package/src/docs/navigation/header/header.module.less +0 -32
  283. package/src/docs/navigation/routes/routes.jsx +0 -16
  284. package/src/docs/start.jsx +0 -12
  285. package/src/docs/views/main/main.jsx +0 -209
  286. package/src/docs/views/main/main.module.less +0 -14
  287. package/src/docs/views/not-found/not-found.jsx +0 -5
  288. package/src/helpers/disabled-context.js +0 -8
  289. package/src/helpers/styles.js +0 -68
  290. package/src/helpers/text.js +0 -6
  291. package/src/helpers/types.js +0 -5
  292. package/src/hooks/index.js +0 -3
  293. package/src/hooks/use-focus.js +0 -11
  294. package/src/hooks/use-keyboard-event.js +0 -16
  295. package/src/hooks/use-window-width.js +0 -20
  296. package/src/images/icons/icon-drop.png +0 -0
  297. package/src/images/icons/icon-share.png +0 -0
  298. package/src/images/icons/icons8-junction.svg +0 -4
  299. package/src/images/logo.png +0 -0
  300. package/src/images/logo.svg +0 -13
  301. package/src/images/oliasoft-logo.svg +0 -1
  302. package/src/style/colors.less +0 -26
  303. package/src/style/external.less +0 -10
  304. package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
  305. package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
  306. package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
  307. package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
  308. package/src/style/fonts.less +0 -27
  309. package/src/style/global.less +0 -51
  310. package/src/style/mixins.less +0 -68
  311. package/src/style/reset/reset.less +0 -34
  312. package/src/style/shared.less +0 -25
  313. package/src/style/theme.dark.less +0 -37
  314. package/src/style/theme.default.less +0 -74
  315. package/src/style/variables.less +0 -49
  316. package/webpack/webpack.common.js +0 -39
  317. package/webpack/webpack.common.rules.js +0 -102
  318. package/webpack/webpack.dev.js +0 -22
  319. package/webpack/webpack.prod.js +0 -23
  320. package/webpack/webpack.resolve.js +0 -22
@@ -1,30 +0,0 @@
1
- import { hasRowActions, getColumnCount } from './table.viewdata';
2
-
3
- describe('table', () => {
4
- test('hasRowActions', () => {
5
- const withActions = [{ cells: [], actions: [{}] }, { cells: [] }];
6
- const withOutActions = [{ cells: [] }, { cells: [] }];
7
- expect(hasRowActions(withOutActions, withOutActions)).toBe(false);
8
- expect(hasRowActions(withActions, withOutActions)).toBe(true);
9
- });
10
-
11
- test('getColumnCount', () => {
12
- const noRows = [];
13
- const unevenColumns = [
14
- { cells: [{}, {}, {}] },
15
- { cells: [{}, {}, {}, {}, {}] },
16
- { cells: [{}, {}, {}] },
17
- ];
18
- expect(getColumnCount(noRows, unevenColumns)).toBe(5);
19
- });
20
-
21
- test('getColumnCount with colSpan', () => {
22
- const noRows = [];
23
- const unevenColumns = [
24
- { cells: [{}, { colSpan: 2 }, {}] },
25
- { cells: [{}, {}] },
26
- { cells: [{}, {}, {}] },
27
- ];
28
- expect(getColumnCount(noRows, unevenColumns)).toBe(4);
29
- });
30
- });
@@ -1,11 +0,0 @@
1
- @import '../../style/variables.less';
2
-
3
- .cellWrapperPadding {
4
- padding: @input_padding_y @input_padding_x !important;
5
- }
6
-
7
- .flexBlock {
8
- display: flex;
9
- align-items: center;
10
- justify-content: space-between;
11
- }
@@ -1,26 +0,0 @@
1
- const getMaxCellCount = (rows) => {
2
- const count = Math.max(
3
- ...rows.reduce((acc, row) => {
4
- const count = row.cells
5
- .map((c) => (c.colSpan ? c.colSpan : 1))
6
- .reduce((a, b) => a + b, 0);
7
- return acc.concat(count);
8
- }, []),
9
- );
10
- return !isNaN(count) ? count : 0;
11
- };
12
-
13
- export const getColumnCount = (rows, headers) => {
14
- const cellCount = [getMaxCellCount(headers), getMaxCellCount(rows)];
15
- return Math.max(...cellCount);
16
- };
17
-
18
- const hasActions = (rows) =>
19
- rows.reduce(
20
- (acc, row) => (row.actions && row.actions.length > 0 ? 1 : acc),
21
- 0,
22
- );
23
-
24
- export const hasRowActions = (rows, headers) => {
25
- return hasActions(headers) > 0 || hasActions(rows) > 0;
26
- };
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import styles from './title.module.less';
4
- import { Actions } from '../../actions/actions';
5
- import { actionsShape } from '../../actions/actions.shape';
6
-
7
- export const Title = (props) => {
8
- const { colSpan, name, actions } = props;
9
- return name ? (
10
- <tr>
11
- <th colSpan={colSpan} className={styles.cellWrapper}>
12
- <div className={styles.title}>
13
- <div>{name}</div>
14
- <div>{actions && <Actions actions={actions} isBlockElement />}</div>
15
- </div>
16
- </th>
17
- </tr>
18
- ) : null;
19
- };
20
-
21
- Title.defaultProps = {
22
- name: null,
23
- actions: null,
24
- };
25
-
26
- Title.propTypes = {
27
- actions: actionsShape,
28
- colSpan: PropTypes.number.isRequired,
29
- name: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
30
- };
@@ -1,11 +0,0 @@
1
- @import '../table.variables.less';
2
-
3
- .cellWrapper {
4
- .cellWrapperPadding();
5
- }
6
-
7
- .title {
8
- display: flex;
9
- align-items: center;
10
- gap: 4px;
11
- }
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import cx from 'classnames';
3
- import styles from './tabs.module.less';
4
-
5
- export const Content = ({ children, activeTabIndex, contentPadding }) => {
6
- //The tab content is only rendered if the children props are provided, otherwise tab content is handled by the parent
7
- return (
8
- children && (
9
- <div className={cx(contentPadding ? styles.contentPadding : '')}>
10
- {children.map((child, index) => activeTabIndex === index && child)}
11
- </div>
12
- )
13
- );
14
- };
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import cx from 'classnames';
3
- import styles from './tabs.module.less';
4
- import { Badge } from '../badge/badge';
5
-
6
- export const Label = ({
7
- label,
8
- url,
9
- hidden,
10
- disabled,
11
- active,
12
- onClick,
13
- right,
14
- invalid,
15
- badge,
16
- testId,
17
- }) => {
18
- // TODO: Replace with named colors (error, success, warning) which can be defined in LESS
19
- const col_danger = getComputedStyle(document.body).getPropertyValue(
20
- '--color-text-error',
21
- );
22
- return (
23
- // eslint-disable-next-line jsx-a11y/anchor-is-valid
24
- <a
25
- id={label}
26
- href={url}
27
- className={cx(
28
- styles.item,
29
- active ? styles.active : '',
30
- disabled ? styles.disabled : '',
31
- hidden && !active ? styles.hidden : '',
32
- right ? styles.right : styles.left,
33
- )}
34
- onClick={onClick}
35
- data-testid={testId}
36
- >
37
- {invalid ? (
38
- <Badge small margin="-4px" color={col_danger} title="!">
39
- {label}
40
- </Badge>
41
- ) : badge ? (
42
- <Badge small margin="-4px" title={badge}>
43
- {label}
44
- </Badge>
45
- ) : (
46
- label
47
- )}
48
- </a>
49
- );
50
- };
@@ -1,191 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import PropTypes from 'prop-types';
3
- import cx from 'classnames';
4
- import { Label } from './label';
5
- import { Content } from './content';
6
- import styles from './tabs.module.less';
7
- import { standardizeInputs } from '../select/select.input';
8
- import { DisabledContext } from '../../helpers/disabled-context';
9
-
10
- export const Tabs = ({
11
- name,
12
- options: rawOptions,
13
- children,
14
- value: rawValue,
15
- onChange,
16
- padding,
17
- margin,
18
- contentPadding,
19
- //deprecated:
20
- onChangeTab,
21
- activeTabIndex: rawActiveTabIndex,
22
- tabs: tabsConfig,
23
- testId,
24
- }) => {
25
- const disabledContext = useContext(DisabledContext);
26
-
27
- //----------------------------------------------------------------------------
28
- // Deprecation / backwards-compatibility
29
- const isDeprecated = onChangeTab !== undefined;
30
-
31
- const rawTabs = children
32
- ? children.map((c, i) => ({
33
- value: i,
34
- url: c.props.url,
35
- label: c.props.label,
36
- hidden: c.props.hidden,
37
- disabled: c.props.disabled || disabledContext,
38
- badge: c.props.badge,
39
- testId: c.props?.testId && `${c.props.testId}-${i}`,
40
- }))
41
- : rawOptions || tabsConfig;
42
- const {
43
- simpleInputs,
44
- options: tabs,
45
- selectedOptions: value,
46
- } = isDeprecated
47
- ? {
48
- simpleInputs: false,
49
- options: rawTabs,
50
- selectedOptions: undefined,
51
- }
52
- : standardizeInputs(rawTabs, rawValue);
53
- const selectedValue =
54
- isDeprecated || value === undefined || value === null
55
- ? undefined
56
- : simpleInputs
57
- ? value
58
- : value.value;
59
- const activeTabIndexBase =
60
- rawActiveTabIndex !== undefined
61
- ? rawActiveTabIndex
62
- : tabs.findIndex((t) => t.value === selectedValue);
63
- const activeTabIndex = activeTabIndexBase === -1 ? 0 : activeTabIndexBase;
64
- //----------------------------------------------------------------------------
65
-
66
- const renderTab = (tab, index) => {
67
- const {
68
- label,
69
- url,
70
- hidden,
71
- disabled,
72
- value,
73
- right,
74
- invalid,
75
- badge,
76
- testId,
77
- } = tab;
78
- return (
79
- <Label
80
- label={label}
81
- url={url}
82
- key={index}
83
- hidden={hidden}
84
- disabled={disabled || disabledContext}
85
- invalid={invalid}
86
- badge={badge}
87
- right={right}
88
- active={
89
- isDeprecated ? index === activeTabIndex : value === selectedValue
90
- }
91
- onClick={
92
- isDeprecated
93
- ? () => {
94
- //deprecated
95
- const value = tab.key || label || null; //return key if it exists, otherwise use label
96
- onChangeTab(index, value);
97
- }
98
- : (evt) => {
99
- evt.target.name = name;
100
- evt.target.value = tab.value;
101
- evt.target.label = label;
102
- onChange(evt);
103
- }
104
- }
105
- testId={testId}
106
- />
107
- );
108
- };
109
-
110
- if (tabs) {
111
- return (
112
- <div>
113
- <div
114
- className={cx(
115
- styles.tabs,
116
- padding ? styles.padding : '',
117
- margin ? styles.margin : '',
118
- )}
119
- data-testid={testId}
120
- >
121
- {tabs.map(renderTab)}
122
- </div>
123
- <Content
124
- activeTabIndex={activeTabIndex}
125
- contentPadding={contentPadding}
126
- >
127
- {children}
128
- </Content>
129
- </div>
130
- );
131
- }
132
- return null;
133
- };
134
-
135
- Tabs.defaultProps = {
136
- name: undefined,
137
- options: null,
138
- children: null,
139
- onChange: () => {},
140
- padding: false,
141
- margin: true,
142
- contentPadding: true,
143
- //deprecated:
144
- activeTabIndex: undefined,
145
- tabs: undefined,
146
- onChangeTab: undefined,
147
- testId: undefined,
148
- };
149
-
150
- export const tabOptionShape = PropTypes.shape({
151
- label: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
152
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
153
- url: PropTypes.string,
154
- hidden: PropTypes.bool,
155
- disabled: PropTypes.bool,
156
- invalid: PropTypes.bool,
157
- badge: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
158
- right: PropTypes.bool,
159
- testId: PropTypes.string,
160
- });
161
-
162
- export const tabSelectedOptionShape = PropTypes.shape({
163
- label: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
164
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
165
- });
166
-
167
- const TabsShapeDeprecated = {
168
- tabs: PropTypes.arrayOf(tabOptionShape),
169
- children: PropTypes.node,
170
- activeTabIndex: PropTypes.number,
171
- onChangeTab: PropTypes.func,
172
- padding: PropTypes.bool,
173
- margin: PropTypes.bool,
174
- contentPadding: PropTypes.bool,
175
- };
176
-
177
- const TabsShape = {
178
- name: PropTypes.string,
179
- options: PropTypes.arrayOf(tabOptionShape),
180
- children: PropTypes.node,
181
- value: tabSelectedOptionShape,
182
- onChange: PropTypes.func,
183
- padding: PropTypes.bool,
184
- margin: PropTypes.bool,
185
- contentPadding: PropTypes.bool,
186
- };
187
-
188
- Tabs.propTypes = PropTypes.oneOfType([
189
- PropTypes.shape(TabsShape), //only use this for new usages
190
- PropTypes.shape(TabsShapeDeprecated), //deprecated Select interface
191
- ]).isRequired;
@@ -1,73 +0,0 @@
1
- @import '../../style/variables.less';
2
-
3
- .tabs {
4
- display: flex;
5
- flex-wrap: wrap;
6
- border-bottom: 1px solid var(--color-border);
7
- flex-shrink: 0;
8
-
9
- &.padding {
10
- padding-left: 20px;
11
- padding-right: 20px;
12
- }
13
-
14
- &.margin {
15
- margin: 1rem 0;
16
- }
17
- }
18
-
19
- .contentPadding {
20
- padding-top: 10px;
21
- }
22
-
23
- .item {
24
- align-self: flex-end;
25
- display: flex;
26
- align-items: center;
27
- position: relative;
28
- vertical-align: middle;
29
- line-height: 1;
30
- text-decoration: none;
31
- flex: 0 0 auto;
32
- user-select: none;
33
- padding: 0.85714286em 0;
34
- transition: border 0.1s ease, color 0.1s ease;
35
- margin-bottom: -1px;
36
- border-bottom: 1px solid transparent;
37
- text-transform: uppercase;
38
- letter-spacing: 0.05em;
39
- font-weight: normal;
40
- color: var(--color-text-primary);
41
- cursor: pointer;
42
-
43
- &:not(:last-child) {
44
- margin-right: 1.5rem;
45
- }
46
-
47
- &:hover {
48
- color: var(--color-text-primary-hover);
49
- }
50
-
51
- &:active {
52
- color: var(--color-text-primary-active);
53
- }
54
-
55
- &.active {
56
- border-color: var(--color-text);
57
- color: var(--color-text);
58
- cursor: default;
59
- }
60
-
61
- &.hidden {
62
- display: none !important;
63
- }
64
-
65
- &.disabled {
66
- color: var(--color-text-faint);
67
- pointer-events: none;
68
- }
69
-
70
- &.left + .item.right {
71
- margin-left: auto;
72
- }
73
- }
@@ -1,110 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { Tabs } from '../../..';
3
-
4
- export default {
5
- title: 'Navigation/Tabs',
6
- component: Tabs,
7
- args: {
8
- name: 'example',
9
- options: [
10
- { label: 'Tab', value: 0 },
11
- { label: 'Tab', value: 1 },
12
- { label: 'With Badge', value: 2, badge: '3' },
13
- { label: 'Invalid', value: 3, invalid: true },
14
- { label: 'Disabled', value: 4, disabled: true },
15
- { label: 'Hidden tab', value: 5, hidden: true },
16
- ],
17
- value: 0,
18
- },
19
- };
20
-
21
- const Template = (args) => (
22
- <Tabs
23
- // eslint-disable-next-line react/jsx-props-no-spreading
24
- {...args}
25
- />
26
- );
27
- export const Default = Template.bind({});
28
-
29
- export const WithChildren = Template.bind({});
30
- WithChildren.args = {
31
- children: [
32
- <div label="Tab 0">
33
- <h3>Tab 0 Content</h3>
34
- </div>,
35
- <div label="Tab 1" hidden>
36
- <h3>Tab 1 Content</h3>
37
- </div>,
38
- <div label="Tab 2" disabled>
39
- <h3>Tab 2 Content</h3>
40
- </div>,
41
- <div label="Tab 3">
42
- <h3>Tab 3 Content</h3>
43
- </div>,
44
- <div label="Tab 4">
45
- <h3>Tab 4 Content</h3>
46
- </div>,
47
- ],
48
- };
49
-
50
- export const NoMargin = Template.bind({});
51
- NoMargin.args = { margin: false };
52
-
53
- export const HorizontalPadding = Template.bind({});
54
- HorizontalPadding.parameters = {
55
- layout: 'fullscreen',
56
- docs: {
57
- description: {
58
- story: 'When you want the divider to fill the edges of its container.',
59
- },
60
- },
61
- };
62
- HorizontalPadding.args = { padding: true };
63
-
64
- export const Alignment = Template.bind({});
65
- Alignment.args = {
66
- options: [
67
- { label: 'Tab 0', value: 0 },
68
- { label: 'Tab 1', value: 1 },
69
- { label: 'Tab 2', value: 2 },
70
- { label: 'Tab 3', value: 3, right: true },
71
- { label: 'Tab 4', value: 4, right: true },
72
- ],
73
- };
74
-
75
- export const Managed = () => {
76
- const options = [
77
- {
78
- label: 'Strawberries',
79
- value: 'strawberries',
80
- },
81
- {
82
- label: 'Bananas',
83
- value: 'bananas',
84
- },
85
- {
86
- label: 'Apples',
87
- value: 'apples',
88
- disabled: true,
89
- },
90
- {
91
- label: 'Pomegranates',
92
- value: 'pomegranates',
93
- },
94
- ];
95
- const [selectedTab, setSelectedTab] = useState(options[0]);
96
- return (
97
- <>
98
- <Tabs
99
- name="example"
100
- value={selectedTab}
101
- options={options}
102
- onChange={(evt) => {
103
- const { value, label } = evt.target;
104
- setSelectedTab({ value, label });
105
- }}
106
- />
107
- <span>Eating {selectedTab.value}...</span>
108
- </>
109
- );
110
- };
@@ -1,64 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import cx from 'classnames';
4
- import styles from './text.module.less';
5
-
6
- export const Text = ({
7
- children,
8
- bold,
9
- center,
10
- error,
11
- faint,
12
- link,
13
- muted,
14
- onClick,
15
- small,
16
- success,
17
- warning,
18
- }) => {
19
- return (
20
- <span
21
- className={cx(
22
- bold && styles.bold,
23
- center && styles.center,
24
- error && styles.error,
25
- faint && styles.faint,
26
- link && styles.link,
27
- muted && styles.muted,
28
- onClick && styles.clickable,
29
- small && styles.small,
30
- success && styles.success,
31
- warning && styles.warning,
32
- )}
33
- onClick={onClick}
34
- >
35
- {children}
36
- </span>
37
- );
38
- };
39
-
40
- Text.defaultProps = {
41
- bold: false,
42
- center: false,
43
- error: false,
44
- faint: false,
45
- link: false,
46
- muted: false,
47
- onClick: null,
48
- small: false,
49
- success: false,
50
- warning: false,
51
- };
52
-
53
- Text.propTypes = {
54
- bold: PropTypes.bool,
55
- center: PropTypes.bool,
56
- error: PropTypes.bool,
57
- faint: PropTypes.bool,
58
- link: PropTypes.bool,
59
- muted: PropTypes.bool,
60
- onClick: PropTypes.func,
61
- small: PropTypes.bool,
62
- success: PropTypes.bool,
63
- warning: PropTypes.bool,
64
- };
@@ -1,45 +0,0 @@
1
- @import '../../style/variables.less';
2
-
3
- .bold {
4
- font-weight: bold;
5
- }
6
-
7
- .center {
8
- text-align: center;
9
- }
10
-
11
- .muted {
12
- color: var(--color-text-muted);
13
- }
14
-
15
- .faint {
16
- color: var(--color-text-faint);
17
- }
18
-
19
- .success {
20
- color: var(--color-text-success);
21
- }
22
-
23
- .warning {
24
- color: var(--color-text-warning);
25
- }
26
-
27
- .error {
28
- color: var(--color-text-error);
29
- }
30
-
31
- .small {
32
- font-size: 0.9em;
33
- }
34
-
35
- .link {
36
- color: var(--color-text-primary);
37
- cursor: pointer;
38
-
39
- &:hover {
40
- color: var(--color-text-primary-hover);
41
- }
42
- &:active {
43
- color: var(--color-text-primary-active);
44
- }
45
- }
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import { Text } from '../../..';
3
-
4
- export default {
5
- title: 'Basic/Text',
6
- component: Text,
7
- args: {
8
- children: 'Text goes here',
9
- small: false,
10
- muted: false,
11
- error: false,
12
- warning: false,
13
- success: false,
14
- link: false,
15
- onClick: undefined,
16
- },
17
- };
18
-
19
- const Template = (args) => (
20
- <Text
21
- // eslint-disable-next-line react/jsx-props-no-spreading
22
- {...args}
23
- />
24
- );
25
- export const Default = Template.bind({});
26
-
27
- export const Small = Template.bind({});
28
- Small.args = { small: true };
29
-
30
- export const Link = Template.bind({});
31
- Link.args = { link: true, onClick: () => {} };