@bento-core/table 1.0.0-c3dc.31 → 1.0.0-c3dc.33
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/dist/DefaultThemConfig.js +12 -3
- package/dist/ExtendedView.js +9 -8
- package/dist/TableView.js +28 -8
- package/dist/toolbar/DownloadButtonView.js +27 -17
- package/dist/toolbar/ManageColumnView.js +272 -40
- package/dist/toolbar/assets/Hidden_Column.svg +4 -0
- package/dist/toolbar/assets/Search_Icon.svg +3 -0
- package/dist/toolbar/assets/View_Columns.svg +6 -0
- package/package.json +1 -1
- package/src/DefaultThemConfig.js +12 -3
- package/src/ExtendedView.js +24 -20
- package/src/TableView.js +90 -64
- package/src/toolbar/DownloadButtonView.js +21 -17
- package/src/toolbar/ManageColumnView.js +287 -63
- package/src/toolbar/assets/Hidden_Column.svg +4 -0
- package/src/toolbar/assets/Search_Icon.svg +3 -0
- package/src/toolbar/assets/View_Columns.svg +6 -0
|
@@ -1,99 +1,207 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Checkbox,
|
|
4
|
+
FormControlLabel,
|
|
4
5
|
IconButton,
|
|
5
6
|
List,
|
|
6
7
|
ListItem,
|
|
7
|
-
Popover,
|
|
8
8
|
Tooltip,
|
|
9
9
|
Typography,
|
|
10
10
|
withStyles,
|
|
11
|
+
Divider,
|
|
11
12
|
} from '@material-ui/core';
|
|
12
13
|
import {
|
|
13
|
-
ViewColumn,
|
|
14
14
|
CheckBox as CheckBoxIcon,
|
|
15
15
|
CheckBoxOutlineBlank as CheckBoxBlankIcon,
|
|
16
16
|
Close,
|
|
17
17
|
} from '@material-ui/icons';
|
|
18
|
+
import KeyboardArrowDownOutlinedIcon from '@material-ui/icons/KeyboardArrowDownOutlined';
|
|
18
19
|
import { cellTypes } from '../util/Types';
|
|
20
|
+
import viewColumnsIcon from './assets/View_Columns.svg';
|
|
21
|
+
import hiddenColumnsIcon from './assets/Hidden_Column.svg';
|
|
22
|
+
|
|
23
|
+
// Height threshold to trigger scrolling behavior
|
|
24
|
+
const SCROLL_THRESHOLD_HEIGHT = 400;
|
|
25
|
+
// Maximum height of scrollable content area when scroll is needed
|
|
26
|
+
const SCROLLABLE_MAX_HEIGHT = '253px';
|
|
19
27
|
|
|
20
28
|
const ManageColumnView = ({
|
|
21
29
|
table,
|
|
22
30
|
onColumnViewChange,
|
|
31
|
+
onAllColumnViewChange,
|
|
23
32
|
manageViewColumns,
|
|
33
|
+
classes,
|
|
24
34
|
}) => {
|
|
25
35
|
if (!manageViewColumns) {
|
|
26
36
|
return null;
|
|
27
37
|
}
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
38
|
+
const { columns } = table;
|
|
39
|
+
const [listDisplay, setListDisplay] = useState('none');
|
|
40
|
+
const [selectAll, setSelectAll] = useState(false);
|
|
41
|
+
const [needsScroll, setNeedsScroll] = useState(false);
|
|
42
|
+
|
|
43
|
+
const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY
|
|
44
|
+
&& col.disableInManageView !== true);
|
|
45
|
+
|
|
46
|
+
const dropdownSelection = useRef(null);
|
|
47
|
+
const formGroupRef = useRef(null);
|
|
48
|
+
|
|
49
|
+
const handleClose = () => {
|
|
50
|
+
setListDisplay('none');
|
|
31
51
|
};
|
|
32
52
|
|
|
33
|
-
const
|
|
53
|
+
const handleClickButton = () => {
|
|
54
|
+
if (listDisplay === 'none') {
|
|
55
|
+
setListDisplay('block');
|
|
56
|
+
} else {
|
|
57
|
+
setListDisplay('none');
|
|
58
|
+
}
|
|
59
|
+
};
|
|
34
60
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
const useOutsideAlerter = (ref) => {
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
function handleClickOutside(event) {
|
|
64
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
65
|
+
setListDisplay('none');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
69
|
+
return () => {
|
|
70
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
};
|
|
74
|
+
useOutsideAlerter(dropdownSelection);
|
|
75
|
+
|
|
76
|
+
const handleSelectAll = () => {
|
|
77
|
+
setSelectAll(!selectAll);
|
|
78
|
+
onAllColumnViewChange(!selectAll);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (formGroupRef.current && listDisplay === 'block') {
|
|
83
|
+
const contentHeight = formGroupRef.current.scrollHeight;
|
|
84
|
+
setNeedsScroll(contentHeight > SCROLL_THRESHOLD_HEIGHT);
|
|
85
|
+
}
|
|
86
|
+
}, [viewColumns, listDisplay]);
|
|
38
87
|
|
|
39
88
|
return (
|
|
40
|
-
|
|
89
|
+
<div ref={dropdownSelection} className={listDisplay === 'none' ? classes.columnDropdown : classes.columnDropdownActive}>
|
|
90
|
+
<Tooltip title="Columns may be hidden">
|
|
91
|
+
<img src={hiddenColumnsIcon} alt="hiddenColumnsIcon" className={classes.displayColumnIcon} />
|
|
92
|
+
</Tooltip>
|
|
41
93
|
<Tooltip title={manageViewColumns.title}>
|
|
42
|
-
<IconButton variant="contained" onClick={
|
|
43
|
-
<
|
|
94
|
+
<IconButton variant="contained" onClick={handleClickButton} className={classes.viewColumnsButton}>
|
|
95
|
+
<img src={viewColumnsIcon} alt="viewColumnsIcon" />
|
|
96
|
+
<KeyboardArrowDownOutlinedIcon className={classes.arrowDownIcon} />
|
|
44
97
|
</IconButton>
|
|
45
98
|
</Tooltip>
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
<div className={listDisplay === 'none' ? classes.dropdownListHidden : classes.dropdownListVisible}>
|
|
100
|
+
<div className={classes.dropdownHeader}>
|
|
101
|
+
<Typography variant="caption" className={classes.titleText}>
|
|
102
|
+
{manageViewColumns.title}
|
|
103
|
+
</Typography>
|
|
104
|
+
<IconButton
|
|
105
|
+
onClick={handleClose}
|
|
106
|
+
className={classes.closeIconButton}
|
|
107
|
+
>
|
|
108
|
+
<Close />
|
|
109
|
+
</IconButton>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
<List className="viewColumnList" id="dropdownListItemTitle">
|
|
113
|
+
<div
|
|
114
|
+
ref={formGroupRef}
|
|
115
|
+
className={classes.formGroup}
|
|
116
|
+
style={needsScroll ? { maxHeight: SCROLLABLE_MAX_HEIGHT } : {}}
|
|
117
|
+
>
|
|
118
|
+
{viewColumns.map((column, index) => (
|
|
119
|
+
<ListItem
|
|
120
|
+
width={1}
|
|
121
|
+
className="viewColumnListItem"
|
|
122
|
+
id={`dropdownListItem-${index}`}
|
|
123
|
+
>
|
|
124
|
+
<FormControlLabel
|
|
125
|
+
control={(
|
|
126
|
+
<Checkbox
|
|
127
|
+
icon={(
|
|
128
|
+
<CheckBoxBlankIcon
|
|
129
|
+
style={{ fontSize: 18 }}
|
|
130
|
+
className="checkBoxIcon"
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
133
|
+
onClick={() => onColumnViewChange(column)}
|
|
134
|
+
checked={column.display}
|
|
135
|
+
id={`dropdownListItemCheckbox-${index}`}
|
|
136
|
+
checkedIcon={(
|
|
137
|
+
<CheckBoxIcon
|
|
138
|
+
style={{
|
|
139
|
+
fontSize: 18,
|
|
140
|
+
color: column.hideable ? 'rgba(109, 95, 91, 1)' : 'rgba(109, 95, 91, 0.38)',
|
|
141
|
+
}}
|
|
142
|
+
className="checkBoxIcon"
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
145
|
+
disableRipple
|
|
146
|
+
color="secondary"
|
|
147
|
+
className="checkBox"
|
|
148
|
+
disabled={!column.hideable}
|
|
149
|
+
style={{ paddingTop: 0 }}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
disabled={!column.hideable}
|
|
153
|
+
label={<Typography id={`dropdownListItemLabel-${index}`} className={classes.textStyle}>{column.header}</Typography>}
|
|
154
|
+
id={`dropdownListItem-${index}-label`}
|
|
155
|
+
className={classes.checkboxItemLabel}
|
|
156
|
+
/>
|
|
157
|
+
</ListItem>
|
|
158
|
+
))}
|
|
159
|
+
</div>
|
|
160
|
+
<Divider className={classes.dividerStyle} />
|
|
161
|
+
<ListItem
|
|
162
|
+
width={1}
|
|
163
|
+
className="viewColumnListItem"
|
|
164
|
+
>
|
|
165
|
+
<FormControlLabel
|
|
166
|
+
control={(
|
|
167
|
+
<Checkbox
|
|
168
|
+
icon={(
|
|
169
|
+
<CheckBoxBlankIcon
|
|
170
|
+
style={{ fontSize: 18 }}
|
|
171
|
+
className="checkBoxIcon"
|
|
172
|
+
/>
|
|
173
|
+
)}
|
|
174
|
+
onClick={() => handleSelectAll()}
|
|
175
|
+
checked={selectAll}
|
|
176
|
+
id="dropdownListItem-all"
|
|
177
|
+
checkedIcon={(
|
|
178
|
+
<CheckBoxIcon
|
|
179
|
+
style={{
|
|
180
|
+
fontSize: 18,
|
|
181
|
+
color: 'rgba(109, 95, 91, 1)',
|
|
182
|
+
}}
|
|
183
|
+
className="checkBoxIcon"
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
disableRipple
|
|
187
|
+
color="secondary"
|
|
188
|
+
className="checkBox"
|
|
189
|
+
style={{ paddingTop: 0 }}
|
|
190
|
+
/>
|
|
191
|
+
)}
|
|
192
|
+
label={(
|
|
193
|
+
<Typography id="dropdownListItem-all-label" className={classes.textStyle}>
|
|
194
|
+
{selectAll ? 'Deselect All' : 'Select All'}
|
|
195
|
+
</Typography>
|
|
196
|
+
)}
|
|
197
|
+
id="dropdownListItem-all-label"
|
|
198
|
+
className={classes.checkboxItemLabel}
|
|
199
|
+
style={{ padding: '2px 0px' }}
|
|
200
|
+
/>
|
|
201
|
+
</ListItem>
|
|
94
202
|
</List>
|
|
95
|
-
</
|
|
96
|
-
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
97
205
|
);
|
|
98
206
|
};
|
|
99
207
|
|
|
@@ -102,6 +210,102 @@ const styles = () => ({
|
|
|
102
210
|
padding: '16px 24px 16px 24px',
|
|
103
211
|
fontFamily: 'Roboto',
|
|
104
212
|
},
|
|
213
|
+
displayColumnIcon: {
|
|
214
|
+
position: 'absolute',
|
|
215
|
+
right: '35px',
|
|
216
|
+
bottom: '23px',
|
|
217
|
+
},
|
|
218
|
+
columnDropdown: {
|
|
219
|
+
width: '48px',
|
|
220
|
+
height: '36px',
|
|
221
|
+
paddingLeft: '5px',
|
|
222
|
+
border: '0.5px solid #606060',
|
|
223
|
+
borderRadius: '5px',
|
|
224
|
+
display: 'inline-flex',
|
|
225
|
+
position: 'relative',
|
|
226
|
+
padding: '0px 0px 0px 5px',
|
|
227
|
+
margin: '5px 11px 5px 1px',
|
|
228
|
+
},
|
|
229
|
+
columnDropdownActive: {
|
|
230
|
+
width: '48px',
|
|
231
|
+
height: '36px',
|
|
232
|
+
border: '1.5px solid #5666BD',
|
|
233
|
+
borderRadius: '5px',
|
|
234
|
+
display: 'inline-flex',
|
|
235
|
+
position: 'relative',
|
|
236
|
+
padding: '0px 0px 0px 5px',
|
|
237
|
+
margin: '5px 10px 5px 0px',
|
|
238
|
+
},
|
|
239
|
+
viewColumnsButton: {
|
|
240
|
+
marginTop: '6px',
|
|
241
|
+
height: '24px',
|
|
242
|
+
backgroundColor: 'transparent',
|
|
243
|
+
},
|
|
244
|
+
arrowDownIcon: {
|
|
245
|
+
fill: '#606060',
|
|
246
|
+
width: '20px',
|
|
247
|
+
height: '20px',
|
|
248
|
+
},
|
|
249
|
+
dropdownListHidden: {
|
|
250
|
+
position: 'absolute',
|
|
251
|
+
width: '230px',
|
|
252
|
+
marginTop: '38px',
|
|
253
|
+
marginLeft: '-188px',
|
|
254
|
+
zIndex: '11',
|
|
255
|
+
border: '1.5px solid #5666BD',
|
|
256
|
+
borderRadius: '5px',
|
|
257
|
+
background: '#ffffff',
|
|
258
|
+
display: 'none',
|
|
259
|
+
},
|
|
260
|
+
dropdownListVisible: {
|
|
261
|
+
position: 'absolute',
|
|
262
|
+
width: '230px',
|
|
263
|
+
marginTop: '38px',
|
|
264
|
+
marginLeft: '-188px',
|
|
265
|
+
zIndex: '11',
|
|
266
|
+
border: '1.5px solid #5666BD',
|
|
267
|
+
borderRadius: '5px',
|
|
268
|
+
background: '#ffffff',
|
|
269
|
+
display: 'block',
|
|
270
|
+
maxHeight: '473px',
|
|
271
|
+
},
|
|
272
|
+
dropdownHeader: {
|
|
273
|
+
display: 'flex',
|
|
274
|
+
alignItems: 'center',
|
|
275
|
+
justifyContent: 'space-between',
|
|
276
|
+
padding: '16px 15px 0px 21px',
|
|
277
|
+
},
|
|
278
|
+
titleText: {
|
|
279
|
+
fontFamily: 'Poppins',
|
|
280
|
+
fontWeight: '400',
|
|
281
|
+
fontSize: '14px',
|
|
282
|
+
lineHeight: '100%',
|
|
283
|
+
color: '#000000',
|
|
284
|
+
},
|
|
285
|
+
closeIconButton: {
|
|
286
|
+
scale: '0.75',
|
|
287
|
+
bottom: '14.5px',
|
|
288
|
+
left: '12.5px',
|
|
289
|
+
},
|
|
290
|
+
checkboxItemLabel: {
|
|
291
|
+
marginLeft: '0px !important',
|
|
292
|
+
},
|
|
293
|
+
textStyle: {
|
|
294
|
+
fontFamily: 'Poppins',
|
|
295
|
+
fontSize: '14px',
|
|
296
|
+
fontWeight: '400',
|
|
297
|
+
marginBottom: '3px',
|
|
298
|
+
lineHeight: '15px',
|
|
299
|
+
},
|
|
300
|
+
dividerStyle: {
|
|
301
|
+
backgroundColor: '#375F9A',
|
|
302
|
+
marginTop: '5px',
|
|
303
|
+
marginBottom: '5px',
|
|
304
|
+
width: 'calc(100% + 20px)',
|
|
305
|
+
position: 'relative',
|
|
306
|
+
left: '-10px',
|
|
307
|
+
height: '0.5px',
|
|
308
|
+
},
|
|
105
309
|
title: {
|
|
106
310
|
marginRight: '24px',
|
|
107
311
|
fontSize: '14px',
|
|
@@ -111,6 +315,19 @@ const styles = () => ({
|
|
|
111
315
|
},
|
|
112
316
|
formGroup: {
|
|
113
317
|
marginTop: '8px',
|
|
318
|
+
overflowY: 'auto',
|
|
319
|
+
overflowX: 'hidden',
|
|
320
|
+
'&::-webkit-scrollbar': {
|
|
321
|
+
width: '6px',
|
|
322
|
+
},
|
|
323
|
+
'&::-webkit-scrollbar-track': {
|
|
324
|
+
background: 'transparent',
|
|
325
|
+
borderRadius: '5px',
|
|
326
|
+
},
|
|
327
|
+
'&::-webkit-scrollbar-thumb': {
|
|
328
|
+
backgroundColor: '#707070',
|
|
329
|
+
borderRadius: '5px',
|
|
330
|
+
},
|
|
114
331
|
},
|
|
115
332
|
formControl: {},
|
|
116
333
|
checkbox: {
|
|
@@ -128,6 +345,13 @@ const styles = () => ({
|
|
|
128
345
|
fontSize: '15px',
|
|
129
346
|
marginLeft: '8px',
|
|
130
347
|
},
|
|
348
|
+
viewColumnListItem: {
|
|
349
|
+
height: '18px',
|
|
350
|
+
},
|
|
351
|
+
formControlLabel: {
|
|
352
|
+
marginLeft: '13px',
|
|
353
|
+
position: 'relative',
|
|
354
|
+
},
|
|
131
355
|
});
|
|
132
356
|
|
|
133
357
|
export default withStyles(styles)(ManageColumnView);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="20" height="19" viewBox="0 0 20 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect x="10" y="0.928786" width="12.2783" height="12.2783" rx="2.5" transform="rotate(45 10 0.928786)" fill="#FFEB13" stroke="black"/>
|
|
3
|
+
<path d="M9.99994 7.14529C9.74072 7.14529 9.52354 7.06575 9.3484 6.90667C9.18026 6.74068 9.09619 6.53664 9.09619 6.29457C9.09619 6.05249 9.18026 5.85192 9.3484 5.69284C9.52354 5.52684 9.74072 5.44385 9.99994 5.44385C10.2592 5.44385 10.4728 5.52684 10.641 5.69284C10.8161 5.85192 10.9037 6.05249 10.9037 6.29457C10.9037 6.53664 10.8161 6.74068 10.641 6.90667C10.4728 7.06575 10.2592 7.14529 9.99994 7.14529ZM10.725 7.83001V13.5776H9.25382V7.83001H10.725Z" fill="black"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M6.4134 1C3.43007 1 1 3.43007 1 6.4134C1 9.39672 3.43007 11.8268 6.4134 11.8268C7.71072 11.8268 8.90214 11.3661 9.83589 10.6014L13.0681 13.8336C13.118 13.8855 13.1777 13.927 13.2438 13.9556C13.3099 13.9841 13.3811 13.9992 13.4531 14C13.5251 14.0007 13.5966 13.9871 13.6632 13.9598C13.7299 13.9326 13.7905 13.8924 13.8414 13.8414C13.8924 13.7905 13.9326 13.7299 13.9598 13.6632C13.9871 13.5966 14.0007 13.5251 14 13.4531C13.9992 13.3811 13.9841 13.3099 13.9556 13.2438C13.927 13.1777 13.8855 13.118 13.8336 13.0681L10.6014 9.83589C11.3661 8.90214 11.8268 7.71072 11.8268 6.4134C11.8268 3.43007 9.39672 1 6.4134 1ZM6.4134 2.08268C8.8116 2.08268 10.7441 4.0152 10.7441 6.4134C10.7441 8.8116 8.8116 10.7441 6.4134 10.7441C4.0152 10.7441 2.08268 8.8116 2.08268 6.4134C2.08268 4.0152 4.0152 2.08268 6.4134 2.08268Z" fill="#4D889E" stroke="#4D889E"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="20" height="18" viewBox="0 0 20 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M2.88892 1.40607H17.1116C17.6636 1.40633 18.1116 1.85394 18.1116 2.40607V15.5936C18.1116 16.1457 17.6636 16.5933 17.1116 16.5936H2.88892C2.33663 16.5936 1.88892 16.1459 1.88892 15.5936V2.40607C1.88892 1.85378 2.33663 1.40607 2.88892 1.40607Z" fill="white" stroke="#606060" stroke-width="2"/>
|
|
3
|
+
<line x1="1.79956" y1="6.08969" x2="19.1106" y2="6.08969" stroke="#606060" stroke-width="2"/>
|
|
4
|
+
<line x1="13.2661" y1="7.09055" x2="13.2661" y2="17.5941" stroke="#606060" stroke-width="2"/>
|
|
5
|
+
<line x1="7.6936" y1="7.0903" x2="7.6936" y2="17.5939" stroke="#606060" stroke-width="2"/>
|
|
6
|
+
</svg>
|