@qoretechnologies/reqore 0.30.6 → 0.30.7

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 (232) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -44
  3. package/__tests__/collection.test.tsx +1 -1
  4. package/__tests__/{control_group.text.tsx → control_group.test.tsx} +4 -2
  5. package/__tests__/modal.test.tsx +74 -2
  6. package/__tests__/panel.test.tsx +96 -24
  7. package/__tests__/popover.test.tsx +24 -2
  8. package/__tests__/tabs.test.tsx +75 -0
  9. package/dist/components/Button/index.d.ts +7 -2
  10. package/dist/components/Button/index.d.ts.map +1 -1
  11. package/dist/components/Button/index.js +30 -20
  12. package/dist/components/Button/index.js.map +1 -1
  13. package/dist/components/Checkbox/index.d.ts.map +1 -1
  14. package/dist/components/Checkbox/index.js +6 -3
  15. package/dist/components/Checkbox/index.js.map +1 -1
  16. package/dist/components/Collection/index.d.ts +7 -2
  17. package/dist/components/Collection/index.d.ts.map +1 -1
  18. package/dist/components/Collection/index.js +57 -53
  19. package/dist/components/Collection/index.js.map +1 -1
  20. package/dist/components/Collection/item.d.ts +5 -5
  21. package/dist/components/Collection/item.d.ts.map +1 -1
  22. package/dist/components/Collection/item.js +15 -4
  23. package/dist/components/Collection/item.js.map +1 -1
  24. package/dist/components/Columns/column.d.ts.map +1 -1
  25. package/dist/components/Columns/column.js +1 -1
  26. package/dist/components/Columns/column.js.map +1 -1
  27. package/dist/components/ControlGroup/index.d.ts +21 -4
  28. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  29. package/dist/components/ControlGroup/index.js +250 -55
  30. package/dist/components/ControlGroup/index.js.map +1 -1
  31. package/dist/components/Drawer/index.d.ts +3 -3
  32. package/dist/components/Drawer/index.d.ts.map +1 -1
  33. package/dist/components/Drawer/index.js +27 -16
  34. package/dist/components/Drawer/index.js.map +1 -1
  35. package/dist/components/Dropdown/index.d.ts +1 -0
  36. package/dist/components/Dropdown/index.d.ts.map +1 -1
  37. package/dist/components/Dropdown/index.js +2 -2
  38. package/dist/components/Dropdown/index.js.map +1 -1
  39. package/dist/components/Dropdown/list.d.ts +3 -3
  40. package/dist/components/Dropdown/list.d.ts.map +1 -1
  41. package/dist/components/Effect/index.d.ts +10 -10
  42. package/dist/components/Effect/index.d.ts.map +1 -1
  43. package/dist/components/Effect/index.js +7 -6
  44. package/dist/components/Effect/index.js.map +1 -1
  45. package/dist/components/Icon/index.d.ts +5 -6
  46. package/dist/components/Icon/index.d.ts.map +1 -1
  47. package/dist/components/Icon/index.js +14 -7
  48. package/dist/components/Icon/index.js.map +1 -1
  49. package/dist/components/Input/index.d.ts +2 -0
  50. package/dist/components/Input/index.d.ts.map +1 -1
  51. package/dist/components/Input/index.js +10 -4
  52. package/dist/components/Input/index.js.map +1 -1
  53. package/dist/components/InternalPopover/index.d.ts.map +1 -1
  54. package/dist/components/InternalPopover/index.js +12 -10
  55. package/dist/components/InternalPopover/index.js.map +1 -1
  56. package/dist/components/Menu/index.d.ts.map +1 -1
  57. package/dist/components/Menu/index.js +1 -1
  58. package/dist/components/Menu/index.js.map +1 -1
  59. package/dist/components/Message/index.d.ts +2 -0
  60. package/dist/components/Message/index.d.ts.map +1 -1
  61. package/dist/components/Message/index.js +2 -2
  62. package/dist/components/Message/index.js.map +1 -1
  63. package/dist/components/MultiSelect/index.d.ts +2 -2
  64. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  65. package/dist/components/MultiSelect/index.js +10 -10
  66. package/dist/components/MultiSelect/index.js.map +1 -1
  67. package/dist/components/Notifications/index.d.ts +1 -1
  68. package/dist/components/Notifications/index.d.ts.map +1 -1
  69. package/dist/components/Notifications/notification.d.ts +1 -1
  70. package/dist/components/Notifications/notification.d.ts.map +1 -1
  71. package/dist/components/Panel/index.d.ts +13 -6
  72. package/dist/components/Panel/index.d.ts.map +1 -1
  73. package/dist/components/Panel/index.js +78 -44
  74. package/dist/components/Panel/index.js.map +1 -1
  75. package/dist/components/Popover/index.d.ts +1 -2
  76. package/dist/components/Popover/index.d.ts.map +1 -1
  77. package/dist/components/Popover/index.js +2 -2
  78. package/dist/components/Popover/index.js.map +1 -1
  79. package/dist/components/Spacer/index.d.ts +2 -0
  80. package/dist/components/Spacer/index.d.ts.map +1 -1
  81. package/dist/components/Spacer/index.js +29 -7
  82. package/dist/components/Spacer/index.js.map +1 -1
  83. package/dist/components/Table/header.js +2 -2
  84. package/dist/components/Table/header.js.map +1 -1
  85. package/dist/components/Table/headerCell.js +2 -2
  86. package/dist/components/Table/headerCell.js.map +1 -1
  87. package/dist/components/Table/helpers.d.ts +3 -2
  88. package/dist/components/Table/helpers.d.ts.map +1 -1
  89. package/dist/components/Table/helpers.js +6 -3
  90. package/dist/components/Table/helpers.js.map +1 -1
  91. package/dist/components/Table/index.d.ts +4 -3
  92. package/dist/components/Table/index.d.ts.map +1 -1
  93. package/dist/components/Table/index.js.map +1 -1
  94. package/dist/components/Table/row.d.ts +0 -5
  95. package/dist/components/Table/row.d.ts.map +1 -1
  96. package/dist/components/Table/row.js +3 -7
  97. package/dist/components/Table/row.js.map +1 -1
  98. package/dist/components/Tabs/content.d.ts +3 -1
  99. package/dist/components/Tabs/content.d.ts.map +1 -1
  100. package/dist/components/Tabs/content.js +8 -3
  101. package/dist/components/Tabs/content.js.map +1 -1
  102. package/dist/components/Tabs/index.d.ts +4 -1
  103. package/dist/components/Tabs/index.d.ts.map +1 -1
  104. package/dist/components/Tabs/index.js +12 -4
  105. package/dist/components/Tabs/index.js.map +1 -1
  106. package/dist/components/Tabs/item.d.ts +1 -0
  107. package/dist/components/Tabs/item.d.ts.map +1 -1
  108. package/dist/components/Tabs/item.js +7 -7
  109. package/dist/components/Tabs/item.js.map +1 -1
  110. package/dist/components/Tabs/list.d.ts +1 -1
  111. package/dist/components/Tabs/list.d.ts.map +1 -1
  112. package/dist/components/Tabs/list.js +7 -6
  113. package/dist/components/Tabs/list.js.map +1 -1
  114. package/dist/components/Tag/group.d.ts +2 -2
  115. package/dist/components/Tag/group.d.ts.map +1 -1
  116. package/dist/components/Tag/group.js +7 -8
  117. package/dist/components/Tag/group.js.map +1 -1
  118. package/dist/components/Tag/index.d.ts +6 -2
  119. package/dist/components/Tag/index.d.ts.map +1 -1
  120. package/dist/components/Tag/index.js +24 -12
  121. package/dist/components/Tag/index.js.map +1 -1
  122. package/dist/components/Tree/index.js +1 -1
  123. package/dist/components/Tree/index.js.map +1 -1
  124. package/dist/constants/animations.js +1 -1
  125. package/dist/constants/sizes.d.ts +2 -2
  126. package/dist/constants/sizes.d.ts.map +1 -1
  127. package/dist/constants/sizes.js +10 -10
  128. package/dist/constants/sizes.js.map +1 -1
  129. package/dist/constants/theme.d.ts +1 -1
  130. package/dist/constants/theme.d.ts.map +1 -1
  131. package/dist/containers/PopoverProvider.d.ts.map +1 -1
  132. package/dist/containers/PopoverProvider.js +10 -8
  133. package/dist/containers/PopoverProvider.js.map +1 -1
  134. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  135. package/dist/containers/ReqoreProvider.js +4 -2
  136. package/dist/containers/ReqoreProvider.js.map +1 -1
  137. package/dist/containers/UIProvider.d.ts +7 -0
  138. package/dist/containers/UIProvider.d.ts.map +1 -1
  139. package/dist/containers/UIProvider.js.map +1 -1
  140. package/dist/context/ReqoreContext.d.ts +2 -0
  141. package/dist/context/ReqoreContext.d.ts.map +1 -1
  142. package/dist/context/ReqoreContext.js.map +1 -1
  143. package/dist/helpers/colors.d.ts +1 -1
  144. package/dist/helpers/colors.d.ts.map +1 -1
  145. package/dist/helpers/colors.js +6 -2
  146. package/dist/helpers/colors.js.map +1 -1
  147. package/dist/helpers/utils.d.ts +3 -0
  148. package/dist/helpers/utils.d.ts.map +1 -1
  149. package/dist/helpers/utils.js +17 -2
  150. package/dist/helpers/utils.js.map +1 -1
  151. package/dist/hooks/useLatestZIndex.js +2 -2
  152. package/dist/hooks/useLatestZIndex.js.map +1 -1
  153. package/dist/hooks/usePopover.d.ts +1 -0
  154. package/dist/hooks/usePopover.d.ts.map +1 -1
  155. package/dist/hooks/usePopover.js +8 -6
  156. package/dist/hooks/usePopover.js.map +1 -1
  157. package/dist/styles.d.ts +1 -0
  158. package/dist/styles.d.ts.map +1 -1
  159. package/dist/styles.js +6 -5
  160. package/dist/styles.js.map +1 -1
  161. package/dist/types/global.d.ts +27 -1
  162. package/dist/types/global.d.ts.map +1 -1
  163. package/dist/types/icons.d.ts +1 -1
  164. package/dist/types/icons.d.ts.map +1 -1
  165. package/package.json +1 -1
  166. package/src/components/Button/index.tsx +79 -34
  167. package/src/components/Checkbox/index.tsx +3 -2
  168. package/src/components/Collection/index.tsx +93 -60
  169. package/src/components/Collection/item.tsx +29 -9
  170. package/src/components/Columns/column.tsx +1 -0
  171. package/src/components/ControlGroup/index.tsx +449 -104
  172. package/src/components/Drawer/index.tsx +28 -27
  173. package/src/components/Dropdown/index.tsx +3 -1
  174. package/src/components/Effect/index.tsx +22 -14
  175. package/src/components/Icon/index.tsx +81 -62
  176. package/src/components/Input/index.tsx +8 -3
  177. package/src/components/InternalPopover/index.tsx +131 -126
  178. package/src/components/Menu/index.tsx +7 -1
  179. package/src/components/Message/index.tsx +9 -1
  180. package/src/components/MultiSelect/index.tsx +180 -188
  181. package/src/components/Panel/index.tsx +227 -100
  182. package/src/components/Popover/index.tsx +1 -3
  183. package/src/components/Spacer/index.tsx +63 -14
  184. package/src/components/Table/header.tsx +2 -2
  185. package/src/components/Table/headerCell.tsx +2 -2
  186. package/src/components/Table/helpers.ts +12 -6
  187. package/src/components/Table/index.tsx +1 -0
  188. package/src/components/Table/row.tsx +2 -7
  189. package/src/components/Tabs/content.tsx +11 -3
  190. package/src/components/Tabs/index.tsx +14 -3
  191. package/src/components/Tabs/item.tsx +28 -5
  192. package/src/components/Tabs/list.tsx +7 -3
  193. package/src/components/Tag/group.tsx +6 -12
  194. package/src/components/Tag/index.tsx +69 -35
  195. package/src/components/Tree/index.tsx +1 -1
  196. package/src/constants/animations.ts +1 -1
  197. package/src/constants/sizes.ts +10 -10
  198. package/src/containers/PopoverProvider.tsx +11 -8
  199. package/src/containers/ReqoreProvider.tsx +40 -35
  200. package/src/containers/UIProvider.tsx +7 -0
  201. package/src/context/ReqoreContext.tsx +2 -0
  202. package/src/helpers/colors.ts +8 -2
  203. package/src/helpers/utils.ts +18 -0
  204. package/src/hooks/useLatestZIndex.ts +2 -2
  205. package/src/hooks/usePopover.tsx +9 -6
  206. package/src/mock/collectionData.tsx +33 -2
  207. package/src/stories/Button/Button.stories.tsx +72 -7
  208. package/src/stories/Checkbox/Checkbox.stories.tsx +6 -3
  209. package/src/stories/Collection/Collection.stories.tsx +18 -2
  210. package/src/stories/ControlGroup/ControlGroup.stories.tsx +282 -33
  211. package/src/stories/Drawer/Drawer.stories.tsx +70 -3
  212. package/src/stories/Dropdown/Dropdown.stories.tsx +13 -3
  213. package/src/stories/Icon/Icon.stories.tsx +1 -0
  214. package/src/stories/Input/Input.stories.tsx +5 -3
  215. package/src/stories/Menu/Menu.stories.tsx +2 -0
  216. package/src/stories/Message/Message.stories.tsx +7 -0
  217. package/src/stories/Panel/Panel.stories.tsx +147 -13
  218. package/src/stories/Popover/Popover.stories.tsx +88 -82
  219. package/src/stories/Tabs/Tabs.stories.tsx +33 -15
  220. package/src/stories/Tag/Tag.stories.tsx +23 -3
  221. package/src/stories/TextArea/TextArea.stories.tsx +3 -3
  222. package/src/styles.ts +6 -0
  223. package/src/types/global.ts +28 -0
  224. package/tests.json +1 -1
  225. package/CODE_OF_CONDUCT.md +0 -105
  226. package/CONTRIBUTING.MD +0 -78
  227. package/SECURITY.md +0 -5
  228. package/public/logo-dark.png +0 -0
  229. package/public/logo.png +0 -0
  230. package/public/q-symbol.png +0 -0
  231. package/public/qoreLogo-dark.png +0 -0
  232. package/public/qoreLogo.png +0 -0
@@ -1,4 +1,4 @@
1
- import { memo } from 'react';
1
+ import { memo, useMemo } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { SIZE_TO_NUMBER, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
4
4
  import { changeLightness } from '../../helpers/colors';
@@ -6,32 +6,68 @@ import { useReqoreTheme } from '../../hooks/useTheme';
6
6
  import { IReqoreIntent, IWithReqoreCustomTheme, IWithReqoreEffect } from '../../types/global';
7
7
  import { StyledEffect } from '../Effect';
8
8
 
9
- export const StyledSpacer = styled(StyledEffect)`
9
+ export const StyledSpacer = styled.div`
10
+ display: ${({ horizontal }) => (horizontal ? 'inline-flex' : 'flex')};
11
+ vertical-align: middle;
12
+
13
+ ${({ horizontal, vertical }) => {
14
+ if (horizontal) {
15
+ return css`
16
+ flex-flow: row;
17
+ `;
18
+ }
19
+
20
+ if (vertical) {
21
+ return css`
22
+ flex-flow: column;
23
+ `;
24
+ }
25
+ }}
26
+
27
+ flex-shrink: 0;
28
+ `;
29
+
30
+ export const StyledSpace = styled.div`
31
+ display: inline-block;
32
+ flex: 0 0 auto;
33
+
10
34
  ${({ horizontal, vertical, width, height, lineSize }) => {
11
35
  if (horizontal) {
12
36
  return css`
13
- margin-left: ${width / 2}px;
14
- margin-right: ${width / 2}px;
15
- width: ${lineSize === 'none' ? 1 : SIZE_TO_NUMBER[lineSize]}px;
37
+ width: ${width / 2 - lineSize / 2}px;
16
38
  height: ${height ? `${height}px` : `${TEXT_FROM_SIZE.normal}px`};
17
- vertical-align: middle;
18
- display: inline-block;
19
39
  `;
20
40
  }
21
41
 
22
42
  if (vertical) {
23
43
  return css`
24
- margin-top: ${height / 2}px;
25
- margin-bottom: ${height / 2}px;
26
- height: ${lineSize === 'none' ? 1 : SIZE_TO_NUMBER[lineSize]}px;
27
44
  width: ${width ? `${width}px` : '100%'};
45
+ height: ${height / 2 - lineSize / 2}px;
28
46
  `;
29
47
  }
30
48
  }}
49
+ `;
31
50
 
51
+ export const StyledLine = styled(StyledEffect)`
52
+ flex-shrink: 0;
32
53
  background-color: ${({ theme, lineSize }) =>
33
54
  lineSize === 'none' ? 'transparent' : changeLightness(theme.main, 0.2)};
34
- flex-shrink: 0;
55
+
56
+ ${({ horizontal, vertical, width, height, lineSize }) => {
57
+ if (horizontal) {
58
+ return css`
59
+ width: ${lineSize}px;
60
+ height: ${height ? `${height}px` : `${TEXT_FROM_SIZE.normal}px`};
61
+ `;
62
+ }
63
+
64
+ if (vertical) {
65
+ return css`
66
+ width: ${width ? `${width}px` : '100%'};
67
+ height: ${lineSize}px;
68
+ `;
69
+ }
70
+ }}
35
71
  `;
36
72
 
37
73
  export interface IReqoreSpacerProps
@@ -66,16 +102,29 @@ export const ReqoreSpacer = memo(
66
102
  }
67
103
  }
68
104
 
105
+ const _lineSize = useMemo(
106
+ () => (lineSize === 'none' ? 0 : SIZE_TO_NUMBER[lineSize]),
107
+ [lineSize]
108
+ );
109
+
69
110
  return (
70
111
  <StyledSpacer
71
112
  as='div'
72
113
  {...rest}
73
- theme={theme}
74
- lineSize={lineSize}
75
114
  horizontal={horizontal}
76
115
  vertical={vertical}
77
116
  className='reqore-spacer'
78
- />
117
+ >
118
+ <StyledSpace {...rest} horizontal={horizontal} vertical={vertical} lineSize={_lineSize} />
119
+ <StyledLine
120
+ {...rest}
121
+ horizontal={horizontal}
122
+ vertical={vertical}
123
+ theme={theme}
124
+ lineSize={_lineSize}
125
+ />
126
+ <StyledSpace {...rest} horizontal={horizontal} vertical={vertical} lineSize={_lineSize} />
127
+ </StyledSpacer>
79
128
  );
80
129
  }
81
130
  );
@@ -2,9 +2,9 @@ import styled, { css } from 'styled-components';
2
2
  import { IReqoreTableColumn, IReqoreTableSort } from '.';
3
3
  import { IReqoreTheme } from '../../constants/theme';
4
4
  import { changeLightness } from '../../helpers/colors';
5
+ import { alignToFlexAlign } from '../../helpers/utils';
5
6
  import { IReqoreIconName } from '../../types/icons';
6
7
  import ReqoreTableHeaderCell, { StyledTableHeader } from './headerCell';
7
- import { alignToFlex } from './row';
8
8
 
9
9
  export interface IReqoreTableSectionProps {
10
10
  columns: IReqoreTableColumn[];
@@ -46,7 +46,7 @@ export interface IReqoreTableHeaderStyle {
46
46
  export const StyledColumnGroupHeader = styled.div<IReqoreTableHeaderStyle>`
47
47
  ${({ align, theme }) => css`
48
48
  background-color: ${changeLightness(theme.main, 0.035)};
49
- justify-content: ${align ? alignToFlex[align] : 'flex-start'};
49
+ justify-content: ${align ? alignToFlexAlign(align) : 'flex-start'};
50
50
  `}
51
51
  `;
52
52
 
@@ -4,9 +4,9 @@ import styled, { css } from 'styled-components';
4
4
  import { IReqoreTableColumn, IReqoreTableSort } from '.';
5
5
  import { IReqoreTheme } from '../../constants/theme';
6
6
  import { changeLightness, getReadableColor } from '../../helpers/colors';
7
+ import { alignToFlexAlign } from '../../helpers/utils';
7
8
  import { useTooltip } from '../../hooks/useTooltip';
8
9
  import ReqoreIcon from '../Icon';
9
- import { alignToFlex } from './row';
10
10
 
11
11
  export interface IReqoreTableHeaderCellProps
12
12
  extends React.HTMLAttributes<HTMLDivElement>,
@@ -32,7 +32,7 @@ export const StyledTableHeader = styled.div<IReqoreTableHeaderStyle>`
32
32
 
33
33
  ${({ align, theme }) => css`
34
34
  background-color: ${changeLightness(theme.main, 0.03)};
35
- justify-content: ${align ? alignToFlex[align] : 'flex-start'};
35
+ justify-content: ${align ? alignToFlexAlign(align) : 'flex-start'};
36
36
  `}
37
37
 
38
38
  ${({ interactive, theme }) =>
@@ -1,19 +1,25 @@
1
- import { firstBy } from "thenby";
2
- import { IReqoreTableSort } from ".";
1
+ import { firstBy } from 'thenby';
2
+ import { IReqoreTableSort } from '.';
3
3
 
4
- export const flipSortDirection = (direction: "asc" | "desc"): "asc" | "desc" =>
5
- direction === "asc" ? "desc" : "asc";
4
+ export const flipSortDirection = (direction: 'asc' | 'desc'): 'asc' | 'desc' =>
5
+ direction === 'asc' ? 'desc' : 'asc';
6
6
 
7
7
  export const fixSort = (sort?: IReqoreTableSort) => {
8
- return { ...(sort || {}), direction: sort?.direction || "desc" };
8
+ return { ...(sort || {}), direction: sort?.direction || 'desc' };
9
9
  };
10
10
 
11
11
  export const sortTableData = (data: any[], sort: IReqoreTableSort) => {
12
- const { by, direction } = sort;
12
+ const { by, thenBy, direction } = sort;
13
13
 
14
14
  if (!by) {
15
15
  return data;
16
16
  }
17
17
 
18
+ if (thenBy) {
19
+ return [...data].sort(
20
+ firstBy(by, { ignoreCase: true, direction }).thenBy(thenBy, { ignoreCase: true, direction })
21
+ );
22
+ }
23
+
18
24
  return [...data].sort(firstBy(by, { ignoreCase: true, direction }));
19
25
  };
@@ -89,6 +89,7 @@ export interface IReqoreTableStyle {
89
89
 
90
90
  export interface IReqoreTableSort {
91
91
  by?: string;
92
+ thenBy?: string;
92
93
  direction?: 'asc' | 'desc';
93
94
  }
94
95
 
@@ -13,6 +13,7 @@ import { ReqorePopover } from '../..';
13
13
  import { SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
14
14
  import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
15
15
  import { changeLightness, getReadableColorFrom } from '../../helpers/colors';
16
+ import { alignToFlexAlign } from '../../helpers/utils';
16
17
  import { TReqoreColor, TReqoreHexColor } from '../Effect';
17
18
  import { ReqoreH4 } from '../Header';
18
19
  import ReqoreIcon from '../Icon';
@@ -75,12 +76,6 @@ export interface IReqoreTableCellStyle {
75
76
  striped?: boolean;
76
77
  }
77
78
 
78
- export const alignToFlex = {
79
- center: 'center',
80
- left: 'flex-start',
81
- right: 'flex-end',
82
- };
83
-
84
79
  export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
85
80
  ${({ width, grow }) =>
86
81
  css`
@@ -137,7 +132,7 @@ export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
137
132
  return css`
138
133
  display: flex;
139
134
  align-items: center;
140
- justify-content: ${align ? alignToFlex[align] : 'flex-start'};
135
+ justify-content: ${align ? alignToFlexAlign(align) : 'flex-start'};
141
136
  flex-shrink: 0;
142
137
  border-bottom: ${!flat ? '1px solid ' : undefined};
143
138
 
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
+ export type TReqoreTabsContentPadding = 'horizontal' | 'vertical' | 'none' | 'both' | true | false;
5
+
4
6
  export interface IReqoreTabsContent extends React.HTMLAttributes<HTMLDivElement> {
5
7
  children?: any;
6
8
  tabId: string | number;
9
+ padded?: TReqoreTabsContentPadding;
7
10
  }
8
11
 
9
12
  const StyledTabsContent = styled.div`
@@ -11,11 +14,16 @@ const StyledTabsContent = styled.div`
11
14
  flex-flow: column;
12
15
  overflow: hidden;
13
16
  flex: 1;
14
- padding: 10px;
17
+ padding: ${({ padded }: IReqoreTabsContent) =>
18
+ padded === 'none' || padded === false
19
+ ? undefined
20
+ : `${padded === 'both' || padded === true || padded === 'vertical' ? 10 : 0}px ${
21
+ padded === 'both' || padded === true || padded === 'horizontal' ? 10 : 0
22
+ }px}`};
15
23
  `;
16
24
 
17
- const ReqoreTabsContent = ({ children, className, ...rest }: IReqoreTabsContent) => (
18
- <StyledTabsContent {...rest} className={`${className || ''} reqore-tabs-content`}>
25
+ const ReqoreTabsContent = ({ children, className, padded = true, ...rest }: IReqoreTabsContent) => (
26
+ <StyledTabsContent {...rest} padded={padded} className={`${className || ''} reqore-tabs-content`}>
19
27
  {children}
20
28
  </StyledTabsContent>
21
29
  );
@@ -1,9 +1,11 @@
1
- import React, { ReactElement, useEffect, useState } from 'react';
1
+ import React, { ReactElement, useState } from 'react';
2
+ import { useUpdateEffect } from 'react-use';
2
3
  import styled, { css } from 'styled-components';
3
4
  import { TSizes } from '../../constants/sizes';
4
5
  import { IReqoreCustomTheme, TReqoreIntent } from '../../constants/theme';
5
6
  import { IReqoreIconName } from '../../types/icons';
6
7
  import { IReqoreButtonProps } from '../Button';
8
+ import { TReqoreTabsContentPadding } from './content';
7
9
  import ReqoreTabsList from './list';
8
10
 
9
11
  export interface IReqoreTabsListItem extends Omit<IReqoreButtonProps, 'id'> {
@@ -26,6 +28,8 @@ export interface IReqoreTabsProps extends React.HTMLAttributes<HTMLDivElement> {
26
28
  fillParent?: boolean;
27
29
  vertical?: boolean;
28
30
  activeTabIntent?: TReqoreIntent;
31
+ padded?: boolean;
32
+ tabsPadding?: TReqoreTabsContentPadding;
29
33
  wrapTabNames?: boolean;
30
34
  flat?: boolean;
31
35
  size?: TSizes;
@@ -61,11 +65,13 @@ const ReqoreTabs = ({
61
65
  wrapTabNames,
62
66
  customTheme,
63
67
  intent,
68
+ padded,
69
+ tabsPadding,
64
70
  ...rest
65
71
  }: IReqoreTabsProps) => {
66
72
  const [_activeTab, setActiveTab] = useState<string | number>(activeTab || tabs[0].id);
67
73
 
68
- useEffect(() => {
74
+ useUpdateEffect(() => {
69
75
  if (activeTab || activeTab === 0) {
70
76
  setActiveTab(activeTab);
71
77
 
@@ -84,6 +90,7 @@ const ReqoreTabs = ({
84
90
  >
85
91
  <ReqoreTabsList
86
92
  tabs={tabs}
93
+ padded={padded}
87
94
  flat={flat}
88
95
  fill={fill}
89
96
  size={size}
@@ -104,7 +111,11 @@ const ReqoreTabs = ({
104
111
  }}
105
112
  />
106
113
  {React.Children.map(children, (child) =>
107
- child && child.props?.tabId === _activeTab ? child : null
114
+ child && child.props?.tabId === _activeTab
115
+ ? React.cloneElement(child, {
116
+ padded: child.props?.padded || tabsPadding,
117
+ })
118
+ : null
108
119
  )}
109
120
  </StyledTabs>
110
121
  );
@@ -18,6 +18,7 @@ export interface IReqoreTabListItemProps extends IReqoreTabsListItem, IWithReqor
18
18
  wrapTabNames?: boolean;
19
19
  fill?: boolean;
20
20
  className?: string;
21
+ padded?: boolean;
21
22
  }
22
23
 
23
24
  export interface IReqoreTabListItemStyle extends IReqoreTabListItemProps {
@@ -27,7 +28,7 @@ export interface IReqoreTabListItemStyle extends IReqoreTabListItemProps {
27
28
  }
28
29
 
29
30
  export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
30
- ${({ disabled, vertical, size, fill }: IReqoreTabListItemStyle) => {
31
+ ${({ disabled, vertical, size, fill, padded }: IReqoreTabListItemStyle) => {
31
32
  return css`
32
33
  display: flex;
33
34
  flex-shrink: 0;
@@ -45,20 +46,40 @@ export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
45
46
  border-right: 0;
46
47
  }
47
48
  ${StyledButton}:last-child {
48
- border-top-right-radius: 0;
49
- border-bottom-right-radius: 0;
49
+ border-top-right-radius: 0 !important;
50
+ border-bottom-right-radius: 0 !important;
50
51
  }
52
+
53
+ ${padded === false &&
54
+ css`
55
+ &:first-child {
56
+ padding-top: 0;
57
+ }
58
+ &:last-child {
59
+ padding-bottom: 0;
60
+ }
61
+ `}
51
62
  `
52
63
  : css`
53
64
  ${StyledButton} {
54
65
  border-bottom: 0;
55
66
  }
56
67
  ${StyledButton}:first-child {
57
- border-bottom-left-radius: 0;
68
+ border-bottom-left-radius: 0 !important;
58
69
  }
59
70
  ${StyledButton}:last-child {
60
- border-bottom-right-radius: 0;
71
+ border-bottom-right-radius: 0 !important;
61
72
  }
73
+
74
+ ${padded === false &&
75
+ css`
76
+ &:first-child {
77
+ padding-left: 0;
78
+ }
79
+ &:last-child {
80
+ padding-right: 0;
81
+ }
82
+ `}
62
83
  `}
63
84
 
64
85
  ${fill &&
@@ -109,6 +130,7 @@ const ReqoreTabsListItem = memo(
109
130
  flat = true,
110
131
  wrapTabNames,
111
132
  id,
133
+ padded,
112
134
  ...rest
113
135
  }: IReqoreTabListItemProps,
114
136
  ref
@@ -129,6 +151,7 @@ const ReqoreTabsListItem = memo(
129
151
  vertical={vertical}
130
152
  theme={theme}
131
153
  fill={fill}
154
+ padded={padded}
132
155
  >
133
156
  {label || icon ? (
134
157
  <ReqoreControlGroup stack size={size} fluid={fill || vertical}>
@@ -162,6 +162,7 @@ const ReqoreTabsList = ({
162
162
  flat,
163
163
  size,
164
164
  intent,
165
+ padded,
165
166
  ...rest
166
167
  }: IReqoreTabsListProps) => {
167
168
  const [ref, { width }] = useMeasure();
@@ -203,19 +204,21 @@ const ReqoreTabsList = ({
203
204
  label: getMoreLabel(item, activeTab),
204
205
  active: !!isTabHidden(item, activeTab),
205
206
  activeIntent: activeTabIntent,
207
+ intent: !!isTabHidden(item, activeTab) ? activeTabData?.intent : undefined,
208
+ effect: !!isTabHidden(item, activeTab) ? activeTabData?.effect : undefined,
206
209
  customTheme: !!isTabHidden(item, activeTab)
207
- ? {
208
- main: currentTabColor,
209
- }
210
+ ? activeTabData?.customTheme
210
211
  : theme,
211
212
  vertical,
212
213
  flat,
213
214
  size,
215
+ padded,
214
216
  className: 'reqore-tabs-list-item-menu',
215
217
  } as IReqoreTabListItemProps
216
218
  }
217
219
  closeOnOutsideClick
218
220
  isReqoreComponent
221
+ noWrapper
219
222
  handler='hoverStay'
220
223
  content={
221
224
  <ReqoreMenu customTheme={theme}>
@@ -278,6 +281,7 @@ const ReqoreTabsList = ({
278
281
  fill={fill}
279
282
  size={size}
280
283
  flat={flat}
284
+ padded={padded}
281
285
  activeIntent={activeTabIntent}
282
286
  wrapTabNames={wrapTabNames}
283
287
  {...item}
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
- import { StyledTag } from '.';
4
3
  import { GAP_FROM_SIZE, TSizes } from '../../constants/sizes';
5
4
  import { IWithReqoreMinimal, IWithReqoreSize } from '../../types/global';
6
5
 
@@ -11,19 +10,14 @@ export interface IReqoreTagGroup
11
10
  children: any;
12
11
  gapSize?: TSizes;
13
12
  columns?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
14
- hasBottomMargin?: boolean;
13
+ wrap?: boolean;
15
14
  }
16
15
 
17
16
  const StyledTagGroup = styled.div`
18
17
  flex-shrink: 0;
19
-
20
- ${StyledTag} {
21
- &:not(:last-child) {
22
- margin-right: ${({ gapSize }: IReqoreTagGroup) => `${GAP_FROM_SIZE[gapSize]}px`};
23
- }
24
-
25
- margin-bottom: ${({ hasBottomMargin }) => (hasBottomMargin ? '5px' : '0px')};
26
- }
18
+ display: flex;
19
+ flex-wrap: ${({ wrap }: IReqoreTagGroup) => (wrap ? 'wrap' : 'nowrap')};
20
+ gap: ${({ gapSize }: IReqoreTagGroup) => GAP_FROM_SIZE[gapSize]}px;
27
21
  `;
28
22
 
29
23
  const ReqoreTagGroup = ({
@@ -33,13 +27,13 @@ const ReqoreTagGroup = ({
33
27
  minimal,
34
28
  className,
35
29
  columns,
36
- hasBottomMargin = true,
30
+ wrap = true,
37
31
  ...rest
38
32
  }: IReqoreTagGroup) => (
39
33
  <StyledTagGroup
40
34
  {...rest}
41
35
  gapSize={gapSize}
42
- hasBottomMargin={hasBottomMargin}
36
+ wrap={wrap}
43
37
  className={`${className || ''} reqore-tag-group`}
44
38
  >
45
39
  {React.Children.map(children, (child) =>