@qoretechnologies/reqore 0.27.5 → 0.28.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 (117) hide show
  1. package/__tests__/tabs.test.tsx +1 -1
  2. package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
  3. package/dist/components/Breadcrumbs/index.js +4 -5
  4. package/dist/components/Breadcrumbs/index.js.map +1 -1
  5. package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
  6. package/dist/components/Breadcrumbs/item.js +1 -1
  7. package/dist/components/Breadcrumbs/item.js.map +1 -1
  8. package/dist/components/Button/index.d.ts +8 -2
  9. package/dist/components/Button/index.d.ts.map +1 -1
  10. package/dist/components/Button/index.js +41 -24
  11. package/dist/components/Button/index.js.map +1 -1
  12. package/dist/components/Checkbox/index.js +1 -1
  13. package/dist/components/Checkbox/index.js.map +1 -1
  14. package/dist/components/Header/index.d.ts +2 -1
  15. package/dist/components/Header/index.d.ts.map +1 -1
  16. package/dist/components/Header/index.js +5 -2
  17. package/dist/components/Header/index.js.map +1 -1
  18. package/dist/components/Icon/index.d.ts +2 -1
  19. package/dist/components/Icon/index.d.ts.map +1 -1
  20. package/dist/components/Icon/index.js +17 -6
  21. package/dist/components/Icon/index.js.map +1 -1
  22. package/dist/components/Input/index.js +1 -1
  23. package/dist/components/Input/index.js.map +1 -1
  24. package/dist/components/Menu/index.d.ts +1 -1
  25. package/dist/components/Menu/index.d.ts.map +1 -1
  26. package/dist/components/Menu/index.js +2 -2
  27. package/dist/components/Menu/index.js.map +1 -1
  28. package/dist/components/Menu/item.d.ts +1 -1
  29. package/dist/components/Menu/item.d.ts.map +1 -1
  30. package/dist/components/Menu/item.js.map +1 -1
  31. package/dist/components/Message/index.d.ts +3 -4
  32. package/dist/components/Message/index.d.ts.map +1 -1
  33. package/dist/components/Message/index.js +8 -7
  34. package/dist/components/Message/index.js.map +1 -1
  35. package/dist/components/Notifications/notification.d.ts +4 -5
  36. package/dist/components/Notifications/notification.d.ts.map +1 -1
  37. package/dist/components/Notifications/notification.js +22 -19
  38. package/dist/components/Notifications/notification.js.map +1 -1
  39. package/dist/components/Panel/index.d.ts +3 -2
  40. package/dist/components/Panel/index.d.ts.map +1 -1
  41. package/dist/components/Panel/index.js +19 -11
  42. package/dist/components/Panel/index.js.map +1 -1
  43. package/dist/components/Table/row.js +1 -1
  44. package/dist/components/Table/row.js.map +1 -1
  45. package/dist/components/Tabs/index.d.ts +2 -6
  46. package/dist/components/Tabs/index.d.ts.map +1 -1
  47. package/dist/components/Tabs/index.js.map +1 -1
  48. package/dist/components/Tabs/item.d.ts.map +1 -1
  49. package/dist/components/Tabs/item.js +19 -10
  50. package/dist/components/Tabs/item.js.map +1 -1
  51. package/dist/components/Tabs/list.d.ts +8 -0
  52. package/dist/components/Tabs/list.d.ts.map +1 -1
  53. package/dist/components/Tabs/list.js +30 -12
  54. package/dist/components/Tabs/list.js.map +1 -1
  55. package/dist/components/Tag/group.d.ts +2 -1
  56. package/dist/components/Tag/group.d.ts.map +1 -1
  57. package/dist/components/Tag/group.js +8 -4
  58. package/dist/components/Tag/group.js.map +1 -1
  59. package/dist/components/Tag/index.d.ts.map +1 -1
  60. package/dist/components/Tag/index.js +3 -3
  61. package/dist/components/Tag/index.js.map +1 -1
  62. package/dist/constants/sizes.d.ts +22 -0
  63. package/dist/constants/sizes.d.ts.map +1 -1
  64. package/dist/constants/sizes.js +36 -14
  65. package/dist/constants/sizes.js.map +1 -1
  66. package/dist/containers/ReqoreProvider.d.ts +1 -1
  67. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  68. package/dist/containers/UIProvider.d.ts.map +1 -1
  69. package/dist/containers/UIProvider.js +1 -1
  70. package/dist/containers/UIProvider.js.map +1 -1
  71. package/dist/helpers/colors.d.ts.map +1 -1
  72. package/dist/helpers/colors.js +8 -4
  73. package/dist/helpers/colors.js.map +1 -1
  74. package/dist/helpers/utils.d.ts +1 -0
  75. package/dist/helpers/utils.d.ts.map +1 -1
  76. package/dist/helpers/utils.js +7 -2
  77. package/dist/helpers/utils.js.map +1 -1
  78. package/dist/styles.d.ts +2 -0
  79. package/dist/styles.d.ts.map +1 -1
  80. package/dist/styles.js +5 -3
  81. package/dist/styles.js.map +1 -1
  82. package/dist/types/global.d.ts +13 -0
  83. package/dist/types/global.d.ts.map +1 -1
  84. package/package.json +1 -1
  85. package/src/components/Breadcrumbs/index.tsx +6 -21
  86. package/src/components/Breadcrumbs/item.tsx +1 -7
  87. package/src/components/Button/index.tsx +88 -50
  88. package/src/components/Checkbox/index.tsx +1 -1
  89. package/src/components/Header/index.tsx +6 -3
  90. package/src/components/Icon/index.tsx +21 -8
  91. package/src/components/Input/index.tsx +1 -1
  92. package/src/components/Menu/index.tsx +8 -8
  93. package/src/components/Menu/item.tsx +2 -5
  94. package/src/components/Message/index.tsx +21 -17
  95. package/src/components/Notifications/notification.tsx +44 -43
  96. package/src/components/Panel/index.tsx +40 -8
  97. package/src/components/Table/row.tsx +1 -1
  98. package/src/components/Tabs/index.tsx +2 -6
  99. package/src/components/Tabs/item.tsx +33 -24
  100. package/src/components/Tabs/list.tsx +45 -15
  101. package/src/components/Tag/group.tsx +22 -5
  102. package/src/components/Tag/index.tsx +9 -11
  103. package/src/constants/sizes.ts +39 -13
  104. package/src/containers/ReqoreProvider.tsx +1 -1
  105. package/src/containers/UIProvider.tsx +3 -0
  106. package/src/helpers/colors.ts +8 -4
  107. package/src/helpers/utils.ts +7 -2
  108. package/src/mock/collectionData.tsx +4 -0
  109. package/src/stories/Button/Button.stories.tsx +43 -17
  110. package/src/stories/ControlGroup/ControlGroup.stories.tsx +2 -2
  111. package/src/stories/Message/Message.stories.tsx +6 -6
  112. package/src/stories/Notifications/Notification.stories.tsx +4 -3
  113. package/src/stories/Panel/Panel.stories.tsx +17 -1
  114. package/src/stories/Tabs/Tabs.stories.tsx +20 -13
  115. package/src/styles.ts +5 -2
  116. package/src/types/global.ts +14 -0
  117. package/tests.json +1 -1
@@ -1,27 +1,29 @@
1
1
  import { animated, useTransition } from '@react-spring/web';
2
- import { darken, rgba } from 'polished';
2
+ import { rgba } from 'polished';
3
3
  import React, { forwardRef, useEffect, useState } from 'react';
4
4
  import { useMount, useUnmount } from 'react-use';
5
5
  import styled, { css, keyframes } from 'styled-components';
6
6
  import { SPRING_CONFIG } from '../../constants/animations';
7
- import { PADDING_FROM_SIZE, TABS_SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
7
+ import {
8
+ ICON_WRAPPER_FROM_HEADER_SIZE,
9
+ PADDING_FROM_SIZE,
10
+ TABS_SIZE_TO_PX,
11
+ TEXT_FROM_SIZE,
12
+ TSizes,
13
+ } from '../../constants/sizes';
8
14
  import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
9
15
  import ReqoreThemeProvider from '../../containers/ThemeProvider';
10
16
  import { fadeIn } from '../../helpers/animations';
11
- import {
12
- changeDarkness,
13
- changeLightness,
14
- getNotificationIntent,
15
- getReadableColorFrom,
16
- } from '../../helpers/colors';
17
- import { IWithReqoreEffect } from '../../types/global';
17
+ import { changeLightness, getNotificationIntent, getReadableColor } from '../../helpers/colors';
18
+ import { IWithReqoreEffect, IWithReqoreMinimal } from '../../types/global';
18
19
  import { IReqoreIconName } from '../../types/icons';
19
20
  import { StyledEffect } from '../Effect';
21
+ import { ReqoreHeading } from '../Header';
20
22
  import ReqoreIcon from '../Icon';
21
23
 
22
24
  export type IReqoreNotificationType = TReqoreIntent;
23
25
 
24
- export interface IReqoreNotificationProps extends IWithReqoreEffect {
26
+ export interface IReqoreNotificationProps extends IWithReqoreEffect, IWithReqoreMinimal {
25
27
  type?: IReqoreNotificationType;
26
28
  intent?: TReqoreIntent;
27
29
  title?: string;
@@ -33,7 +35,6 @@ export interface IReqoreNotificationProps extends IWithReqoreEffect {
33
35
  onFinish?: () => any;
34
36
  fluid?: boolean;
35
37
  flat?: boolean;
36
- inverted?: boolean;
37
38
  size?: TSizes;
38
39
  }
39
40
 
@@ -46,7 +47,7 @@ export interface IReqoreNotificationStyle {
46
47
  hasShadow?: boolean;
47
48
  fluid?: boolean;
48
49
  flat?: boolean;
49
- inverted?: boolean;
50
+ minimal?: boolean;
50
51
  size?: TSizes;
51
52
  asMessage?: boolean;
52
53
  }
@@ -79,8 +80,6 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
79
80
  animation: 0.2s ${fadeIn} ease-in;
80
81
  `};
81
82
 
82
- font-size: ${({ size = 'normal' }) => TEXT_FROM_SIZE[size]}px;
83
-
84
83
  &:not(:first-child) {
85
84
  margin-top: ${({ asMessage }) => (asMessage ? undefined : `10px`)};
86
85
  }
@@ -93,13 +92,13 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
93
92
  timeout,
94
93
  hasShadow,
95
94
  flat,
96
- inverted,
95
+ minimal,
97
96
  }: IReqoreNotificationStyle) => css`
98
- background-color: ${inverted ? 'transparent' : getNotificationIntent(theme, intent || type)};
97
+ background-color: ${minimal
98
+ ? 'transparent'
99
+ : rgba(getNotificationIntent(theme, intent || type), 0.3)};
99
100
  border: ${flat ? 0 : '1px solid'};
100
- border-color: ${inverted
101
- ? getNotificationIntent(theme, intent || type)
102
- : darken(0.2, getNotificationIntent(theme, intent || type))};
101
+ border-color: ${getNotificationIntent(theme, intent || type)};
103
102
 
104
103
  ${hasShadow &&
105
104
  css`
@@ -120,30 +119,32 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
120
119
  }
121
120
  `}
122
121
 
123
- color: ${inverted && (intent || type)
124
- ? getNotificationIntent(theme, intent || type)
125
- : getReadableColorFrom(getNotificationIntent(theme, intent || type), true)};
122
+ color: ${getReadableColor(theme, null, null, true, theme.originalMain)};
126
123
 
127
124
  ${clickable &&
128
125
  css`
129
126
  cursor: pointer;
130
127
  &:hover {
131
- background-color: ${inverted
132
- ? rgba(changeDarkness(getNotificationIntent(theme, intent || type), 0.2), 0.1)
133
- : changeLightness(getNotificationIntent(theme, intent || type), 0.0625)};
128
+ background-color: ${rgba(
129
+ getNotificationIntent(theme, intent || type),
130
+ minimal ? 0.2 : 0.5
131
+ )};
132
+ border-color: ${changeLightness(getNotificationIntent(theme, intent || type), 0.1)};
134
133
  }
135
134
  `}
136
135
  `}
137
136
  `;
138
137
 
139
138
  export const StyledIconWrapper = styled.div<IReqoreNotificationStyle>`
140
- min-height: ${({ size = 'normal' }: IReqoreNotificationStyle) => TABS_SIZE_TO_PX[size]}px;
139
+ height: ${({ size = 'normal' }: IReqoreNotificationStyle) =>
140
+ ICON_WRAPPER_FROM_HEADER_SIZE[size]}px;
141
141
  flex: 0 1 auto;
142
142
  flex-shrink: 0;
143
143
  display: flex;
144
144
  justify-content: center;
145
145
  align-items: center;
146
146
  transition: all 0.2s ease-out;
147
+ margin-top: ${({ size = 'normal' }: IReqoreNotificationStyle) => `${PADDING_FROM_SIZE[size]}px`};
147
148
 
148
149
  ${({ clickable, theme, intent, type }) =>
149
150
  clickable &&
@@ -178,12 +179,17 @@ export const StyledNotificationTitle = styled.h4`
178
179
  align-items: center;
179
180
  `;
180
181
 
181
- export const StyledNotificationContent = styled.p`
182
+ export const StyledNotificationContent = styled.div`
182
183
  margin: 0;
183
184
  padding: 0;
184
185
  flex: 1;
185
- display: flex;
186
- align-items: center;
186
+ font-size: ${({ size = 'normal' }) => TEXT_FROM_SIZE[size]}px;
187
+
188
+ ${({ hasTitle, size = 'normal' }) =>
189
+ hasTitle &&
190
+ css`
191
+ padding-top: ${PADDING_FROM_SIZE[size]}px;
192
+ `}
187
193
  `;
188
194
 
189
195
  export const typeToIcon: { [type: string]: IReqoreIconName } = {
@@ -195,10 +201,7 @@ export const typeToIcon: { [type: string]: IReqoreIconName } = {
195
201
  muted: 'Forbid2Line',
196
202
  };
197
203
 
198
- const ReqoreNotification: React.FC<IReqoreNotificationProps> = forwardRef<
199
- HTMLDivElement,
200
- IReqoreNotificationProps
201
- >(
204
+ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
202
205
  (
203
206
  {
204
207
  type,
@@ -211,7 +214,7 @@ const ReqoreNotification: React.FC<IReqoreNotificationProps> = forwardRef<
211
214
  duration,
212
215
  onFinish,
213
216
  flat,
214
- inverted,
217
+ minimal,
215
218
  size = 'normal',
216
219
  },
217
220
  ref: any
@@ -262,7 +265,7 @@ const ReqoreNotification: React.FC<IReqoreNotificationProps> = forwardRef<
262
265
  clickable={!!onClick}
263
266
  onClick={onClick}
264
267
  flat={flat}
265
- inverted={inverted}
268
+ minimal={minimal}
266
269
  className='reqore-notification'
267
270
  ref={ref}
268
271
  style={styles}
@@ -270,16 +273,14 @@ const ReqoreNotification: React.FC<IReqoreNotificationProps> = forwardRef<
270
273
  >
271
274
  {type || intent || icon ? (
272
275
  <StyledIconWrapper type={type || intent} size={size}>
273
- <ReqoreIcon
274
- icon={icon || typeToIcon[type || intent]}
275
- margin={'both'}
276
- size={`${TEXT_FROM_SIZE[size]}px`}
277
- />
276
+ <ReqoreIcon icon={icon || typeToIcon[type || intent]} margin={'both'} size={size} />
278
277
  </StyledIconWrapper>
279
278
  ) : null}
280
279
  <StyledNotificationContentWrapper size={size}>
281
- {title && <StyledNotificationTitle>{title}</StyledNotificationTitle>}
282
- <StyledNotificationContent>{content}</StyledNotificationContent>
280
+ {title && <ReqoreHeading size={size}>{title}</ReqoreHeading>}
281
+ <StyledNotificationContent hasTitle={!!title} size={size}>
282
+ {content}
283
+ </StyledNotificationContent>
283
284
  </StyledNotificationContentWrapper>
284
285
  <StyledIconWrapper
285
286
  type={type || intent}
@@ -291,7 +292,7 @@ const ReqoreNotification: React.FC<IReqoreNotificationProps> = forwardRef<
291
292
  onClose && onClose();
292
293
  }}
293
294
  >
294
- <ReqoreIcon icon='CloseFill' margin='both' size={`${TEXT_FROM_SIZE[size]}px`} />
295
+ <ReqoreIcon icon='CloseFill' margin='both' size={size} />
295
296
  </StyledIconWrapper>
296
297
  </StyledReqoreNotification>
297
298
  </ReqoreThemeProvider>
@@ -5,6 +5,7 @@ import { useUpdateEffect } from 'react-use';
5
5
  import styled, { css } from 'styled-components';
6
6
  import {
7
7
  ICON_FROM_HEADER_SIZE,
8
+ PADDING_FROM_SIZE,
8
9
  RADIUS_FROM_SIZE,
9
10
  TEXT_FROM_SIZE,
10
11
  TSizes,
@@ -19,6 +20,7 @@ import {
19
20
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
20
21
  import { useReqoreTheme } from '../../hooks/useTheme';
21
22
  import { useTooltip } from '../../hooks/useTooltip';
23
+ import { ACTIVE_ICON_SCALE, INACTIVE_ICON_SCALE } from '../../styles';
22
24
  import {
23
25
  IReqoreIntent,
24
26
  IWithReqoreCustomTheme,
@@ -27,19 +29,20 @@ import {
27
29
  IWithReqoreTooltip,
28
30
  } from '../../types/global';
29
31
  import { IReqoreIconName } from '../../types/icons';
30
- import ReqoreButton, { IReqoreButtonProps } from '../Button';
32
+ import ReqoreButton, { ButtonBadge, IReqoreButtonProps, TReqoreBadge } from '../Button';
31
33
  import { StyledCollectionItemContent } from '../Collection/item';
32
34
  import ReqoreControlGroup from '../ControlGroup';
33
35
  import ReqoreDropdown from '../Dropdown';
34
36
  import { IReqoreDropdownItem } from '../Dropdown/list';
35
37
  import { IReqoreEffect, StyledEffect } from '../Effect';
36
38
  import { ReqoreHeading } from '../Header';
37
- import ReqoreIcon from '../Icon';
39
+ import ReqoreIcon, { StyledIconWrapper } from '../Icon';
40
+ import { ReqoreSpacer } from '../Spacer';
38
41
 
39
42
  export interface IReqorePanelAction extends IReqoreButtonProps, IWithReqoreTooltip, IReqoreIntent {
40
43
  label?: string | number;
41
44
  onClick?: () => void;
42
- actions?: IReqoreDropdownItem[];
45
+ actions?: Omit<IReqoreDropdownItem[], 'value'>;
43
46
  // Custom react element
44
47
  as?: React.ElementType;
45
48
  props?: any;
@@ -62,7 +65,7 @@ export interface IReqorePanelProps
62
65
  children?: any;
63
66
  icon?: IReqoreIconName;
64
67
  label?: string | ReactElement<any>;
65
-
68
+ badge?: TReqoreBadge | TReqoreBadge[];
66
69
  collapsible?: boolean;
67
70
  isCollapsed?: boolean;
68
71
  onClose?: () => void;
@@ -114,6 +117,10 @@ export const StyledPanel = styled(StyledEffect)<IStyledPanel>`
114
117
  cursor: pointer;
115
118
 
116
119
  &:hover {
120
+ ${StyledPanelTitle} > div > ${StyledIconWrapper} {
121
+ transform: scale(${ACTIVE_ICON_SCALE});
122
+ }
123
+
117
124
  background-color: ${rgba(
118
125
  darken(0.025, rgba(changeDarkness(getMainBackgroundColor(theme), 0.03), opacity)),
119
126
  opacity === 0 ? 0.2 : opacity
@@ -159,7 +166,7 @@ export const StyledPanel = styled(StyledEffect)<IStyledPanel>`
159
166
  export const StyledPanelTitle = styled.div<IStyledPanel>`
160
167
  display: flex;
161
168
  background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
162
- rgba(changeLightness(getMainBackgroundColor(theme), 0.07), opacity)};
169
+ rgba(changeLightness(getMainBackgroundColor(theme), 0.03), opacity)};
163
170
  justify-content: space-between;
164
171
  height: 40px;
165
172
  align-items: center;
@@ -175,13 +182,21 @@ export const StyledPanelTitle = styled.div<IStyledPanel>`
175
182
  overflow: hidden;
176
183
  flex: 0 0 auto;
177
184
 
185
+ > div > ${StyledIconWrapper} {
186
+ transform: scale(${INACTIVE_ICON_SCALE});
187
+ }
188
+
178
189
  ${({ collapsible }) =>
179
190
  collapsible &&
180
191
  css`
181
192
  cursor: pointer;
182
193
  &:hover {
194
+ > div > ${StyledIconWrapper} {
195
+ transform: scale(${ACTIVE_ICON_SCALE});
196
+ }
197
+
183
198
  background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
184
- rgba(changeLightness(getMainBackgroundColor(theme), 0.1), opacity)};
199
+ rgba(changeLightness(getMainBackgroundColor(theme), 0.05), opacity)};
185
200
  }
186
201
  `}
187
202
  `;
@@ -247,6 +262,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
247
262
  contentSize = 'normal',
248
263
  minimal,
249
264
  tooltip,
265
+ badge,
250
266
  ...rest
251
267
  }: IReqorePanelProps,
252
268
  ref
@@ -267,12 +283,17 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
267
283
  setIsCollapsed(!!isCollapsed);
268
284
  }, [isCollapsed]);
269
285
 
286
+ // Return true if the card has a title bar, otherwise return false.
270
287
  const hasTitleBar: boolean = useMemo(
271
- () => !!label || collapsible || !!onClose || !!size(actions),
272
- [label, collapsible, onClose, actions]
288
+ () => !!label || collapsible || !!onClose || !!size(actions) || !!badge,
289
+ [label, collapsible, onClose, actions, badge]
273
290
  );
274
291
 
292
+ // If collapsible is true, toggle the isCollapsed state
293
+ // If the isCollapsed state is true, the component is expanded
294
+ // If the isCollapsed state is false, the component is collapsed
275
295
  const handleCollapseClick = useCallback(() => {
296
+ // If collapsible is true, toggle the isCollapsed state
276
297
  if (collapsible) {
277
298
  setIsCollapsed(!_isCollapsed);
278
299
  onCollapseChange?.(!_isCollapsed);
@@ -289,6 +310,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
289
310
  [bottomActions]
290
311
  );
291
312
 
313
+ // Calculates whether or not the bottom actions should be displayed.
292
314
  const hasBottomActions: boolean = useMemo(
293
315
  () => !!(size(leftBottomActions) || size(rightBottomActions)),
294
316
  [leftBottomActions, rightBottomActions]
@@ -437,6 +459,16 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
437
459
  ) : (
438
460
  label
439
461
  )}
462
+ {badge && (
463
+ <>
464
+ <ButtonBadge
465
+ color={changeLightness(theme.main, 0.18)}
466
+ size='big'
467
+ content={badge}
468
+ />
469
+ <ReqoreSpacer width={PADDING_FROM_SIZE.normal} />
470
+ </>
471
+ )}
440
472
  </StyledPanelTitleHeader>
441
473
  <ReqoreControlGroup>
442
474
  {actions.map(renderActions)}
@@ -342,7 +342,7 @@ const ReqoreTableRow = ({
342
342
  ? 'CheckboxCircleLine'
343
343
  : 'CheckboxBlankCircleLine'
344
344
  }
345
- size={`${TEXT_FROM_SIZE[size]}px`}
345
+ size={size}
346
346
  style={{ opacity: !data[index]._selectId || !isSelected ? 0.4 : 1 }}
347
347
  />
348
348
  </StyledTableCell>
@@ -2,22 +2,18 @@ import React, { ReactElement, useEffect, useState } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { TSizes } from '../../constants/sizes';
4
4
  import { IReqoreCustomTheme, TReqoreIntent } from '../../constants/theme';
5
- import { TReqoreTooltipProp } from '../../types/global';
6
5
  import { IReqoreIconName } from '../../types/icons';
6
+ import { IReqoreButtonProps } from '../Button';
7
7
  import ReqoreTabsList from './list';
8
8
 
9
- export interface IReqoreTabsListItem {
9
+ export interface IReqoreTabsListItem extends Omit<IReqoreButtonProps, 'id'> {
10
10
  label: string;
11
- icon?: IReqoreIconName;
12
11
  as?: any;
13
- disabled?: boolean;
14
12
  id: string | number;
15
- tooltip?: TReqoreTooltipProp;
16
13
  props?: React.HTMLAttributes<any>;
17
14
  onClick?: (event: any) => any;
18
15
  onCloseClick?: (id: string | number) => any;
19
16
  activeIntent?: TReqoreIntent;
20
- intent?: TReqoreIntent;
21
17
  closeIcon?: IReqoreIconName;
22
18
  }
23
19
 
@@ -3,11 +3,10 @@ import styled, { css } from 'styled-components';
3
3
  import { IReqoreTabsListItem } from '.';
4
4
  import { TABS_PADDING_TO_PX, TSizes } from '../../constants/sizes';
5
5
  import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
6
- import { changeLightness } from '../../helpers/colors';
7
6
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
8
7
  import { useReqoreTheme } from '../../hooks/useTheme';
9
8
  import { IWithReqoreFlat } from '../../types/global';
10
- import ReqoreButton from '../Button';
9
+ import ReqoreButton, { StyledButton } from '../Button';
11
10
  import ReqoreControlGroup from '../ControlGroup';
12
11
 
13
12
  export interface IReqoreTabListItemProps extends IReqoreTabsListItem, IWithReqoreFlat {
@@ -28,7 +27,7 @@ export interface IReqoreTabListItemStyle extends IReqoreTabListItemProps {
28
27
  }
29
28
 
30
29
  export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
31
- ${({ active, disabled, vertical, activeColor, size, fill }: IReqoreTabListItemStyle) => {
30
+ ${({ disabled, vertical, size, fill }: IReqoreTabListItemStyle) => {
32
31
  return css`
33
32
  display: flex;
34
33
  flex-shrink: 0;
@@ -37,19 +36,30 @@ export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
37
36
  align-items: center;
38
37
  width: ${vertical ? `100%` : undefined};
39
38
  padding: ${vertical ? `${TABS_PADDING_TO_PX[size!]}px` : `${TABS_PADDING_TO_PX[size!]}px`};
40
- ${active &&
41
- css`
42
- &:after {
43
- width: ${vertical ? '5px' : '1px'};
44
- height: ${vertical ? '1px' : '5px'};
45
- left: ${vertical ? '0' : '50%'};
46
- top: ${vertical ? '50%' : undefined};
47
- bottom: ${vertical ? undefined : '0'};
48
- content: '';
49
- position: absolute;
50
- background-color: ${activeColor};
51
- }
52
- `}
39
+ padding-bottom: ${!vertical && 0};
40
+ padding-right: ${vertical && 0};
41
+
42
+ ${vertical
43
+ ? css`
44
+ ${StyledButton}:last-child {
45
+ border-right: 0;
46
+ }
47
+ ${StyledButton}:last-child {
48
+ border-top-right-radius: 0;
49
+ border-bottom-right-radius: 0;
50
+ }
51
+ `
52
+ : css`
53
+ ${StyledButton} {
54
+ border-bottom: 0;
55
+ }
56
+ ${StyledButton}:first-child {
57
+ border-bottom-left-radius: 0;
58
+ }
59
+ ${StyledButton}:last-child {
60
+ border-bottom-right-radius: 0;
61
+ }
62
+ `}
53
63
 
54
64
  ${fill &&
55
65
  css`
@@ -98,13 +108,13 @@ const ReqoreTabsListItem = memo(
98
108
  className,
99
109
  flat = true,
100
110
  wrapTabNames,
111
+ id,
112
+ ...rest
101
113
  }: IReqoreTabListItemProps,
102
114
  ref
103
115
  ) => {
104
116
  const { targetRef } = useCombinedRefs(ref);
105
117
  const theme = useReqoreTheme('main', customTheme);
106
- const _intent = activeIntent || intent;
107
- const activeColor = _intent ? theme.intents[_intent] : changeLightness(theme.main, 0.05);
108
118
 
109
119
  return (
110
120
  <StyledTabListItem
@@ -112,8 +122,6 @@ const ReqoreTabsListItem = memo(
112
122
  {...props}
113
123
  className={className}
114
124
  intent={intent}
115
- activeIntent={activeIntent}
116
- activeColor={activeColor}
117
125
  as={as}
118
126
  size={size}
119
127
  active={active}
@@ -125,7 +133,7 @@ const ReqoreTabsListItem = memo(
125
133
  {label || icon ? (
126
134
  <ReqoreControlGroup stack size={size} fluid={fill || vertical}>
127
135
  <ReqoreButton
128
- flat={active || intent ? false : flat}
136
+ flat={intent ? false : flat}
129
137
  fluid={fill || vertical}
130
138
  icon={icon}
131
139
  minimal
@@ -135,21 +143,22 @@ const ReqoreTabsListItem = memo(
135
143
  disabled={disabled}
136
144
  onClick={onClick}
137
145
  tooltip={tooltip}
138
- customTheme={customTheme}
146
+ customTheme={theme}
139
147
  className={`reqore-tabs-list-item ${active ? 'reqore-tabs-list-item-active' : ''}`}
148
+ {...rest}
140
149
  >
141
150
  {label}
142
151
  </ReqoreButton>
143
152
  {onCloseClick && !disabled ? (
144
153
  <ReqoreButton
145
154
  fixed
146
- flat={active || intent ? false : flat}
155
+ flat={intent ? false : flat}
147
156
  icon={closeIcon || 'CloseLine'}
148
157
  intent={active ? activeIntent || intent : intent}
149
158
  minimal
150
159
  active={active}
151
160
  className='reqore-tabs-list-item-close'
152
- customTheme={customTheme}
161
+ customTheme={theme}
153
162
  onClick={(event) => {
154
163
  event.stopPropagation();
155
164
  onCloseClick?.();
@@ -4,7 +4,13 @@ import { useMeasure } from 'react-use';
4
4
  import styled, { css } from 'styled-components';
5
5
  import { IReqoreTabsListItem, IReqoreTabsProps } from '.';
6
6
  import { ReqorePopover } from '../..';
7
- import { TABS_SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
7
+ import {
8
+ ICON_FROM_SIZE,
9
+ PADDING_FROM_SIZE,
10
+ TABS_PADDING_TO_PX,
11
+ TEXT_FROM_SIZE,
12
+ TSizes,
13
+ } from '../../constants/sizes';
8
14
  import { IReqoreBreadcrumbsTheme, IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
9
15
  import ReqoreThemeProvider from '../../containers/ThemeProvider';
10
16
  import { changeLightness } from '../../helpers/colors';
@@ -28,13 +34,13 @@ export interface IReqoreTabsListStyle extends Omit<IReqoreTabsListProps, 'tabs'>
28
34
  }
29
35
 
30
36
  export const StyledReqoreTabsList = styled.div<IReqoreTabsListStyle>`
31
- ${({ theme, fill, vertical, size, width }) => css`
32
- height: ${vertical ? '100%' : `${TABS_SIZE_TO_PX[size]}px`};
37
+ ${({ fill, vertical, currentTabColor, width }) => css`
38
+ height: ${vertical ? '100%' : undefined};
33
39
  width: ${vertical ? width || '200px' : '100%'};
34
40
  flex-flow: ${vertical ? 'column' : 'row'};
35
41
  display: flex;
36
42
  align-items: center;
37
- border-${vertical ? 'right' : 'bottom'}: 1px solid ${changeLightness(theme.main, 0.05)};
43
+ border-${vertical ? 'right' : 'bottom'}: 1px solid ${changeLightness(currentTabColor, 0.175)};
38
44
 
39
45
  ${
40
46
  fill &&
@@ -72,12 +78,20 @@ const getLabel = (
72
78
  }
73
79
 
74
80
  const label: string = isArray(item) ? getMoreLabel(item, activeTab) : item.label;
75
- const icon: number = isArray(item) || item.icon ? TEXT_FROM_SIZE[tabsSize] : 0;
76
- const closeIconSize = isArray(item) || !item.onCloseClick ? 0 : 30;
81
+ const icon: number = isArray(item) || item.icon ? ICON_FROM_SIZE[tabsSize] : 0;
82
+ const closeIconSize = isArray(item) || !item.onCloseClick ? 0 : ICON_FROM_SIZE[tabsSize] * 2;
77
83
 
78
84
  return calculateStringSizeInPixels(label, TEXT_FROM_SIZE[tabsSize]) + icon + closeIconSize;
79
85
  };
80
86
 
87
+ /**
88
+ * This function returns the total width or height of the tabs.
89
+ * @param items the items that will be rendered in the tabs
90
+ * @param type the type of calculation, either width or height
91
+ * @param activeTab the currently active tab
92
+ * @param tabsSize the size of the tabs
93
+ * @returns the total width or height of the tabs
94
+ */
81
95
  export const getTabsLength = (
82
96
  items: (IReqoreTabsListItem | IReqoreTabsListItem[])[],
83
97
  type: 'width' | 'height' = 'width',
@@ -91,7 +105,12 @@ export const getTabsLength = (
91
105
  return len + rows * 15 + 10;
92
106
  }
93
107
 
94
- return len + 36 + getLabel(item, activeTab, tabsSize);
108
+ const labelLength: number =
109
+ PADDING_FROM_SIZE[tabsSize] * 3 +
110
+ TABS_PADDING_TO_PX[tabsSize] * 2 +
111
+ getLabel(item, activeTab, tabsSize);
112
+
113
+ return len + labelLength;
95
114
  }, 0);
96
115
 
97
116
  const getTransformedItems = (
@@ -142,6 +161,11 @@ const ReqoreTabsList = ({
142
161
  }: IReqoreTabsListProps) => {
143
162
  const [ref, { width, height }] = useMeasure();
144
163
  const theme = useReqoreTheme('main', customTheme, intent);
164
+ const activeTabData = tabs.find((tab) => tab.id === activeTab);
165
+ const currentTabColor =
166
+ activeTabIntent || activeTabData?.intent
167
+ ? theme.intents[activeTabIntent || activeTabData.intent]
168
+ : activeTabData?.customTheme?.main || theme.main;
145
169
 
146
170
  const transformedItems = vertical
147
171
  ? tabs
@@ -164,6 +188,7 @@ const ReqoreTabsList = ({
164
188
  ref={ref}
165
189
  flat={flat}
166
190
  theme={theme}
191
+ currentTabColor={currentTabColor}
167
192
  >
168
193
  {transformedItems.map((item: IReqoreTabsListItem | IReqoreTabsListItem[], index: number) =>
169
194
  isArray(item) ? (
@@ -178,7 +203,9 @@ const ReqoreTabsList = ({
178
203
  label: getMoreLabel(item, activeTab),
179
204
  active: !!isTabHidden(item, activeTab),
180
205
  activeIntent: activeTabIntent,
181
- customTheme: theme,
206
+ customTheme: {
207
+ main: currentTabColor,
208
+ },
182
209
  vertical,
183
210
  flat,
184
211
  size,
@@ -203,6 +230,7 @@ const ReqoreTabsList = ({
203
230
  intent,
204
231
  activeIntent,
205
232
  closeIcon,
233
+ ...rest
206
234
  }) => (
207
235
  <ReqoreMenuItem
208
236
  {...({
@@ -212,11 +240,12 @@ const ReqoreTabsList = ({
212
240
  intent: activeTab === id ? activeIntent || intent : intent,
213
241
  disabled,
214
242
  rightIcon: onCloseClick ? closeIcon || 'CloseLine' : undefined,
215
- onRightIconClick: onCloseClick
216
- ? () => {
217
- onCloseClick(id);
218
- }
219
- : undefined,
243
+ onRightIconClick:
244
+ onCloseClick && !disabled
245
+ ? () => {
246
+ onCloseClick(id);
247
+ }
248
+ : undefined,
220
249
  selected: activeTab === id,
221
250
  onClick: (_id, event: React.MouseEvent<any>) => {
222
251
  if (!disabled) {
@@ -229,6 +258,7 @@ const ReqoreTabsList = ({
229
258
  },
230
259
  } as IReqoreMenuItemProps)}
231
260
  tooltip={tooltip}
261
+ {...rest}
232
262
  key={index + label}
233
263
  >
234
264
  {label}
@@ -242,13 +272,13 @@ const ReqoreTabsList = ({
242
272
  ) : (
243
273
  <React.Fragment key={index}>
244
274
  <ReqoreTabsListItem
245
- {...item}
275
+ customTheme={theme}
246
276
  fill={fill}
247
277
  size={size}
248
278
  flat={flat}
249
279
  activeIntent={activeTabIntent}
250
- customTheme={theme}
251
280
  wrapTabNames={wrapTabNames}
281
+ {...item}
252
282
  key={index}
253
283
  vertical={vertical}
254
284
  active={activeTab === item.id}