@bento-core/table 1.0.1-ccdihub.91 → 1.0.1-ccdihub.92

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.
@@ -19,7 +19,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
19
19
  const downloadAreaStyle = {
20
20
  display: 'flex',
21
21
  borderTop: '1px solid #8A7F7C',
22
- paddingRight: '41px'
22
+ paddingRight: '48px'
23
23
  };
24
24
  const ExtendedView = _ref => {
25
25
  let {
@@ -115,7 +115,7 @@ const DownloadButton = _ref => {
115
115
  width: '48px',
116
116
  height: '36px',
117
117
  paddingLeft: '5px',
118
- border: '0.75px solid #606060',
118
+ border: " ".concat(listDisplay === 'none' ? '0.75px solid #606060' : '1.5px solid #5666BD'),
119
119
  borderRadius: '5px',
120
120
  display: 'inline-block',
121
121
  position: 'relative',
@@ -125,11 +125,11 @@ const DownloadButton = _ref => {
125
125
  display: 'block',
126
126
  position: 'absolute',
127
127
  width: '60px',
128
- marginTop: '3px',
129
- marginLeft: '-5px',
128
+ top: '38px',
129
+ right: '0.5px',
130
130
  overflow: 'auto',
131
131
  zIndex: '5',
132
- border: '1.5px solid #41545E',
132
+ border: '1.5px solid #5666BD',
133
133
  borderRadius: '5px',
134
134
  background: '#ffffff'
135
135
  },
@@ -140,7 +140,7 @@ const DownloadButton = _ref => {
140
140
  fontWeight: 400,
141
141
  lineHeight: '21px',
142
142
  '&:hover': {
143
- background: '#D7D7D7',
143
+ background: '#C9CFF4',
144
144
  cursor: 'pointer'
145
145
  }
146
146
  },
@@ -163,11 +163,17 @@ const DownloadButton = _ref => {
163
163
  title: "Download filtered results",
164
164
  className: classes.tooltip
165
165
  }, count !== 0 ? /*#__PURE__*/_react.default.createElement(_core.IconButton, {
166
- onClick: handleClickButton
166
+ onClick: handleClickButton,
167
+ style: {
168
+ backgroundColor: 'transparent'
169
+ }
167
170
  }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
168
171
  className: classes.arrowdownIcon
169
172
  })) : /*#__PURE__*/_react.default.createElement(_core.IconButton, {
170
- disabled: true
173
+ disabled: true,
174
+ style: {
175
+ backgroundColor: 'transparent'
176
+ }
171
177
  }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
172
178
  className: classes.arrowdownIconDisabled
173
179
  }))), /*#__PURE__*/_react.default.createElement("div", {
@@ -27,13 +27,35 @@ const ManageColumnView = _ref => {
27
27
  const {
28
28
  columns
29
29
  } = table;
30
- const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
30
+ const [listDisplay, setListDisplay] = (0, _react.useState)('none');
31
31
  const [selectAll, setSelectAll] = (0, _react.useState)(false);
32
32
  const viewColumns = columns.filter(col => col.role === _Types.cellTypes.DISPLAY);
33
- const handleClick = event => {
34
- setAnchorEl(event.currentTarget);
33
+ const dropdownSelection = (0, _react.useRef)(null);
34
+ const handleClose = () => {
35
+ setListDisplay('none');
35
36
  };
36
- const handleClose = () => setAnchorEl(null);
37
+ const handleClickButton = () => {
38
+ if (listDisplay === 'none') {
39
+ setListDisplay('block');
40
+ } else {
41
+ setListDisplay('none');
42
+ }
43
+ };
44
+ const useOutsideAlerter = ref => {
45
+ (0, _react.useEffect)(() => {
46
+ function handleClickOutside(event) {
47
+ console.log(event.target);
48
+ if (!(event.target.getAttribute('id') && event.target.getAttribute('id').includes('dropdownListItem')) && !(event.target.getAttribute('class') && event.target.getAttribute('class').includes('MuiFormControlLabel'))) {
49
+ setListDisplay('none');
50
+ }
51
+ }
52
+ document.addEventListener('mousedown', handleClickOutside);
53
+ return () => {
54
+ document.removeEventListener('mousedown', handleClickOutside);
55
+ };
56
+ }, [ref]);
57
+ };
58
+ useOutsideAlerter(dropdownSelection);
37
59
  const handleSelectAll = () => {
38
60
  const state = selectAll;
39
61
  setSelectAll(!selectAll);
@@ -43,7 +65,7 @@ const ManageColumnView = _ref => {
43
65
  width: '48px',
44
66
  height: '36px',
45
67
  paddingLeft: '5px',
46
- border: '0.75px solid #606060',
68
+ border: "".concat(listDisplay === 'none' ? '0.75px solid #606060' : '1.5px solid #5666BD'),
47
69
  borderRadius: '5px',
48
70
  display: 'inline-flex',
49
71
  position: 'relative',
@@ -51,20 +73,30 @@ const ManageColumnView = _ref => {
51
73
  marginRight: '7px'
52
74
  };
53
75
  const displayColumnStyle = {
54
- position: 'relative',
55
- right: '20px',
56
- bottom: '15px',
57
- scale: '0.5'
76
+ position: 'absolute',
77
+ right: '35px',
78
+ bottom: '23px'
58
79
  };
59
80
  const viewColumnsStyle = {
60
81
  marginTop: '6px',
61
82
  height: '24px',
62
- right: '37px'
83
+ backgroundColor: 'transparent'
84
+ };
85
+ const dropdownList = {
86
+ position: 'absolute',
87
+ width: '230px',
88
+ marginTop: '38px',
89
+ marginLeft: '-187px',
90
+ overflow: 'auto',
91
+ zIndex: '5',
92
+ border: '1.5px solid #5666BD',
93
+ borderRadius: '5px',
94
+ background: '#ffffff',
95
+ display: listDisplay
63
96
  };
64
97
  const arrowdownIcon = {
65
98
  fill: '#606060'
66
99
  };
67
- const open = Boolean(anchorEl);
68
100
  return /*#__PURE__*/_react.default.createElement("div", {
69
101
  style: columnDropdown
70
102
  }, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
@@ -77,21 +109,15 @@ const ManageColumnView = _ref => {
77
109
  title: manageViewColumns.title
78
110
  }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
79
111
  variant: "contained",
80
- onClick: handleClick,
112
+ onClick: handleClickButton,
81
113
  style: viewColumnsStyle
82
114
  }, /*#__PURE__*/_react.default.createElement("img", {
83
115
  src: _View_Columns.default,
84
116
  alt: "viewColumnsIcon"
85
117
  }), /*#__PURE__*/_react.default.createElement(_KeyboardArrowDownOutlined.default, {
86
118
  style: arrowdownIcon
87
- }))), /*#__PURE__*/_react.default.createElement(_core.Popover, {
88
- open: open,
89
- anchorEl: anchorEl,
90
- onClose: handleClose,
91
- anchorOrigin: {
92
- vertical: 'bottom',
93
- horizontal: 'left'
94
- }
119
+ }))), /*#__PURE__*/_react.default.createElement("div", {
120
+ style: dropdownList
95
121
  }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
96
122
  variant: "caption",
97
123
  className: "viewColumnText"
@@ -103,9 +129,10 @@ const ManageColumnView = _ref => {
103
129
  }
104
130
  }, /*#__PURE__*/_react.default.createElement(_icons.Close, null)), /*#__PURE__*/_react.default.createElement(_core.List, {
105
131
  className: "viewColumnList"
106
- }, viewColumns.map(column => /*#__PURE__*/_react.default.createElement(_core.ListItem, {
132
+ }, viewColumns.map((column, index) => /*#__PURE__*/_react.default.createElement(_core.ListItem, {
107
133
  width: 1,
108
- className: "viewColumnListItem"
134
+ className: "viewColumnListItem",
135
+ id: "dropdownListItem-".concat(index)
109
136
  }, /*#__PURE__*/_react.default.createElement(_core.FormControlLabel, {
110
137
  control: /*#__PURE__*/_react.default.createElement(_core.Checkbox, {
111
138
  icon: /*#__PURE__*/_react.default.createElement(_icons.CheckBoxOutlineBlank, {
@@ -116,6 +143,7 @@ const ManageColumnView = _ref => {
116
143
  }),
117
144
  onClick: () => onColumnViewChange(column),
118
145
  checked: column.display,
146
+ id: "dropdownListItemCheckbox-".concat(index),
119
147
  checkedIcon: /*#__PURE__*/_react.default.createElement(_icons.CheckBox, {
120
148
  style: {
121
149
  fontSize: 18,
@@ -129,7 +157,8 @@ const ManageColumnView = _ref => {
129
157
  disabled: !column.hideable
130
158
  }),
131
159
  disabled: !column.hideable,
132
- label: column.header
160
+ label: column.header,
161
+ id: "dropdownListItem-".concat(index, "-label")
133
162
  }))), /*#__PURE__*/_react.default.createElement(_core.Divider, {
134
163
  style: {
135
164
  color: '#375F9A',
@@ -149,6 +178,7 @@ const ManageColumnView = _ref => {
149
178
  }),
150
179
  onClick: () => handleSelectAll(),
151
180
  checked: selectAll,
181
+ id: "dropdownListItem-all",
152
182
  checkedIcon: /*#__PURE__*/_react.default.createElement(_icons.CheckBox, {
153
183
  style: {
154
184
  fontSize: 18,
@@ -160,7 +190,8 @@ const ManageColumnView = _ref => {
160
190
  color: "secondary",
161
191
  className: "checkBox"
162
192
  }),
163
- label: selectAll ? 'Deselect All' : 'Select All'
193
+ label: selectAll ? 'Deselect All' : 'Select All',
194
+ id: "dropdownListItem-all-label"
164
195
  })))));
165
196
  };
166
197
  const styles = () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdihub.91",
3
+ "version": "1.0.1-ccdihub.92",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
@@ -11,7 +11,7 @@ import DownloadButton from './toolbar/DownloadButtonView';
11
11
  const downloadAreaStyle = {
12
12
  display: 'flex',
13
13
  borderTop: '1px solid #8A7F7C',
14
- paddingRight: '41px',
14
+ paddingRight: '48px',
15
15
  };
16
16
 
17
17
  const ExtendedView = ({
@@ -123,7 +123,7 @@ const DownloadButton = ({
123
123
  width: '48px',
124
124
  height: '36px',
125
125
  paddingLeft: '5px',
126
- border: '0.75px solid #606060',
126
+ border: ` ${listDisplay === 'none' ? '0.75px solid #606060' : '1.5px solid #5666BD'}`,
127
127
  borderRadius: '5px',
128
128
  display: 'inline-block',
129
129
  position: 'relative',
@@ -133,11 +133,11 @@ const DownloadButton = ({
133
133
  display: 'block',
134
134
  position: 'absolute',
135
135
  width: '60px',
136
- marginTop: '3px',
137
- marginLeft: '-5px',
136
+ top: '38px',
137
+ right: '0.5px',
138
138
  overflow: 'auto',
139
139
  zIndex: '5',
140
- border: '1.5px solid #41545E',
140
+ border: '1.5px solid #5666BD',
141
141
  borderRadius: '5px',
142
142
  background: '#ffffff',
143
143
  },
@@ -148,7 +148,7 @@ const DownloadButton = ({
148
148
  fontWeight: 400,
149
149
  lineHeight: '21px',
150
150
  '&:hover': {
151
- background: '#D7D7D7',
151
+ background: '#C9CFF4',
152
152
  cursor: 'pointer',
153
153
  },
154
154
  },
@@ -173,13 +173,13 @@ const DownloadButton = ({
173
173
  {
174
174
  count !== 0
175
175
  ? (
176
- <IconButton onClick={handleClickButton}>
176
+ <IconButton onClick={handleClickButton} style={{ backgroundColor: 'transparent' }}>
177
177
  <CloudDownload />
178
178
  <KeyboardArrowDownOutlinedIcon className={classes.arrowdownIcon} />
179
179
  </IconButton>
180
180
  )
181
181
  : (
182
- <IconButton disabled>
182
+ <IconButton disabled style={{ backgroundColor: 'transparent' }}>
183
183
  <CloudDownload />
184
184
  <KeyboardArrowDownOutlinedIcon className={classes.arrowdownIconDisabled} />
185
185
  </IconButton>
@@ -1,11 +1,10 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import {
3
3
  Checkbox,
4
4
  FormControlLabel,
5
5
  IconButton,
6
6
  List,
7
7
  ListItem,
8
- Popover,
9
8
  Tooltip,
10
9
  Typography,
11
10
  withStyles,
@@ -31,16 +30,42 @@ const ManageColumnView = ({
31
30
  return null;
32
31
  }
33
32
  const { columns } = table;
34
- const [anchorEl, setAnchorEl] = useState(null);
33
+ const [listDisplay, setListDisplay] = useState('none');
35
34
  const [selectAll, setSelectAll] = useState(false);
36
35
 
37
36
  const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY);
38
37
 
39
- const handleClick = (event) => {
40
- setAnchorEl(event.currentTarget);
38
+ const dropdownSelection = useRef(null);
39
+
40
+ const handleClose = () => {
41
+ setListDisplay('none');
41
42
  };
42
43
 
43
- const handleClose = () => setAnchorEl(null);
44
+ const handleClickButton = () => {
45
+ if (listDisplay === 'none') {
46
+ setListDisplay('block');
47
+ } else {
48
+ setListDisplay('none');
49
+ }
50
+ };
51
+
52
+ const useOutsideAlerter = (ref) => {
53
+ useEffect(() => {
54
+ function handleClickOutside(event) {
55
+ console.log(event.target);
56
+ if (!(event.target.getAttribute('id') && event.target.getAttribute('id').includes('dropdownListItem'))
57
+ && !(event.target.getAttribute('class') && event.target.getAttribute('class').includes('MuiFormControlLabel'))
58
+ ) {
59
+ setListDisplay('none');
60
+ }
61
+ }
62
+ document.addEventListener('mousedown', handleClickOutside);
63
+ return () => {
64
+ document.removeEventListener('mousedown', handleClickOutside);
65
+ };
66
+ }, [ref]);
67
+ };
68
+ useOutsideAlerter(dropdownSelection);
44
69
 
45
70
  const handleSelectAll = () => {
46
71
  const state = selectAll;
@@ -52,7 +77,7 @@ const ManageColumnView = ({
52
77
  width: '48px',
53
78
  height: '36px',
54
79
  paddingLeft: '5px',
55
- border: '0.75px solid #606060',
80
+ border: `${listDisplay === 'none' ? '0.75px solid #606060' : '1.5px solid #5666BD'}`,
56
81
  borderRadius: '5px',
57
82
  display: 'inline-flex',
58
83
  position: 'relative',
@@ -61,43 +86,45 @@ const ManageColumnView = ({
61
86
  };
62
87
 
63
88
  const displayColumnStyle = {
64
- position: 'relative',
65
- right: '20px',
66
- bottom: '15px',
67
- scale: '0.5',
89
+ position: 'absolute',
90
+ right: '35px',
91
+ bottom: '23px',
68
92
  };
69
93
 
70
94
  const viewColumnsStyle = {
71
95
  marginTop: '6px',
72
96
  height: '24px',
73
- right: '37px',
97
+ backgroundColor: 'transparent',
98
+ };
99
+
100
+ const dropdownList = {
101
+ position: 'absolute',
102
+ width: '230px',
103
+ marginTop: '38px',
104
+ marginLeft: '-187px',
105
+ overflow: 'auto',
106
+ zIndex: '5',
107
+ border: '1.5px solid #5666BD',
108
+ borderRadius: '5px',
109
+ background: '#ffffff',
110
+ display: listDisplay,
74
111
  };
75
112
 
76
113
  const arrowdownIcon = {
77
114
  fill: '#606060',
78
115
  };
79
-
80
- const open = Boolean(anchorEl);
81
116
  return (
82
117
  <div style={columnDropdown}>
83
118
  <Tooltip title="Columns may be hidden">
84
119
  <img src={hiddenColumnsIcon} alt="hiddenColumnsIcon" style={displayColumnStyle} />
85
120
  </Tooltip>
86
121
  <Tooltip title={manageViewColumns.title}>
87
- <IconButton variant="contained" onClick={handleClick} style={viewColumnsStyle}>
122
+ <IconButton variant="contained" onClick={handleClickButton} style={viewColumnsStyle}>
88
123
  <img src={viewColumnsIcon} alt="viewColumnsIcon" />
89
124
  <KeyboardArrowDownOutlinedIcon style={arrowdownIcon} />
90
125
  </IconButton>
91
126
  </Tooltip>
92
- <Popover
93
- open={open}
94
- anchorEl={anchorEl}
95
- onClose={handleClose}
96
- anchorOrigin={{
97
- vertical: 'bottom',
98
- horizontal: 'left',
99
- }}
100
- >
127
+ <div style={dropdownList}>
101
128
  <Typography variant="caption" className="viewColumnText">
102
129
  {manageViewColumns.title}
103
130
  </Typography>
@@ -109,10 +136,11 @@ const ManageColumnView = ({
109
136
  <Close />
110
137
  </IconButton>
111
138
  <List className="viewColumnList">
112
- {viewColumns.map((column) => (
139
+ {viewColumns.map((column, index) => (
113
140
  <ListItem
114
141
  width={1}
115
142
  className="viewColumnListItem"
143
+ id={`dropdownListItem-${index}`}
116
144
  >
117
145
  <FormControlLabel
118
146
  control={(
@@ -125,6 +153,7 @@ const ManageColumnView = ({
125
153
  )}
126
154
  onClick={() => onColumnViewChange(column)}
127
155
  checked={column.display}
156
+ id={`dropdownListItemCheckbox-${index}`}
128
157
  checkedIcon={(
129
158
  <CheckBoxIcon
130
159
  style={{
@@ -142,6 +171,7 @@ const ManageColumnView = ({
142
171
  )}
143
172
  disabled={!column.hideable}
144
173
  label={column.header}
174
+ id={`dropdownListItem-${index}-label`}
145
175
  />
146
176
  </ListItem>
147
177
  ))}
@@ -161,6 +191,7 @@ const ManageColumnView = ({
161
191
  )}
162
192
  onClick={() => handleSelectAll()}
163
193
  checked={selectAll}
194
+ id="dropdownListItem-all"
164
195
  checkedIcon={(
165
196
  <CheckBoxIcon
166
197
  style={{
@@ -176,10 +207,11 @@ const ManageColumnView = ({
176
207
  />
177
208
  )}
178
209
  label={selectAll ? 'Deselect All' : 'Select All'}
210
+ id="dropdownListItem-all-label"
179
211
  />
180
212
  </ListItem>
181
213
  </List>
182
- </Popover>
214
+ </div>
183
215
  </div>
184
216
  );
185
217
  };