@qoretechnologies/reqore 0.30.6 → 0.30.8
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/CODE_OF_CONDUCT.md +104 -104
- package/CONTRIBUTING.MD +78 -78
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/SECURITY.md +5 -5
- package/__tests__/collection.test.tsx +1 -1
- package/__tests__/{control_group.text.tsx → control_group.test.tsx} +4 -2
- package/__tests__/modal.test.tsx +74 -2
- package/__tests__/panel.test.tsx +96 -24
- package/__tests__/popover.test.tsx +24 -2
- package/__tests__/tabs.test.tsx +75 -0
- package/dist/components/Button/index.d.ts +6 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +30 -20
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +6 -3
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Collection/index.d.ts +7 -2
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +57 -53
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Collection/item.d.ts +5 -5
- package/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js +15 -4
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Columns/column.d.ts.map +1 -1
- package/dist/components/Columns/column.js +1 -1
- package/dist/components/Columns/column.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts +21 -4
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +250 -55
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts +2 -2
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +27 -16
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +1 -0
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/Effect/index.d.ts +1 -1
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +7 -6
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +5 -6
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +14 -7
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +10 -4
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +12 -10
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Message/index.d.ts +2 -0
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +2 -2
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.js +10 -10
- package/dist/components/MultiSelect/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +13 -6
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +78 -44
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -2
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +2 -2
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Spacer/index.d.ts +2 -0
- package/dist/components/Spacer/index.d.ts.map +1 -1
- package/dist/components/Spacer/index.js +29 -7
- package/dist/components/Spacer/index.js.map +1 -1
- package/dist/components/Table/header.js +2 -2
- package/dist/components/Table/header.js.map +1 -1
- package/dist/components/Table/headerCell.js +2 -2
- package/dist/components/Table/headerCell.js.map +1 -1
- package/dist/components/Table/helpers.d.ts +3 -2
- package/dist/components/Table/helpers.d.ts.map +1 -1
- package/dist/components/Table/helpers.js +6 -3
- package/dist/components/Table/helpers.js.map +1 -1
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/row.d.ts +0 -5
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +3 -7
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Tabs/content.d.ts +3 -1
- package/dist/components/Tabs/content.d.ts.map +1 -1
- package/dist/components/Tabs/content.js +8 -3
- package/dist/components/Tabs/content.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +4 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js +12 -4
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/item.d.ts +1 -0
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +7 -7
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tabs/list.d.ts +1 -1
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +7 -6
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tag/group.d.ts +2 -2
- package/dist/components/Tag/group.d.ts.map +1 -1
- package/dist/components/Tag/group.js +7 -8
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/components/Tag/index.d.ts +6 -2
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +24 -12
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Tree/index.js +1 -1
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/constants/animations.js +1 -1
- package/dist/constants/sizes.js +10 -10
- package/dist/constants/sizes.js.map +1 -1
- package/dist/containers/PopoverProvider.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.js +10 -8
- package/dist/containers/PopoverProvider.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +4 -2
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +7 -0
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/context/ReqoreContext.d.ts +2 -0
- package/dist/context/ReqoreContext.d.ts.map +1 -1
- package/dist/context/ReqoreContext.js.map +1 -1
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +6 -2
- package/dist/helpers/colors.js.map +1 -1
- package/dist/helpers/utils.d.ts +3 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +16 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/hooks/useLatestZIndex.js +2 -2
- package/dist/hooks/useLatestZIndex.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +1 -0
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +8 -6
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +6 -5
- package/dist/styles.js.map +1 -1
- package/dist/types/global.d.ts +26 -0
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +79 -34
- package/src/components/Checkbox/index.tsx +3 -2
- package/src/components/Collection/index.tsx +93 -60
- package/src/components/Collection/item.tsx +29 -9
- package/src/components/Columns/column.tsx +1 -0
- package/src/components/ControlGroup/index.tsx +449 -104
- package/src/components/Drawer/index.tsx +28 -27
- package/src/components/Dropdown/index.tsx +3 -1
- package/src/components/Effect/index.tsx +22 -14
- package/src/components/Icon/index.tsx +81 -62
- package/src/components/Input/index.tsx +8 -3
- package/src/components/InternalPopover/index.tsx +131 -126
- package/src/components/Menu/index.tsx +7 -1
- package/src/components/Message/index.tsx +9 -1
- package/src/components/MultiSelect/index.tsx +180 -188
- package/src/components/Panel/index.tsx +227 -100
- package/src/components/Popover/index.tsx +1 -3
- package/src/components/Spacer/index.tsx +63 -14
- package/src/components/Table/header.tsx +2 -2
- package/src/components/Table/headerCell.tsx +2 -2
- package/src/components/Table/helpers.ts +12 -6
- package/src/components/Table/index.tsx +1 -0
- package/src/components/Table/row.tsx +2 -7
- package/src/components/Tabs/content.tsx +11 -3
- package/src/components/Tabs/index.tsx +14 -3
- package/src/components/Tabs/item.tsx +28 -5
- package/src/components/Tabs/list.tsx +7 -3
- package/src/components/Tag/group.tsx +6 -12
- package/src/components/Tag/index.tsx +69 -35
- package/src/components/Tree/index.tsx +1 -1
- package/src/constants/animations.ts +1 -1
- package/src/constants/sizes.ts +10 -10
- package/src/containers/PopoverProvider.tsx +11 -8
- package/src/containers/ReqoreProvider.tsx +40 -35
- package/src/containers/UIProvider.tsx +7 -0
- package/src/context/ReqoreContext.tsx +2 -0
- package/src/helpers/colors.ts +8 -2
- package/src/helpers/utils.ts +18 -0
- package/src/hooks/useLatestZIndex.ts +2 -2
- package/src/hooks/usePopover.tsx +9 -6
- package/src/mock/collectionData.tsx +33 -2
- package/src/stories/Button/Button.stories.tsx +72 -7
- package/src/stories/Checkbox/Checkbox.stories.tsx +6 -3
- package/src/stories/Collection/Collection.stories.tsx +18 -2
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +282 -33
- package/src/stories/Drawer/Drawer.stories.tsx +70 -3
- package/src/stories/Dropdown/Dropdown.stories.tsx +13 -3
- package/src/stories/Icon/Icon.stories.tsx +1 -0
- package/src/stories/Input/Input.stories.tsx +5 -3
- package/src/stories/Menu/Menu.stories.tsx +2 -0
- package/src/stories/Message/Message.stories.tsx +7 -0
- package/src/stories/Panel/Panel.stories.tsx +147 -13
- package/src/stories/Popover/Popover.stories.tsx +88 -82
- package/src/stories/Tabs/Tabs.stories.tsx +33 -15
- package/src/stories/Tag/Tag.stories.tsx +23 -3
- package/src/stories/TextArea/TextArea.stories.tsx +3 -3
- package/src/styles.ts +6 -0
- package/src/types/global.ts +28 -0
- package/tests.json +1 -1
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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 ?
|
|
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 ?
|
|
35
|
+
justify-content: ${align ? alignToFlexAlign(align) : 'flex-start'};
|
|
36
36
|
`}
|
|
37
37
|
|
|
38
38
|
${({ interactive, theme }) =>
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { firstBy } from
|
|
2
|
-
import { IReqoreTableSort } from
|
|
1
|
+
import { firstBy } from 'thenby';
|
|
2
|
+
import { IReqoreTableSort } from '.';
|
|
3
3
|
|
|
4
|
-
export const flipSortDirection = (direction:
|
|
5
|
-
direction ===
|
|
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 ||
|
|
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
|
};
|
|
@@ -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 ?
|
|
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:
|
|
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,
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
13
|
+
wrap?: boolean;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
const StyledTagGroup = styled.div`
|
|
18
17
|
flex-shrink: 0;
|
|
19
|
-
|
|
20
|
-
${
|
|
21
|
-
|
|
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
|
-
|
|
30
|
+
wrap = true,
|
|
37
31
|
...rest
|
|
38
32
|
}: IReqoreTagGroup) => (
|
|
39
33
|
<StyledTagGroup
|
|
40
34
|
{...rest}
|
|
41
35
|
gapSize={gapSize}
|
|
42
|
-
|
|
36
|
+
wrap={wrap}
|
|
43
37
|
className={`${className || ''} reqore-tag-group`}
|
|
44
38
|
>
|
|
45
39
|
{React.Children.map(children, (child) =>
|