@qoretechnologies/reqore 0.35.0 → 0.35.2
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__/helpers/table.test.tsx +20 -0
- package/__tests__/table.test.tsx +199 -2
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +1 -1
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts +1 -0
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Menu/divider.d.ts +1 -0
- package/dist/components/Menu/divider.d.ts.map +1 -1
- package/dist/components/Menu/divider.js +3 -2
- package/dist/components/Menu/divider.js.map +1 -1
- package/dist/components/Spacer/index.d.ts.map +1 -1
- package/dist/components/Spacer/index.js +1 -1
- package/dist/components/Spacer/index.js.map +1 -1
- package/dist/components/Table/body.d.ts +10 -3
- package/dist/components/Table/body.d.ts.map +1 -1
- package/dist/components/Table/body.js +40 -9
- package/dist/components/Table/body.js.map +1 -1
- package/dist/components/Table/cell.d.ts +1 -0
- package/dist/components/Table/cell.d.ts.map +1 -1
- package/dist/components/Table/cell.js +4 -4
- package/dist/components/Table/cell.js.map +1 -1
- package/dist/components/Table/header.d.ts +8 -7
- package/dist/components/Table/header.d.ts.map +1 -1
- package/dist/components/Table/header.js +34 -37
- package/dist/components/Table/header.js.map +1 -1
- package/dist/components/Table/headerCell.d.ts +3 -2
- package/dist/components/Table/headerCell.d.ts.map +1 -1
- package/dist/components/Table/headerCell.js +39 -8
- package/dist/components/Table/headerCell.js.map +1 -1
- package/dist/components/Table/helpers.d.ts +7 -1
- package/dist/components/Table/helpers.d.ts.map +1 -1
- package/dist/components/Table/helpers.js +30 -4
- package/dist/components/Table/helpers.js.map +1 -1
- package/dist/components/Table/index.d.ts +13 -2
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +203 -23
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/row.d.ts +2 -1
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +19 -29
- package/dist/components/Table/row.js.map +1 -1
- package/dist/constants/sizes.d.ts +15 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +16 -1
- package/dist/constants/sizes.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ControlGroup/index.tsx +1 -0
- package/src/components/Dropdown/list.tsx +1 -0
- package/src/components/Menu/divider.tsx +31 -21
- package/src/components/Spacer/index.tsx +2 -2
- package/src/components/Table/body.tsx +81 -35
- package/src/components/Table/cell.tsx +8 -2
- package/src/components/Table/header.tsx +133 -124
- package/src/components/Table/headerCell.tsx +45 -9
- package/src/components/Table/helpers.ts +48 -3
- package/src/components/Table/index.tsx +266 -53
- package/src/components/Table/row.tsx +38 -55
- package/src/constants/sizes.ts +17 -0
- package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -3
- package/src/stories/Table/Table.stories.tsx +99 -1
- package/tests.json +1 -1
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { getReadableColor } from '../../helpers/colors';
|
|
|
5
5
|
import { getOneLessSize, isStringSize } from '../../helpers/utils';
|
|
6
6
|
import { IWithReqoreEffect, IWithReqoreSize } from '../../types/global';
|
|
7
7
|
import { IReqoreEffect, StyledTextEffect } from '../Effect';
|
|
8
|
+
import { ReqoreVerticalSpacer } from '../Spacer';
|
|
8
9
|
|
|
9
10
|
export interface IReqoreMenuDividerProps
|
|
10
11
|
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>,
|
|
@@ -13,6 +14,7 @@ export interface IReqoreMenuDividerProps
|
|
|
13
14
|
label?: string | number;
|
|
14
15
|
margin?: 'left' | 'right' | 'both' | 'none';
|
|
15
16
|
align?: 'left' | 'center' | 'right';
|
|
17
|
+
line?: boolean;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const StyledMenuDivider = styled(StyledTextEffect)`
|
|
@@ -46,30 +48,38 @@ const ReqoreMenuDivider = forwardRef<HTMLDivElement, IReqoreMenuDividerProps>(
|
|
|
46
48
|
effect,
|
|
47
49
|
size = 'normal',
|
|
48
50
|
align = 'center',
|
|
51
|
+
line,
|
|
49
52
|
...rest
|
|
50
53
|
}: IReqoreMenuDividerProps,
|
|
51
54
|
ref: any
|
|
52
|
-
) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
) =>
|
|
56
|
+
line ? (
|
|
57
|
+
<ReqoreVerticalSpacer
|
|
58
|
+
className={`${className || ''} reqore-menu-divider`}
|
|
59
|
+
height={PADDING_FROM_SIZE[size]}
|
|
60
|
+
lineSize={size}
|
|
61
|
+
/>
|
|
62
|
+
) : (
|
|
63
|
+
<StyledMenuDivider
|
|
64
|
+
as='div'
|
|
65
|
+
{...rest}
|
|
66
|
+
size={size}
|
|
67
|
+
className={`${className || ''} reqore-menu-divider`}
|
|
68
|
+
ref={ref}
|
|
69
|
+
effect={
|
|
70
|
+
{
|
|
71
|
+
uppercase: true,
|
|
72
|
+
spaced: 2,
|
|
73
|
+
textAlign: align,
|
|
74
|
+
textSize: getOneLessSize(size),
|
|
75
|
+
weight: 'bold',
|
|
76
|
+
...effect,
|
|
77
|
+
} as IReqoreEffect
|
|
78
|
+
}
|
|
79
|
+
>
|
|
80
|
+
{label}
|
|
81
|
+
</StyledMenuDivider>
|
|
82
|
+
)
|
|
73
83
|
);
|
|
74
84
|
|
|
75
85
|
export default ReqoreMenuDivider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo, useMemo } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import {
|
|
3
|
+
import { LINE_SIZE_TO_NUMBER, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
4
4
|
import { changeLightness } from '../../helpers/colors';
|
|
5
5
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
6
6
|
import { IReqoreIntent, IWithReqoreCustomTheme, IWithReqoreEffect } from '../../types/global';
|
|
@@ -103,7 +103,7 @@ export const ReqoreSpacer = memo(
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const _lineSize = useMemo(
|
|
106
|
-
() => (lineSize === 'none' ? 0 :
|
|
106
|
+
() => (lineSize === 'none' ? 0 : LINE_SIZE_TO_NUMBER[lineSize]),
|
|
107
107
|
[lineSize]
|
|
108
108
|
);
|
|
109
109
|
|
|
@@ -1,46 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { useMount } from 'react-use';
|
|
3
3
|
import { FixedSizeList as List } from 'react-window';
|
|
4
|
+
import styled from 'styled-components';
|
|
4
5
|
import { TABLE_SIZE_TO_PX } from '../../constants/sizes';
|
|
6
|
+
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
5
7
|
import ReqoreTableRow, { IReqoreTableRowOptions } from './row';
|
|
6
8
|
|
|
7
9
|
export interface IReqoreTableSectionBodyProps extends IReqoreTableRowOptions {
|
|
8
|
-
setLeftScroll: Dispatch<SetStateAction<number>>;
|
|
9
10
|
rowHeight?: number;
|
|
10
11
|
height: number;
|
|
12
|
+
refs: {
|
|
13
|
+
left: React.RefObject<HTMLDivElement>;
|
|
14
|
+
right: React.RefObject<HTMLDivElement>;
|
|
15
|
+
main: React.RefObject<HTMLDivElement>;
|
|
16
|
+
header: React.RefObject<HTMLDivElement>;
|
|
17
|
+
};
|
|
18
|
+
type?: 'left' | 'right' | 'main';
|
|
19
|
+
onScrollChange?: (isScrolled: boolean) => void;
|
|
11
20
|
}
|
|
12
21
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
22
|
+
const StyledList = styled(List)`
|
|
23
|
+
::-webkit-scrollbar {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const ReqoreTableBody = forwardRef<HTMLDivElement, IReqoreTableSectionBodyProps>(
|
|
29
|
+
(
|
|
30
|
+
{
|
|
31
|
+
data,
|
|
32
|
+
height,
|
|
33
|
+
rowHeight,
|
|
34
|
+
size = 'normal',
|
|
35
|
+
refs,
|
|
36
|
+
type,
|
|
37
|
+
onScrollChange,
|
|
38
|
+
...rest
|
|
39
|
+
}: IReqoreTableSectionBodyProps,
|
|
40
|
+
ref
|
|
41
|
+
) => {
|
|
42
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
43
|
+
|
|
44
|
+
useMount(() => {
|
|
45
|
+
targetRef.current?.addEventListener('wheel', (e) => {
|
|
46
|
+
if (e.deltaY) {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
|
|
49
|
+
const currentScroll = refs[type].current?.scrollTop + e.deltaY;
|
|
50
|
+
|
|
51
|
+
onScrollChange?.(currentScroll > 0);
|
|
52
|
+
|
|
53
|
+
refs[type].current?.scrollTo({ top: currentScroll });
|
|
54
|
+
|
|
55
|
+
if (type === 'left') {
|
|
56
|
+
refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
|
|
57
|
+
refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
|
|
58
|
+
} else if (type === 'main') {
|
|
59
|
+
refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
|
|
60
|
+
refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
|
|
61
|
+
} else if (type === 'right') {
|
|
62
|
+
refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
|
|
63
|
+
refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (e.deltaX && type === 'main') {
|
|
68
|
+
refs.header.current?.scrollTo({ left: refs.main.current?.scrollLeft + e.deltaX });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<StyledList
|
|
75
|
+
outerRef={targetRef}
|
|
76
|
+
itemCount={data.length}
|
|
77
|
+
height={height}
|
|
78
|
+
className='reqore-table-body'
|
|
79
|
+
itemSize={rest.flat ? TABLE_SIZE_TO_PX[size] : TABLE_SIZE_TO_PX[size] + 1}
|
|
80
|
+
itemData={{
|
|
81
|
+
data,
|
|
82
|
+
size,
|
|
83
|
+
...rest,
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{ReqoreTableRow}
|
|
87
|
+
</StyledList>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
45
91
|
|
|
46
92
|
export default ReqoreTableBody;
|
|
@@ -13,12 +13,16 @@ export interface IReqoreTableBodyCellProps
|
|
|
13
13
|
extends Partial<IReqoreTableColumn>,
|
|
14
14
|
React.HTMLAttributes<HTMLDivElement> {
|
|
15
15
|
children?: React.ReactNode;
|
|
16
|
+
padded?: IReqoreTableColumn['cell']['padded'];
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
|
|
19
|
-
${({ width, grow }) =>
|
|
20
|
+
${({ width, minWidth, maxWidth, grow }) =>
|
|
20
21
|
css`
|
|
21
22
|
width: ${width}px;
|
|
23
|
+
min-width: ${minWidth}px;
|
|
24
|
+
max-width: ${maxWidth}px;
|
|
25
|
+
|
|
22
26
|
flex-grow: ${grow || (width ? undefined : 1)};
|
|
23
27
|
`}
|
|
24
28
|
|
|
@@ -36,6 +40,7 @@ export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
|
|
|
36
40
|
selectedIntent,
|
|
37
41
|
disabled,
|
|
38
42
|
hovered,
|
|
43
|
+
padded,
|
|
39
44
|
}: IReqoreTableCellStyle) => {
|
|
40
45
|
const getBackgroundColor = (): TReqoreColor => {
|
|
41
46
|
let color = theme.main;
|
|
@@ -76,7 +81,8 @@ export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
|
|
|
76
81
|
border-bottom: ${!flat ? '1px solid ' : undefined};
|
|
77
82
|
|
|
78
83
|
height: 100%;
|
|
79
|
-
padding: 0
|
|
84
|
+
padding: ${!padded || padded === 'both' || padded === 'vertical' ? 0 : undefined}
|
|
85
|
+
${!padded || padded === 'both' || padded === 'horizontal' ? '10px' : undefined};
|
|
80
86
|
font-size: ${TEXT_FROM_SIZE[size]}px;
|
|
81
87
|
background-color: ${backgroundColor === 'transparent'
|
|
82
88
|
? 'transparent'
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { omit } from 'lodash';
|
|
2
|
+
import { forwardRef, useCallback } from 'react';
|
|
3
|
+
import { useMount } from 'react-use';
|
|
2
4
|
import styled, { css } from 'styled-components';
|
|
3
5
|
import { IReqoreTableColumn, IReqoreTableSort } from '.';
|
|
6
|
+
import { SIZE_TO_PX, TSizes } from '../../constants/sizes';
|
|
4
7
|
import { IReqoreTheme } from '../../constants/theme';
|
|
5
8
|
import { changeLightness } from '../../helpers/colors';
|
|
6
9
|
import { alignToFlexAlign } from '../../helpers/utils';
|
|
10
|
+
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
7
11
|
import { IWithReqoreSize } from '../../types/global';
|
|
8
|
-
import { IReqoreIconName } from '../../types/icons';
|
|
9
12
|
import { IReqoreButtonProps } from '../Button';
|
|
10
13
|
import { IReqoreTableHeaderCellProps, ReqoreTableHeaderCell } from './headerCell';
|
|
11
|
-
import {
|
|
14
|
+
import { getOnlyShownColumns } from './helpers';
|
|
12
15
|
|
|
13
16
|
export type TColumnsUpdater = <T extends keyof IReqoreTableColumn>(
|
|
14
17
|
id: string,
|
|
@@ -22,37 +25,45 @@ export interface IReqoreCustomHeaderCellProps
|
|
|
22
25
|
'sortData' | 'onSortChange' | 'onColumnsUpdate' | 'onFilterChange'
|
|
23
26
|
>,
|
|
24
27
|
Omit<IReqoreTableColumn, 'cell' | 'header'>,
|
|
25
|
-
IReqoreButtonProps {
|
|
28
|
+
Omit<IReqoreButtonProps, 'maxWidth'> {
|
|
26
29
|
hasColumns?: boolean;
|
|
27
30
|
}
|
|
28
31
|
export interface IReqoreCustomHeaderCellComponent extends React.FC<IReqoreCustomHeaderCellProps> {}
|
|
29
32
|
|
|
30
33
|
export interface IReqoreTableSectionProps extends IWithReqoreSize {
|
|
31
34
|
columns: IReqoreTableColumn[];
|
|
32
|
-
leftScroll: number;
|
|
33
35
|
onSortChange?: (sort: string) => void;
|
|
34
36
|
sortData: IReqoreTableSort;
|
|
35
|
-
selectable?: boolean;
|
|
36
|
-
selectedQuant: 'none' | 'all' | 'some';
|
|
37
|
-
onToggleSelectClick: () => void;
|
|
38
37
|
hasVerticalScroll: boolean;
|
|
39
|
-
selectToggleTooltip?: string;
|
|
40
38
|
onColumnsUpdate: TColumnsUpdater;
|
|
41
39
|
onFilterChange?: (dataId: string, value: any) => void;
|
|
42
40
|
component?: IReqoreCustomHeaderCellComponent;
|
|
41
|
+
heightAsGroup?: boolean;
|
|
42
|
+
scrollable?: boolean;
|
|
43
|
+
bodyRef: React.RefObject<HTMLDivElement>;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export interface IReqoreTableSectionStyle {
|
|
46
47
|
leftScroll: number;
|
|
47
48
|
hasVerticalScroll: boolean;
|
|
48
49
|
theme: IReqoreTheme;
|
|
50
|
+
heightAsGroup?: boolean;
|
|
51
|
+
size?: TSizes;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
const StyledTableHeaderWrapper = styled.div<IReqoreTableSectionStyle>`
|
|
52
|
-
${({
|
|
55
|
+
${({ heightAsGroup, size }) => css`
|
|
53
56
|
display: flex;
|
|
57
|
+
|
|
58
|
+
overflow-x: auto;
|
|
59
|
+
overflow-y: hidden;
|
|
60
|
+
::-webkit-scrollbar {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
flex-shrink: 0;
|
|
54
65
|
flex-flow: column;
|
|
55
|
-
|
|
66
|
+
height: ${heightAsGroup ? `${SIZE_TO_PX[size] * 2}px` : undefined};
|
|
56
67
|
|
|
57
68
|
${({ theme }) => css`
|
|
58
69
|
background-color: ${theme.main};
|
|
@@ -77,7 +88,10 @@ export const StyledColumnGroupHeader = styled.div<IReqoreTableHeaderStyle>`
|
|
|
77
88
|
const StyledColumnGroup = styled.div<IReqoreTableHeaderStyle>`
|
|
78
89
|
display: flex;
|
|
79
90
|
flex-flow: column;
|
|
91
|
+
flex-shrink: 0;
|
|
80
92
|
width: ${({ width }) => width}px;
|
|
93
|
+
max-width: ${({ maxWidth = 9999 }) => maxWidth}px;
|
|
94
|
+
min-width: ${({ minWidth, width }) => minWidth || width}px;
|
|
81
95
|
|
|
82
96
|
${({ grow }) =>
|
|
83
97
|
grow &&
|
|
@@ -105,126 +119,121 @@ const StyledTableHeaderRow = styled.div<{ theme: IReqoreTheme }>`
|
|
|
105
119
|
}
|
|
106
120
|
`;
|
|
107
121
|
|
|
108
|
-
const ReqoreTableHeader = (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}: IReqoreTableSectionProps
|
|
123
|
-
|
|
124
|
-
headerCellComponent: IReqoreCustomHeaderCellComponent,
|
|
125
|
-
props: IReqoreCustomHeaderCellProps
|
|
122
|
+
const ReqoreTableHeader = forwardRef<HTMLDivElement, IReqoreTableSectionProps>(
|
|
123
|
+
(
|
|
124
|
+
{
|
|
125
|
+
columns,
|
|
126
|
+
onSortChange,
|
|
127
|
+
sortData,
|
|
128
|
+
hasVerticalScroll,
|
|
129
|
+
onColumnsUpdate,
|
|
130
|
+
onFilterChange,
|
|
131
|
+
size,
|
|
132
|
+
component,
|
|
133
|
+
heightAsGroup,
|
|
134
|
+
scrollable,
|
|
135
|
+
bodyRef,
|
|
136
|
+
}: IReqoreTableSectionProps,
|
|
137
|
+
ref
|
|
126
138
|
) => {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
140
|
+
|
|
141
|
+
useMount(() => {
|
|
142
|
+
if (scrollable) {
|
|
143
|
+
targetRef.current?.addEventListener('wheel', (e) => {
|
|
144
|
+
if (e.deltaX) {
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
|
|
147
|
+
targetRef.current?.scrollTo({ left: targetRef.current?.scrollLeft + e.deltaX });
|
|
148
|
+
bodyRef.current?.scrollTo({ left: bodyRef.current?.scrollLeft + e.deltaX });
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const renderHeaderCell = useCallback(
|
|
134
155
|
(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
headerCellComponent: IReqoreCustomHeaderCellComponent,
|
|
157
|
+
props: IReqoreCustomHeaderCellProps
|
|
158
|
+
) => {
|
|
159
|
+
const HeaderCell = headerCellComponent || component || ReqoreTableHeaderCell;
|
|
160
|
+
|
|
161
|
+
return <HeaderCell key={props.dataId} {...props} />;
|
|
162
|
+
},
|
|
163
|
+
[component]
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const renderColumns = (columns: IReqoreTableColumn[]) =>
|
|
167
|
+
getOnlyShownColumns(columns).map(
|
|
168
|
+
(
|
|
169
|
+
{
|
|
170
|
+
grow,
|
|
171
|
+
align,
|
|
172
|
+
dataId,
|
|
173
|
+
header: { columns, onClick, component: headerComponent, ...rest },
|
|
174
|
+
...colRest
|
|
175
|
+
},
|
|
176
|
+
index
|
|
177
|
+
) =>
|
|
178
|
+
columns ? (
|
|
179
|
+
<StyledColumnGroup
|
|
180
|
+
grow={getOnlyShownColumns(columns).reduce((gr, col) => gr + col.grow, 0)}
|
|
181
|
+
key={index}
|
|
182
|
+
className='reqore-table-column-group'
|
|
183
|
+
width={getOnlyShownColumns(columns).reduce(
|
|
184
|
+
(wid, col) => wid + (col.resizedWidth || col.width || 80),
|
|
185
|
+
0
|
|
186
|
+
)}
|
|
187
|
+
maxWidth={getOnlyShownColumns(columns).reduce((wid, col) => wid + col.maxWidth, 0)}
|
|
188
|
+
minWidth={getOnlyShownColumns(columns).reduce((wid, col) => wid + col.minWidth, 0)}
|
|
189
|
+
>
|
|
190
|
+
{renderHeaderCell(headerComponent, {
|
|
191
|
+
...rest,
|
|
192
|
+
...omit(colRest, ['cell']),
|
|
193
|
+
dataId,
|
|
194
|
+
size,
|
|
195
|
+
readOnly: !onClick,
|
|
196
|
+
onClick,
|
|
197
|
+
rounded: false,
|
|
198
|
+
textAlign: align,
|
|
199
|
+
className: 'reqore-table-column-group-header',
|
|
200
|
+
resizable: false,
|
|
201
|
+
hideable: false,
|
|
202
|
+
hasColumns: true,
|
|
203
|
+
})}
|
|
204
|
+
<StyledColumnGroupHeaders className='reqore-table-headers'>
|
|
205
|
+
{renderColumns(columns)}
|
|
206
|
+
</StyledColumnGroupHeaders>
|
|
207
|
+
</StyledColumnGroup>
|
|
208
|
+
) : (
|
|
209
|
+
renderHeaderCell(headerComponent, {
|
|
155
210
|
...rest,
|
|
156
211
|
...omit(colRest, ['cell']),
|
|
212
|
+
onClick,
|
|
157
213
|
dataId,
|
|
158
214
|
size,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
size,
|
|
177
|
-
sortData,
|
|
178
|
-
grow,
|
|
179
|
-
align,
|
|
180
|
-
onSortChange,
|
|
181
|
-
onColumnsUpdate,
|
|
182
|
-
onFilterChange,
|
|
183
|
-
})
|
|
184
|
-
)
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
const getSelectedIcon = (): IReqoreIconName => {
|
|
188
|
-
switch (selectedQuant) {
|
|
189
|
-
case 'all':
|
|
190
|
-
return 'CheckboxCircleLine';
|
|
191
|
-
case 'some':
|
|
192
|
-
return 'IndeterminateCircleLine';
|
|
193
|
-
default:
|
|
194
|
-
return 'CheckboxBlankCircleLine';
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<StyledTableHeaderWrapper
|
|
200
|
-
className='reqore-table-header-wrapper'
|
|
201
|
-
hasVerticalScroll={hasVerticalScroll}
|
|
202
|
-
>
|
|
203
|
-
<StyledTableHeaderRow
|
|
204
|
-
style={{
|
|
205
|
-
transform: `translate3d(${leftScroll ? -leftScroll : 0}px, 0, 0)`,
|
|
206
|
-
}}
|
|
215
|
+
sortData,
|
|
216
|
+
grow,
|
|
217
|
+
align,
|
|
218
|
+
onSortChange,
|
|
219
|
+
onColumnsUpdate,
|
|
220
|
+
onFilterChange,
|
|
221
|
+
})
|
|
222
|
+
)
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<StyledTableHeaderWrapper
|
|
227
|
+
className='reqore-table-header-wrapper'
|
|
228
|
+
hasVerticalScroll={hasVerticalScroll}
|
|
229
|
+
heightAsGroup={heightAsGroup}
|
|
230
|
+
size={size}
|
|
231
|
+
ref={targetRef}
|
|
207
232
|
>
|
|
208
|
-
{
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
size,
|
|
214
|
-
onSortChange,
|
|
215
|
-
icon: getSelectedIcon(),
|
|
216
|
-
width: calculateMinimumCellWidth(50, size),
|
|
217
|
-
resizable: false,
|
|
218
|
-
hideable: false,
|
|
219
|
-
tooltip: selectToggleTooltip || 'Toggle selection on all data',
|
|
220
|
-
onClick: () => {
|
|
221
|
-
onToggleSelectClick();
|
|
222
|
-
},
|
|
223
|
-
})}
|
|
224
|
-
{renderColumns(columns)}
|
|
225
|
-
</StyledTableHeaderRow>
|
|
226
|
-
</StyledTableHeaderWrapper>
|
|
227
|
-
);
|
|
228
|
-
};
|
|
233
|
+
<StyledTableHeaderRow>{renderColumns(columns)}</StyledTableHeaderRow>
|
|
234
|
+
</StyledTableHeaderWrapper>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
);
|
|
229
238
|
|
|
230
239
|
export default ReqoreTableHeader;
|