@bento-core/table 1.0.0-c3dc.32 → 1.0.0-c3dc.34

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.
@@ -30,8 +30,13 @@ const defaultTheme = () => ({
30
30
  MuiList: {
31
31
  root: {
32
32
  '&.viewColumnList': {
33
- padding: '8px 20px 8px 20px',
34
- bottom: '5px'
33
+ paddingLeft: '19.5px'
34
+ }
35
+ },
36
+ padding: {
37
+ '&.viewColumnList': {
38
+ paddingTop: '0px',
39
+ paddingBottom: '0px'
35
40
  }
36
41
  }
37
42
  },
@@ -14,6 +14,10 @@ var _Hidden_Column = _interopRequireDefault(require("./assets/Hidden_Column.svg"
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+ // Height threshold to trigger scrolling behavior
18
+ const SCROLL_THRESHOLD_HEIGHT = 400;
19
+ // Maximum height of scrollable content area when scroll is needed
20
+ const SCROLLABLE_MAX_HEIGHT = '253px';
17
21
  const ManageColumnView = _ref => {
18
22
  let {
19
23
  table,
@@ -30,8 +34,10 @@ const ManageColumnView = _ref => {
30
34
  } = table;
31
35
  const [listDisplay, setListDisplay] = (0, _react.useState)('none');
32
36
  const [selectAll, setSelectAll] = (0, _react.useState)(false);
37
+ const [needsScroll, setNeedsScroll] = (0, _react.useState)(false);
33
38
  const viewColumns = columns.filter(col => col.role === _Types.cellTypes.DISPLAY && col.disableInManageView !== true);
34
39
  const dropdownSelection = (0, _react.useRef)(null);
40
+ const formGroupRef = (0, _react.useRef)(null);
35
41
  const handleClose = () => {
36
42
  setListDisplay('none');
37
43
  };
@@ -60,6 +66,12 @@ const ManageColumnView = _ref => {
60
66
  setSelectAll(!selectAll);
61
67
  onAllColumnViewChange(!selectAll);
62
68
  };
69
+ (0, _react.useEffect)(() => {
70
+ if (formGroupRef.current && listDisplay === 'block') {
71
+ const contentHeight = formGroupRef.current.scrollHeight;
72
+ setNeedsScroll(contentHeight > SCROLL_THRESHOLD_HEIGHT);
73
+ }
74
+ }, [viewColumns, listDisplay]);
63
75
  return /*#__PURE__*/_react.default.createElement("div", {
64
76
  ref: dropdownSelection,
65
77
  className: listDisplay === 'none' ? classes.columnDropdown : classes.columnDropdownActive
@@ -82,15 +94,23 @@ const ManageColumnView = _ref => {
82
94
  className: classes.arrowDownIcon
83
95
  }))), /*#__PURE__*/_react.default.createElement("div", {
84
96
  className: listDisplay === 'none' ? classes.dropdownListHidden : classes.dropdownListVisible
97
+ }, /*#__PURE__*/_react.default.createElement("div", {
98
+ className: classes.dropdownHeader
85
99
  }, /*#__PURE__*/_react.default.createElement(_core.Typography, {
86
100
  variant: "caption",
87
101
  className: classes.titleText
88
102
  }, manageViewColumns.title), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
89
103
  onClick: handleClose,
90
104
  className: classes.closeIconButton
91
- }, /*#__PURE__*/_react.default.createElement(_icons.Close, null)), /*#__PURE__*/_react.default.createElement(_core.List, {
105
+ }, /*#__PURE__*/_react.default.createElement(_icons.Close, null))), /*#__PURE__*/_react.default.createElement(_core.List, {
92
106
  className: "viewColumnList",
93
107
  id: "dropdownListItemTitle"
108
+ }, /*#__PURE__*/_react.default.createElement("div", {
109
+ ref: formGroupRef,
110
+ className: classes.formGroup,
111
+ style: needsScroll ? {
112
+ maxHeight: SCROLLABLE_MAX_HEIGHT
113
+ } : {}
94
114
  }, viewColumns.map((column, index) => /*#__PURE__*/_react.default.createElement(_core.ListItem, {
95
115
  width: 1,
96
116
  className: "viewColumnListItem",
@@ -127,19 +147,12 @@ const ManageColumnView = _ref => {
127
147
  className: classes.textStyle
128
148
  }, column.header),
129
149
  id: "dropdownListItem-".concat(index, "-label"),
130
- className: "formControlLabel",
131
- style: {
132
- marginLeft: '13px',
133
- alignItems: 'flex-start'
134
- }
135
- }))), /*#__PURE__*/_react.default.createElement(_core.Divider, {
150
+ className: classes.checkboxItemLabel
151
+ })))), /*#__PURE__*/_react.default.createElement(_core.Divider, {
136
152
  className: classes.dividerStyle
137
153
  }), /*#__PURE__*/_react.default.createElement(_core.ListItem, {
138
154
  width: 1,
139
- className: "viewColumnListItem",
140
- style: {
141
- height: '20px'
142
- }
155
+ className: "viewColumnListItem"
143
156
  }, /*#__PURE__*/_react.default.createElement(_core.FormControlLabel, {
144
157
  control: /*#__PURE__*/_react.default.createElement(_core.Checkbox, {
145
158
  icon: /*#__PURE__*/_react.default.createElement(_icons.CheckBoxOutlineBlank, {
@@ -170,10 +183,9 @@ const ManageColumnView = _ref => {
170
183
  className: classes.textStyle
171
184
  }, selectAll ? 'Deselect All' : 'Select All'),
172
185
  id: "dropdownListItem-all-label",
186
+ className: classes.checkboxItemLabel,
173
187
  style: {
174
- marginLeft: '13px',
175
- alignItems: 'flex-start',
176
- paddingTop: 7
188
+ padding: '2px 0px'
177
189
  }
178
190
  })))));
179
191
  };
@@ -239,44 +251,34 @@ const styles = () => ({
239
251
  borderRadius: '5px',
240
252
  background: '#ffffff',
241
253
  display: 'block',
242
- maxHeight: '300px',
243
- overflowY: 'auto',
244
- overflowX: 'hidden',
245
- '&::-webkit-scrollbar': {
246
- width: '6px' // Width of the scrollbar
247
- },
248
-
249
- '&::-webkit-scrollbar-track': {
250
- background: '#CECECE',
251
- // Track color
252
- borderRadius: '5px'
253
- },
254
- '&::-webkit-scrollbar-thumb': {
255
- backgroundColor: '#8B98AF',
256
- // Thumb color
257
- borderRadius: '5px'
258
- }
254
+ maxHeight: '473px'
255
+ },
256
+ dropdownHeader: {
257
+ display: 'flex',
258
+ alignItems: 'center',
259
+ justifyContent: 'space-between',
260
+ padding: '16px 15px 0px 21px'
259
261
  },
260
262
  titleText: {
261
263
  fontFamily: 'Poppins',
262
264
  fontWeight: '400',
263
265
  fontSize: '14px',
264
- display: 'flex',
265
- position: 'relative',
266
- top: '15px',
267
- left: '34px',
266
+ lineHeight: '100%',
268
267
  color: '#000000'
269
268
  },
270
269
  closeIconButton: {
271
- float: 'right',
272
- bottom: '20px',
273
- scale: '0.75'
270
+ scale: '0.75',
271
+ bottom: '14.5px',
272
+ left: '12.5px'
273
+ },
274
+ checkboxItemLabel: {
275
+ marginLeft: '0px !important'
274
276
  },
275
277
  textStyle: {
276
278
  fontFamily: 'Poppins',
277
279
  fontSize: '14px',
278
280
  fontWeight: '400',
279
- margin: '2px 0px',
281
+ marginBottom: '3px',
280
282
  lineHeight: '15px'
281
283
  },
282
284
  dividerStyle: {
@@ -296,7 +298,20 @@ const styles = () => ({
296
298
  fontWeight: 500
297
299
  },
298
300
  formGroup: {
299
- marginTop: '8px'
301
+ marginTop: '8px',
302
+ overflowY: 'auto',
303
+ overflowX: 'hidden',
304
+ '&::-webkit-scrollbar': {
305
+ width: '6px'
306
+ },
307
+ '&::-webkit-scrollbar-track': {
308
+ background: 'transparent',
309
+ borderRadius: '5px'
310
+ },
311
+ '&::-webkit-scrollbar-thumb': {
312
+ backgroundColor: '#707070',
313
+ borderRadius: '5px'
314
+ }
300
315
  },
301
316
  formControl: {},
302
317
  checkbox: {
@@ -76,18 +76,27 @@ function downloadData(tableData, table, downloadFileName) {
76
76
  } = table;
77
77
  const filterColumns = columns.filter(_ref => {
78
78
  let {
79
- cellType,
80
- doNotDownload
79
+ cellType
81
80
  } = _ref;
82
- return !_Types.actionCellTypes.includes(cellType) && !doNotDownload;
81
+ return !_Types.actionCellTypes.includes(cellType);
82
+ }).filter(_ref2 => {
83
+ let {
84
+ doNotDownload
85
+ } = _ref2;
86
+ return !doNotDownload;
87
+ }).filter(_ref3 => {
88
+ let {
89
+ display
90
+ } = _ref3;
91
+ return display;
83
92
  });
84
93
  let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
85
94
  formatDataVal = formatDataVal.map(item => {
86
95
  const updatedItem = {};
87
- filterColumns.forEach(_ref2 => {
96
+ filterColumns.forEach(_ref4 => {
88
97
  let {
89
98
  dataField
90
- } = _ref2;
99
+ } = _ref4;
91
100
  updatedItem[dataField] = item[dataField];
92
101
  });
93
102
  return updatedItem;
@@ -112,27 +121,27 @@ function downloadData(tableData, table, downloadFileName) {
112
121
  fileType = 'application/json';
113
122
  } else {
114
123
  const jsonse = JSON.stringify(formatDataVal);
115
- const keysToInclude = filterColumns.filter(_ref3 => {
124
+ const keysToInclude = filterColumns.filter(_ref5 => {
116
125
  let {
117
126
  dataField
118
- } = _ref3;
127
+ } = _ref5;
119
128
  return dataField;
120
- }).map(_ref4 => {
129
+ }).map(_ref6 => {
121
130
  let {
122
131
  dataField
123
- } = _ref4;
132
+ } = _ref6;
124
133
  return dataField;
125
134
  });
126
- const headers = filterColumns.filter(_ref5 => {
135
+ const headers = filterColumns.filter(_ref7 => {
127
136
  let {
128
137
  dataField
129
- } = _ref5;
138
+ } = _ref7;
130
139
  return dataField;
131
- }).map(_ref6 => {
140
+ }).map(_ref8 => {
132
141
  let {
133
142
  header,
134
143
  downloadHeader
135
- } = _ref6;
144
+ } = _ref8;
136
145
  return downloadHeader || header;
137
146
  });
138
147
  fileContent = convertToCSV(jsonse, keysToInclude, headers);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.0-c3dc.32",
3
+ "version": "1.0.0-c3dc.34",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
@@ -24,8 +24,13 @@ const defaultTheme = () => ({
24
24
  MuiList: {
25
25
  root: {
26
26
  '&.viewColumnList': {
27
- padding: '8px 20px 8px 20px',
28
- bottom: '5px',
27
+ paddingLeft: '19.5px',
28
+ },
29
+ },
30
+ padding: {
31
+ '&.viewColumnList': {
32
+ paddingTop: '0px',
33
+ paddingBottom: '0px',
29
34
  },
30
35
  },
31
36
  },
@@ -20,6 +20,11 @@ import { cellTypes } from '../util/Types';
20
20
  import viewColumnsIcon from './assets/View_Columns.svg';
21
21
  import hiddenColumnsIcon from './assets/Hidden_Column.svg';
22
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';
27
+
23
28
  const ManageColumnView = ({
24
29
  table,
25
30
  onColumnViewChange,
@@ -33,11 +38,13 @@ const ManageColumnView = ({
33
38
  const { columns } = table;
34
39
  const [listDisplay, setListDisplay] = useState('none');
35
40
  const [selectAll, setSelectAll] = useState(false);
41
+ const [needsScroll, setNeedsScroll] = useState(false);
36
42
 
37
43
  const viewColumns = columns.filter((col) => col.role === cellTypes.DISPLAY
38
44
  && col.disableInManageView !== true);
39
45
 
40
46
  const dropdownSelection = useRef(null);
47
+ const formGroupRef = useRef(null);
41
48
 
42
49
  const handleClose = () => {
43
50
  setListDisplay('none');
@@ -71,6 +78,13 @@ const ManageColumnView = ({
71
78
  onAllColumnViewChange(!selectAll);
72
79
  };
73
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]);
87
+
74
88
  return (
75
89
  <div ref={dropdownSelection} className={listDisplay === 'none' ? classes.columnDropdown : classes.columnDropdownActive}>
76
90
  <Tooltip title="Columns may be hidden">
@@ -83,63 +97,70 @@ const ManageColumnView = ({
83
97
  </IconButton>
84
98
  </Tooltip>
85
99
  <div className={listDisplay === 'none' ? classes.dropdownListHidden : classes.dropdownListVisible}>
86
- <Typography variant="caption" className={classes.titleText}>
87
- {manageViewColumns.title}
88
- </Typography>
89
- <IconButton
90
- onClick={handleClose}
91
- className={classes.closeIconButton}
92
- >
93
- <Close />
94
- </IconButton>
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
+
95
112
  <List className="viewColumnList" id="dropdownListItemTitle">
96
- {viewColumns.map((column, index) => (
97
- <ListItem
98
- width={1}
99
- className="viewColumnListItem"
100
- id={`dropdownListItem-${index}`}
101
- >
102
- <FormControlLabel
103
- control={(
104
- <Checkbox
105
- icon={(
106
- <CheckBoxBlankIcon
107
- style={{ fontSize: 18 }}
108
- className="checkBoxIcon"
109
- />
110
- )}
111
- onClick={() => onColumnViewChange(column)}
112
- checked={column.display}
113
- id={`dropdownListItemCheckbox-${index}`}
114
- checkedIcon={(
115
- <CheckBoxIcon
116
- style={{
117
- fontSize: 18,
118
- color: column.hideable ? 'rgba(109, 95, 91, 1)' : 'rgba(109, 95, 91, 0.38)',
119
- }}
120
- className="checkBoxIcon"
121
- />
122
- )}
123
- disableRipple
124
- color="secondary"
125
- className="checkBox"
126
- disabled={!column.hideable}
127
- style={{ paddingTop: 0 }}
128
- />
129
- )}
130
- disabled={!column.hideable}
131
- label={<Typography id={`dropdownListItemLabel-${index}`} className={classes.textStyle}>{column.header}</Typography>}
132
- id={`dropdownListItem-${index}-label`}
133
- className="formControlLabel"
134
- style={{ marginLeft: '13px', alignItems: 'flex-start' }}
135
- />
136
- </ListItem>
137
- ))}
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>
138
160
  <Divider className={classes.dividerStyle} />
139
161
  <ListItem
140
162
  width={1}
141
163
  className="viewColumnListItem"
142
- style={{ height: '20px' }}
143
164
  >
144
165
  <FormControlLabel
145
166
  control={(
@@ -174,7 +195,8 @@ const ManageColumnView = ({
174
195
  </Typography>
175
196
  )}
176
197
  id="dropdownListItem-all-label"
177
- style={{ marginLeft: '13px', alignItems: 'flex-start', paddingTop: 7 }}
198
+ className={classes.checkboxItemLabel}
199
+ style={{ padding: '2px 0px' }}
178
200
  />
179
201
  </ListItem>
180
202
  </List>
@@ -245,41 +267,34 @@ const styles = () => ({
245
267
  borderRadius: '5px',
246
268
  background: '#ffffff',
247
269
  display: 'block',
248
- maxHeight: '300px',
249
- overflowY: 'auto',
250
- overflowX: 'hidden',
251
- '&::-webkit-scrollbar': {
252
- width: '6px', // Width of the scrollbar
253
- },
254
- '&::-webkit-scrollbar-track': {
255
- background: '#CECECE', // Track color
256
- borderRadius: '5px',
257
- },
258
- '&::-webkit-scrollbar-thumb': {
259
- backgroundColor: '#8B98AF', // Thumb color
260
- borderRadius: '5px',
261
- },
270
+ maxHeight: '473px',
271
+ },
272
+ dropdownHeader: {
273
+ display: 'flex',
274
+ alignItems: 'center',
275
+ justifyContent: 'space-between',
276
+ padding: '16px 15px 0px 21px',
262
277
  },
263
278
  titleText: {
264
279
  fontFamily: 'Poppins',
265
280
  fontWeight: '400',
266
281
  fontSize: '14px',
267
- display: 'flex',
268
- position: 'relative',
269
- top: '15px',
270
- left: '34px',
282
+ lineHeight: '100%',
271
283
  color: '#000000',
272
284
  },
273
285
  closeIconButton: {
274
- float: 'right',
275
- bottom: '20px',
276
286
  scale: '0.75',
287
+ bottom: '14.5px',
288
+ left: '12.5px',
289
+ },
290
+ checkboxItemLabel: {
291
+ marginLeft: '0px !important',
277
292
  },
278
293
  textStyle: {
279
294
  fontFamily: 'Poppins',
280
295
  fontSize: '14px',
281
296
  fontWeight: '400',
282
- margin: '2px 0px',
297
+ marginBottom: '3px',
283
298
  lineHeight: '15px',
284
299
  },
285
300
  dividerStyle: {
@@ -300,6 +315,19 @@ const styles = () => ({
300
315
  },
301
316
  formGroup: {
302
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
+ },
303
331
  },
304
332
  formControl: {},
305
333
  checkbox: {
@@ -63,8 +63,10 @@ export function convertToCSV(jsonse, keysToInclude, header) {
63
63
 
64
64
  export function downloadData(tableData, table, downloadFileName, format = 'csv') {
65
65
  const { columns = [] } = table;
66
- const filterColumns = columns.filter(({ cellType, doNotDownload }) => (
67
- !actionCellTypes.includes(cellType) && !doNotDownload));
66
+ const filterColumns = columns
67
+ .filter(({ cellType }) => !actionCellTypes.includes(cellType))
68
+ .filter(({ doNotDownload }) => !doNotDownload)
69
+ .filter(({ display }) => display);
68
70
  let formatDataVal = formatColumnValues(filterColumns, tableData);
69
71
 
70
72
  formatDataVal = formatDataVal.map((item) => {