@qoretechnologies/reqore 0.27.6 → 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.
- package/__tests__/tabs.test.tsx +1 -1
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/index.js +4 -5
- package/dist/components/Breadcrumbs/index.js.map +1 -1
- package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/item.js +1 -1
- package/dist/components/Breadcrumbs/item.js.map +1 -1
- package/dist/components/Button/index.d.ts +8 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +41 -24
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Header/index.d.ts +2 -1
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +5 -2
- package/dist/components/Header/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +2 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +17 -6
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Menu/index.js +2 -2
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Message/index.d.ts +2 -3
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +8 -7
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +3 -4
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +22 -19
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Panel/index.d.ts +3 -2
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +19 -11
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Table/row.js +1 -1
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +2 -6
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +19 -10
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tabs/list.d.ts +8 -0
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +30 -12
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tag/group.d.ts +2 -1
- package/dist/components/Tag/group.d.ts.map +1 -1
- package/dist/components/Tag/group.js +8 -4
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +3 -3
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/constants/sizes.d.ts +22 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +36 -14
- package/dist/constants/sizes.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +1 -1
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +8 -4
- package/dist/helpers/colors.js.map +1 -1
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +7 -2
- package/dist/helpers/utils.js.map +1 -1
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +5 -3
- package/dist/styles.js.map +1 -1
- package/dist/types/global.d.ts +13 -0
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Breadcrumbs/index.tsx +6 -21
- package/src/components/Breadcrumbs/item.tsx +1 -7
- package/src/components/Button/index.tsx +88 -50
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/Header/index.tsx +6 -3
- package/src/components/Icon/index.tsx +21 -8
- package/src/components/Input/index.tsx +1 -1
- package/src/components/Menu/index.tsx +6 -6
- package/src/components/Message/index.tsx +20 -13
- package/src/components/Notifications/notification.tsx +43 -39
- package/src/components/Panel/index.tsx +40 -8
- package/src/components/Table/row.tsx +1 -1
- package/src/components/Tabs/index.tsx +2 -6
- package/src/components/Tabs/item.tsx +33 -24
- package/src/components/Tabs/list.tsx +45 -15
- package/src/components/Tag/group.tsx +22 -5
- package/src/components/Tag/index.tsx +9 -11
- package/src/constants/sizes.ts +39 -13
- package/src/containers/ReqoreProvider.tsx +1 -1
- package/src/containers/UIProvider.tsx +3 -0
- package/src/helpers/colors.ts +8 -4
- package/src/helpers/utils.ts +7 -2
- package/src/mock/collectionData.tsx +4 -0
- package/src/stories/Button/Button.stories.tsx +43 -17
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +2 -2
- package/src/stories/Message/Message.stories.tsx +6 -6
- package/src/stories/Notifications/Notification.stories.tsx +4 -3
- package/src/stories/Panel/Panel.stories.tsx +17 -1
- package/src/stories/Tabs/Tabs.stories.tsx +20 -13
- package/src/styles.ts +5 -2
- package/src/types/global.ts +14 -0
- package/tests.json +1 -1
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { animated, useTransition } from '@react-spring/web';
|
|
2
|
-
import {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95
|
+
minimal,
|
|
97
96
|
}: IReqoreNotificationStyle) => css`
|
|
98
|
-
background-color: ${
|
|
97
|
+
background-color: ${minimal
|
|
98
|
+
? 'transparent'
|
|
99
|
+
: rgba(getNotificationIntent(theme, intent || type), 0.3)};
|
|
99
100
|
border: ${flat ? 0 : '1px solid'};
|
|
100
|
-
border-color: ${
|
|
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: ${
|
|
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: ${
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
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.
|
|
182
|
+
export const StyledNotificationContent = styled.div`
|
|
182
183
|
margin: 0;
|
|
183
184
|
padding: 0;
|
|
184
185
|
flex: 1;
|
|
185
|
-
|
|
186
|
-
|
|
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 } = {
|
|
@@ -208,7 +214,7 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
208
214
|
duration,
|
|
209
215
|
onFinish,
|
|
210
216
|
flat,
|
|
211
|
-
|
|
217
|
+
minimal,
|
|
212
218
|
size = 'normal',
|
|
213
219
|
},
|
|
214
220
|
ref: any
|
|
@@ -259,7 +265,7 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
259
265
|
clickable={!!onClick}
|
|
260
266
|
onClick={onClick}
|
|
261
267
|
flat={flat}
|
|
262
|
-
|
|
268
|
+
minimal={minimal}
|
|
263
269
|
className='reqore-notification'
|
|
264
270
|
ref={ref}
|
|
265
271
|
style={styles}
|
|
@@ -267,16 +273,14 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
267
273
|
>
|
|
268
274
|
{type || intent || icon ? (
|
|
269
275
|
<StyledIconWrapper type={type || intent} size={size}>
|
|
270
|
-
<ReqoreIcon
|
|
271
|
-
icon={icon || typeToIcon[type || intent]}
|
|
272
|
-
margin={'both'}
|
|
273
|
-
size={`${TEXT_FROM_SIZE[size]}px`}
|
|
274
|
-
/>
|
|
276
|
+
<ReqoreIcon icon={icon || typeToIcon[type || intent]} margin={'both'} size={size} />
|
|
275
277
|
</StyledIconWrapper>
|
|
276
278
|
) : null}
|
|
277
279
|
<StyledNotificationContentWrapper size={size}>
|
|
278
|
-
{title && <
|
|
279
|
-
<StyledNotificationContent
|
|
280
|
+
{title && <ReqoreHeading size={size}>{title}</ReqoreHeading>}
|
|
281
|
+
<StyledNotificationContent hasTitle={!!title} size={size}>
|
|
282
|
+
{content}
|
|
283
|
+
</StyledNotificationContent>
|
|
280
284
|
</StyledNotificationContentWrapper>
|
|
281
285
|
<StyledIconWrapper
|
|
282
286
|
type={type || intent}
|
|
@@ -288,7 +292,7 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
|
|
|
288
292
|
onClose && onClose();
|
|
289
293
|
}}
|
|
290
294
|
>
|
|
291
|
-
<ReqoreIcon icon='CloseFill' margin='both' size={
|
|
295
|
+
<ReqoreIcon icon='CloseFill' margin='both' size={size} />
|
|
292
296
|
</StyledIconWrapper>
|
|
293
297
|
</StyledReqoreNotification>
|
|
294
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.
|
|
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.
|
|
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)}
|
|
@@ -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
|
-
${({
|
|
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
|
-
${
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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={
|
|
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={
|
|
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={
|
|
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={
|
|
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 {
|
|
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
|
-
${({
|
|
32
|
-
height: ${vertical ? '100%' :
|
|
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(
|
|
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 ?
|
|
76
|
-
const closeIconSize = isArray(item) || !item.onCloseClick ? 0 :
|
|
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
|
-
|
|
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:
|
|
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:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
{
|
|
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}
|