@qoretechnologies/reqore 0.36.5 → 0.36.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/control_group.test.tsx +0 -1
- package/dist/components/Button/index.d.ts +2 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +4 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts +2 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +29 -14
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +2 -3
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +10 -9
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Table/body.d.ts +2 -2
- package/dist/components/Table/body.d.ts.map +1 -1
- package/dist/components/Table/body.js +1 -1
- package/dist/components/Table/body.js.map +1 -1
- package/dist/components/Table/cell.d.ts +1 -1
- package/dist/components/Table/cell.d.ts.map +1 -1
- package/dist/components/Table/cell.js +2 -2
- package/dist/components/Table/cell.js.map +1 -1
- package/dist/components/Table/header.d.ts +3 -3
- package/dist/components/Table/header.d.ts.map +1 -1
- package/dist/components/Table/header.js +3 -3
- package/dist/components/Table/header.js.map +1 -1
- package/dist/components/Table/headerCell.d.ts +3 -3
- package/dist/components/Table/headerCell.d.ts.map +1 -1
- package/dist/components/Table/headerCell.js +5 -6
- package/dist/components/Table/headerCell.js.map +1 -1
- package/dist/components/Table/index.d.ts +3 -2
- 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 +1 -1
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +3 -3
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Table/value.d.ts +2 -1
- package/dist/components/Table/value.d.ts.map +1 -1
- package/dist/components/Table/value.js +3 -3
- package/dist/components/Table/value.js.map +1 -1
- package/dist/helpers/utils.d.ts +2 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +25 -1
- package/dist/helpers/utils.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 +1 -1
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/hooks/useTooltip.d.ts.map +1 -1
- package/dist/hooks/useTooltip.js +3 -2
- package/dist/hooks/useTooltip.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Button/index.tsx +3 -1
- package/src/components/ControlGroup/index.tsx +54 -24
- package/src/components/Input/index.tsx +4 -2
- package/src/components/Panel/index.tsx +10 -5
- package/src/components/Table/body.tsx +2 -2
- package/src/components/Table/cell.tsx +9 -7
- package/src/components/Table/header.tsx +11 -14
- package/src/components/Table/headerCell.tsx +151 -144
- package/src/components/Table/index.tsx +4 -2
- package/src/components/Table/row.tsx +193 -173
- package/src/components/Table/value.tsx +3 -2
- package/src/helpers/utils.ts +22 -0
- package/src/hooks/usePopover.tsx +2 -1
- package/src/hooks/useTooltip.ts +7 -3
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +1 -1
- package/src/stories/Panel/Panel.stories.tsx +26 -0
- package/src/stories/Table/Table.stories.tsx +23 -1
- package/tests.json +1 -1
- package/src/stories/Table/Tests.stories.tsx +0 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import { rgba } from 'polished';
|
|
3
3
|
import { Resizable } from 're-resizable';
|
|
4
|
-
import { useMemo } from 'react';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { IReqoreTableColumn, IReqoreTableSort } from '.';
|
|
7
7
|
import { ReqoreButton, ReqoreControlGroup, ReqoreDropdown } from '../..';
|
|
@@ -13,12 +13,12 @@ import { TColumnsUpdater } from './header';
|
|
|
13
13
|
|
|
14
14
|
export interface IReqoreTableHeaderCellProps
|
|
15
15
|
extends Omit<IReqoreTableColumn, 'cell'>,
|
|
16
|
-
|
|
16
|
+
Pick<IReqoreTableColumn['header'], 'content' | 'actions'>,
|
|
17
|
+
Omit<IReqoreButtonProps, 'maxWidth' | 'content'> {
|
|
17
18
|
onSortChange?: (sort: string) => void;
|
|
18
19
|
sortData?: IReqoreTableSort;
|
|
19
20
|
onColumnsUpdate?: TColumnsUpdater;
|
|
20
21
|
onFilterChange?: (dataId: string, filter: string) => void;
|
|
21
|
-
actions?: IReqoreTableColumn['header']['actions'];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface IReqoreTableHeaderStyle {
|
|
@@ -42,155 +42,162 @@ export const StyledTableHeaderResize = styled.div`
|
|
|
42
42
|
}
|
|
43
43
|
`;
|
|
44
44
|
|
|
45
|
-
export const ReqoreTableHeaderCell = (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
45
|
+
export const ReqoreTableHeaderCell = memo(
|
|
46
|
+
({
|
|
47
|
+
width,
|
|
48
|
+
maxWidth,
|
|
49
|
+
minWidth,
|
|
50
|
+
resizedWidth,
|
|
51
|
+
grow,
|
|
52
|
+
align,
|
|
53
|
+
pin,
|
|
54
|
+
onSortChange,
|
|
55
|
+
dataId,
|
|
56
|
+
sortable,
|
|
57
|
+
sortData,
|
|
58
|
+
className,
|
|
59
|
+
onClick,
|
|
60
|
+
onColumnsUpdate,
|
|
61
|
+
resizable = true,
|
|
62
|
+
filterPlaceholder,
|
|
63
|
+
filterable,
|
|
64
|
+
hideable = true,
|
|
65
|
+
pinnable = true,
|
|
66
|
+
filter,
|
|
67
|
+
content,
|
|
68
|
+
size,
|
|
69
|
+
onFilterChange,
|
|
70
|
+
actions,
|
|
71
|
+
...rest
|
|
72
|
+
}: IReqoreTableHeaderCellProps) => {
|
|
73
|
+
const items = useMemo(() => {
|
|
74
|
+
let _items: IReqoreDropdownItem[] = [];
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
if (resizable || hideable) {
|
|
77
|
+
if (resizable) {
|
|
78
|
+
_items.push({
|
|
79
|
+
label: 'Reset size',
|
|
80
|
+
icon: 'HistoryLine',
|
|
81
|
+
disabled: !resizedWidth || width === resizedWidth,
|
|
82
|
+
onClick: () => {
|
|
83
|
+
onColumnsUpdate?.(dataId, 'resizedWidth', width);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
if (pinnable) {
|
|
89
|
+
_items.push({ divider: true, size: 'small', line: true });
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
_items.push({
|
|
92
|
+
label: 'Pin left',
|
|
93
|
+
icon: 'SkipBackLine',
|
|
94
|
+
active: pin === 'left',
|
|
95
|
+
intent: pin === 'left' ? 'info' : undefined,
|
|
96
|
+
onClick: () => {
|
|
97
|
+
onColumnsUpdate?.(dataId, 'pin', pin !== 'left' ? 'left' : undefined);
|
|
98
|
+
},
|
|
99
|
+
});
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
_items.push({
|
|
102
|
+
label: 'Pin Right',
|
|
103
|
+
icon: 'SkipForwardLine',
|
|
104
|
+
active: pin === 'right',
|
|
105
|
+
intent: pin === 'right' ? 'info' : undefined,
|
|
106
|
+
onClick: () => {
|
|
107
|
+
onColumnsUpdate?.(dataId, 'pin', pin !== 'right' ? 'right' : undefined);
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
if (hideable) {
|
|
113
|
+
_items.push({ divider: true, size: 'small', line: true });
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
_items.push({
|
|
116
|
+
label: 'Hide column',
|
|
117
|
+
icon: 'EyeCloseLine',
|
|
118
|
+
className: 'reqore-table-header-hide',
|
|
119
|
+
onClick: () => {
|
|
120
|
+
onColumnsUpdate?.(dataId, 'show', false);
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
121
124
|
}
|
|
122
|
-
}
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
if (actions) {
|
|
127
|
+
_items = [..._items, { divider: true, label: 'Other' }, ...actions];
|
|
128
|
+
}
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
return _items;
|
|
131
|
+
}, [resizable, hideable, width, resizedWidth, onColumnsUpdate, dataId]);
|
|
130
132
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
133
|
+
return (
|
|
134
|
+
<Resizable
|
|
135
|
+
minWidth={minWidth || width}
|
|
136
|
+
maxWidth={maxWidth}
|
|
137
|
+
onResize={(_event, _direction, _component) => {
|
|
138
|
+
onColumnsUpdate?.(dataId, 'resizedWidth', parseInt(_component.style.width));
|
|
139
|
+
}}
|
|
140
|
+
handleComponent={{
|
|
141
|
+
right: <StyledTableHeaderResize />,
|
|
142
|
+
}}
|
|
143
|
+
style={{
|
|
144
|
+
overflow: 'hidden',
|
|
145
|
+
flexGrow: grow,
|
|
146
|
+
}}
|
|
147
|
+
size={{
|
|
148
|
+
width: resizedWidth || width,
|
|
149
|
+
height: undefined,
|
|
150
|
+
}}
|
|
151
|
+
enable={{
|
|
152
|
+
right: resizable,
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<ReqoreControlGroup fluid stack rounded={false} fill style={{ height: '100%' }}>
|
|
156
|
+
{content ? (
|
|
157
|
+
content
|
|
158
|
+
) : (
|
|
159
|
+
<ReqoreButton
|
|
160
|
+
{...rest}
|
|
161
|
+
size={size}
|
|
162
|
+
readOnly={!sortable && !onClick}
|
|
163
|
+
className={`${className || ''} reqore-table-header-cell`}
|
|
164
|
+
rounded={false}
|
|
165
|
+
textAlign={align}
|
|
166
|
+
rightIcon={
|
|
167
|
+
sortable && sortData.by === dataId
|
|
168
|
+
? (`Arrow${sortData.direction === 'desc' ? 'Down' : 'Up'}Fill` as
|
|
169
|
+
| 'ArrowDownFill'
|
|
170
|
+
| 'ArrowUpFill')
|
|
171
|
+
: rest.rightIcon
|
|
172
|
+
}
|
|
173
|
+
onClick={(e) => {
|
|
174
|
+
if (sortable) {
|
|
175
|
+
onSortChange?.(dataId);
|
|
176
|
+
}
|
|
172
177
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
onFilterChange
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
178
|
+
onClick?.(e);
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
)}
|
|
182
|
+
{filterable || hideable || resizable ? (
|
|
183
|
+
<ReqoreDropdown<IReqoreButtonProps>
|
|
184
|
+
icon='MoreLine'
|
|
185
|
+
className='reqore-table-header-cell-options'
|
|
186
|
+
fixed
|
|
187
|
+
size={size}
|
|
188
|
+
rounded={false}
|
|
189
|
+
intent={filter ? 'info' : rest.intent}
|
|
190
|
+
filterable={filterable}
|
|
191
|
+
filterPlaceholder={filterPlaceholder || 'Filter by this column...'}
|
|
192
|
+
filter={filter}
|
|
193
|
+
onFilterChange={(value) => {
|
|
194
|
+
onFilterChange?.(dataId, value);
|
|
195
|
+
}}
|
|
196
|
+
items={items}
|
|
197
|
+
/>
|
|
198
|
+
) : null}
|
|
199
|
+
</ReqoreControlGroup>
|
|
200
|
+
</Resizable>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
);
|
|
@@ -59,7 +59,7 @@ export type TReqoreTableColumnContent =
|
|
|
59
59
|
export interface IReqoreTableColumn extends IReqoreIntent {
|
|
60
60
|
dataId: string;
|
|
61
61
|
show?: boolean;
|
|
62
|
-
grow?: 1 | 2 | 3 | 4;
|
|
62
|
+
grow?: 0 | 1 | 2 | 3 | 4;
|
|
63
63
|
width?: number;
|
|
64
64
|
minWidth?: number;
|
|
65
65
|
maxWidth?: number;
|
|
@@ -79,8 +79,10 @@ export interface IReqoreTableColumn extends IReqoreIntent {
|
|
|
79
79
|
header?: {
|
|
80
80
|
columns?: IReqoreTableColumn[];
|
|
81
81
|
component?: React.FC<IReqoreTableHeaderCellProps>;
|
|
82
|
+
// Content is the same as react children
|
|
83
|
+
content?: React.ReactNode;
|
|
82
84
|
actions?: IReqoreDropdownItem[];
|
|
83
|
-
} & Omit<IReqoreButtonProps, 'maxWidth'>;
|
|
85
|
+
} & Omit<IReqoreButtonProps, 'maxWidth' | 'content'>;
|
|
84
86
|
|
|
85
87
|
cell?: {
|
|
86
88
|
onClick?: (cellValue: any) => void;
|