@telus-uds/components-community.data-grid 1.2.2 → 1.3.0

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/CHANGELOG.md CHANGED
@@ -1,12 +1,37 @@
1
1
  # Change Log - @telus-uds/components-community.data-grid
2
2
 
3
- This log was last generated on Mon, 24 Mar 2025 16:24:15 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 08 Apr 2025 19:33:56 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.3.0
8
+
9
+ Tue, 08 Apr 2025 19:33:56 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - `DataGrid`: Enhancement to allow more diverse content (sam.obisesan@telus.com)
14
+ - Bump @telus-uds/components-web to v4.4.2
15
+ - Bump @telus-uds/components-base to v3.5.2
16
+ - Bump @telus-uds/browserslist-config to v1.0.5
17
+
18
+ ### Patches
19
+
20
+ - `Datagrid`: expanded row double border fix (vishal.jindal@telus.com)
21
+
22
+ ## 1.2.3
23
+
24
+ Fri, 28 Mar 2025 01:02:45 GMT
25
+
26
+ ### Patches
27
+
28
+ - Bump @telus-uds/components-web to v4.4.1
29
+ - Bump @telus-uds/components-base to v3.5.1
30
+ - Bump @telus-uds/browserslist-config to v1.0.5
31
+
7
32
  ## 1.2.2
8
33
 
9
- Mon, 24 Mar 2025 16:24:15 GMT
34
+ Mon, 24 Mar 2025 16:30:05 GMT
10
35
 
11
36
  ### Patches
12
37
 
@@ -54,29 +54,29 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
54
54
  const [disableHeaderCheckbox, setDisableHeaderCheckbox] = _react.default.useState(false);
55
55
  const [hideHeaderCheckBoxByRows, setHideHeaderCheckBoxByRows] = _react.default.useState(false);
56
56
  (0, _react.useEffect)(() => {
57
- let _isAtLeastOneRowUnselected = null;
58
- let _isAtLeastOneRowEnabled = null;
59
- let _hideHeaderCheckBoxByRows = null;
57
+ let isAtLeastOneRowUnselectedCheck = null;
58
+ let isAtLeastOneRowEnabledCheck = null;
59
+ let hideHeaderCheckBoxByRowsCheck = null;
60
60
  if (groupedRows) {
61
- _isAtLeastOneRowUnselected = Object.keys(data).some(el => {
61
+ isAtLeastOneRowUnselectedCheck = Object.keys(data).some(el => {
62
62
  return (0, _utility.isAtLeastOneRowUnselected)(data[el].data);
63
63
  });
64
- _isAtLeastOneRowEnabled = Object.keys(data).some(el => {
64
+ isAtLeastOneRowEnabledCheck = Object.keys(data).some(el => {
65
65
  return (0, _utility.isAtLeastOneRowEnabled)(data[el].data);
66
66
  });
67
- _hideHeaderCheckBoxByRows = Object.keys(data).some(el => {
67
+ hideHeaderCheckBoxByRowsCheck = Object.keys(data).some(el => {
68
68
  return (0, _utility.hasEveryRowHiddenItsCheckbox)(data[el].data);
69
69
  });
70
70
  } else {
71
- _isAtLeastOneRowUnselected = (0, _utility.isAtLeastOneRowUnselected)(data);
72
- _isAtLeastOneRowEnabled = (0, _utility.isAtLeastOneRowEnabled)(data);
73
- _hideHeaderCheckBoxByRows = (0, _utility.hasEveryRowHiddenItsCheckbox)(data);
71
+ isAtLeastOneRowUnselectedCheck = (0, _utility.isAtLeastOneRowUnselected)(data);
72
+ isAtLeastOneRowEnabledCheck = (0, _utility.isAtLeastOneRowEnabled)(data);
73
+ hideHeaderCheckBoxByRowsCheck = (0, _utility.hasEveryRowHiddenItsCheckbox)(data);
74
74
  }
75
- setCheckAllState(_isAtLeastOneRowEnabled === false ? false : !_isAtLeastOneRowUnselected);
76
- setDisableHeaderCheckbox(!_isAtLeastOneRowEnabled);
77
- setHideHeaderCheckBoxByRows(_hideHeaderCheckBoxByRows);
75
+ setCheckAllState(isAtLeastOneRowEnabledCheck === false ? false : !isAtLeastOneRowUnselectedCheck);
76
+ setDisableHeaderCheckbox(!isAtLeastOneRowEnabledCheck);
77
+ setHideHeaderCheckBoxByRows(hideHeaderCheckBoxByRowsCheck);
78
78
  }, [data, groupedRows]);
79
- const shouldDisplayIconColumn = (allData, _showCheckbox) => {
79
+ const shouldDisplayIconColumn = (allData, shouldShowCheckbox) => {
80
80
  let doesOneRowHaveExpandedContent = null;
81
81
  if (groupedRows) {
82
82
  doesOneRowHaveExpandedContent = Object.keys(allData).some(el => {
@@ -85,54 +85,53 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
85
85
  } else {
86
86
  doesOneRowHaveExpandedContent = allData.some(el => el.hasExpandedRow === true);
87
87
  }
88
- return !!(_showCheckbox || doesOneRowHaveExpandedContent);
88
+ return !!(shouldShowCheckbox || doesOneRowHaveExpandedContent);
89
89
  };
90
90
  const toggleSelectAll = () => {
91
- let _rows = null;
91
+ let tempRows = {};
92
92
  if (groupedRows) {
93
- _rows = {};
94
93
  Object.keys(data).forEach(el => {
95
- _rows[el] = {
94
+ tempRows[el] = {
96
95
  ...data[el]
97
96
  };
98
- _rows[el].data = (0, _utility.toggleAllCheckBoxes)(data[el].data, checkAllState);
97
+ tempRows[el].data = (0, _utility.toggleAllCheckBoxes)(data[el].data, checkAllState);
99
98
  });
100
99
  } else {
101
- _rows = (0, _utility.toggleAllCheckBoxes)(data, checkAllState);
100
+ tempRows = (0, _utility.toggleAllCheckBoxes)(data, checkAllState);
102
101
  }
103
- setData(_rows);
102
+ setData(tempRows);
104
103
  setCheckAllState(!checkAllState);
105
104
  };
106
105
  const toggleCheckbox = (rowId, row) => {
107
- let _data = null;
106
+ let tempData = null;
108
107
  if (typeof row.checkBoxProps?.onChange === 'function') {
109
108
  row.checkBoxProps.onChange();
110
109
  }
111
110
  if (groupedRows) {
112
- const [group, _] = rowId.split('-');
113
- const id = parseInt(_, 10);
114
- _data = {
111
+ const [group, splitID] = rowId.split('-');
112
+ const id = parseInt(splitID, 10);
113
+ tempData = {
115
114
  ...data
116
115
  };
117
- _data[group].data = (0, _utility.toggleRowCheckbox)(_data[group].data, id);
116
+ tempData[group].data = (0, _utility.toggleRowCheckbox)(tempData[group].data, id);
118
117
  } else {
119
- _data = (0, _utility.toggleRowCheckbox)(data, rowId);
118
+ tempData = (0, _utility.toggleRowCheckbox)(data, rowId);
120
119
  }
121
- setData(_data);
120
+ setData(tempData);
122
121
  };
123
122
  const toggleRowExpansion = rowId => {
124
- let _row = null;
123
+ let tempRow = null;
125
124
  if (groupedRows) {
126
- const [group, _] = rowId.split('-');
127
- const id = parseInt(_, 10);
128
- _row = {
125
+ const [group, splitId] = rowId.split('-');
126
+ const id = parseInt(splitId, 10);
127
+ tempRow = {
129
128
  ...data
130
129
  };
131
- _row[group].data = (0, _utility.toggleExpandedRow)(_row[group].data, id);
130
+ tempRow[group].data = (0, _utility.toggleExpandedRow)(tempRow[group].data, id);
132
131
  } else {
133
- _row = (0, _utility.toggleExpandedRow)(data, rowId);
132
+ tempRow = (0, _utility.toggleExpandedRow)(data, rowId);
134
133
  }
135
- setData(_row);
134
+ setData(tempRow);
136
135
  };
137
136
  const HeaderCheckBoxDisplay = showCheckbox && !hideHeaderCheckBoxByRows && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Checkbox, {
138
137
  label: getCopy('all'),
@@ -140,8 +139,8 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
140
139
  inactive: disableHeaderCheckbox,
141
140
  onChange: toggleSelectAll
142
141
  });
143
- const buildCheckBoxDisplay = (_showCheckbox, row, rowId) => {
144
- return _showCheckbox && !row.hideCheckbox && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Checkbox, {
142
+ const buildCheckBoxDisplay = (shouldShowCheckbox, row, rowId) => {
143
+ return shouldShowCheckbox && !row.hideCheckbox && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Checkbox, {
145
144
  ...row.checkBoxProps,
146
145
  onChange: () => toggleCheckbox(rowId, row)
147
146
  });
@@ -166,25 +165,24 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
166
165
  children: row.expandedRowChildComponent.component
167
166
  })
168
167
  });
169
- const buildRowContent = (row, rowId, _showCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
168
+ const buildRowContent = (row, rowId, shouldShowCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
170
169
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_DataGridRow.default, {
171
170
  tokens: themeTokens,
172
171
  rowId: rowId,
173
172
  isExpandedRowOpen: row.isExpandedRowOpen,
174
173
  hasExpandedContent: row.hasExpandedRow,
175
174
  onClick: toggleRowExpansion,
176
- children: [shouldDisplayIconColumn(data, _showCheckbox) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
175
+ children: [shouldDisplayIconColumn(data, shouldShowCheckbox) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
177
176
  tokens: themeTokens,
178
177
  isExpandedRowOpen: row.isExpandedRowOpen,
178
+ hidePreviousRowBorder: row.hidePreviousRowBorder,
179
179
  isHeaderVisible: isHeaderVisible,
180
180
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledIconContainer, {
181
181
  children: [CheckBoxDisplay, DisplayCaret]
182
182
  })
183
- }), columnsData.map(column => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
184
- tokens: themeTokens,
185
- isExpandedRowOpen: row.isExpandedRowOpen,
186
- isHeaderVisible: isHeaderVisible,
187
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
183
+ }), columnsData.map(column => {
184
+ const currentColumn = columns.find(el => el.key === column.key);
185
+ const columnContent = typeof currentColumn?.displayedComponent === 'function' ? currentColumn.displayedComponent(row[column.key]) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
188
186
  block: true,
189
187
  variant: {
190
188
  size: 'small'
@@ -193,31 +191,38 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
193
191
  color: themeTokens.cellTextColor
194
192
  },
195
193
  children: row[column.key]
196
- })
197
- }, `${rowId}-${column.key}`))]
194
+ });
195
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
196
+ tokens: themeTokens,
197
+ isExpandedRowOpen: row.isExpandedRowOpen,
198
+ hidePreviousRowBorder: row.hidePreviousRowBorder,
199
+ isHeaderVisible: isHeaderVisible,
200
+ children: columnContent
201
+ }, `${rowId}-${column.key}`);
202
+ })]
198
203
  }, rowId), ExpandedRow]
199
204
  }, rowId);
200
205
  const sortColumn = column => {
201
- const _col = {
206
+ const currentColumn = {
202
207
  ...column
203
208
  };
204
209
  if (!groupedRows) {
205
- const _data = [...data].sort((a, b) => {
206
- const first = _col.dataType === _utility.DATA_TYPE.NUMBER ? parseFloat(a[_col.key]) : a[_col.key].toUpperCase();
207
- const next = _col.dataType === _utility.DATA_TYPE.NUMBER ? parseFloat(b[_col.key]) : b[_col.key].toUpperCase();
208
- if (_col.sortDirection === _utility.SORT_DIRECTION.DESC) {
210
+ const currentData = [...data].sort((a, b) => {
211
+ const first = currentColumn.dataType === _utility.DATA_TYPE.NUMBER ? parseFloat(a[currentColumn.key]) : a[currentColumn.key].toUpperCase();
212
+ const next = currentColumn.dataType === _utility.DATA_TYPE.NUMBER ? parseFloat(b[currentColumn.key]) : b[currentColumn.key].toUpperCase();
213
+ if (currentColumn.sortDirection === _utility.SORT_DIRECTION.DESC) {
209
214
  if (first < next) return -1;
210
215
  return next === first ? 0 : 1;
211
216
  }
212
217
  if (next < first) return -1;
213
218
  return first === next ? 0 : 1;
214
219
  });
215
- _col.sortDirection = _col.sortDirection === _utility.SORT_DIRECTION.DESC ? _utility.SORT_DIRECTION.ASC : _utility.SORT_DIRECTION.DESC;
216
- _col.currentSort = true;
217
- const _columns = (0, _utility.resetColumnsData)(columnsData);
218
- _columns[columnsData.findIndex(_el => _el.key === column.key)] = _col;
219
- setColumnsData(_columns);
220
- setData(_data);
220
+ currentColumn.sortDirection = currentColumn.sortDirection === _utility.SORT_DIRECTION.DESC ? _utility.SORT_DIRECTION.ASC : _utility.SORT_DIRECTION.DESC;
221
+ currentColumn.currentSort = true;
222
+ const tempColumns = (0, _utility.resetColumnsData)(columnsData);
223
+ tempColumns[columnsData.findIndex(el => el.key === column.key)] = currentColumn;
224
+ setColumnsData(tempColumns);
225
+ setData(currentData);
221
226
  }
222
227
  };
223
228
  let HeaderContent = null;
@@ -241,7 +246,8 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
241
246
  children: data[group].groupHeaderComponent || DefaultSubHeading
242
247
  })
243
248
  }, group);
244
- const DataRow = data[group].data.map(row => {
249
+ const modifiedData = (0, _utility.hideRowBottomBorder)([...data[group].data]);
250
+ const DataRow = modifiedData.map(row => {
245
251
  const rowId = `${group}-${row.id}`;
246
252
  const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId);
247
253
  const DisplayCaret = buildDisplayCaret(row, rowId);
@@ -253,7 +259,8 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
253
259
  }, group);
254
260
  });
255
261
  } else {
256
- BodyContent = data.map(row => {
262
+ const modifiedData = (0, _utility.hideRowBottomBorder)([...data]);
263
+ BodyContent = modifiedData.map(row => {
257
264
  const rowId = row.id;
258
265
  const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId);
259
266
  const DisplayCaret = buildDisplayCaret(row, rowId);
@@ -261,18 +268,22 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
261
268
  return buildRowContent(row, rowId, showCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow);
262
269
  });
263
270
  }
271
+ const isFirstRowExpanded = data[0]?.isExpandedRowOpen;
264
272
  HeaderContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
265
273
  children: [shouldDisplayIconColumn(data, showCheckbox) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
266
274
  type: _utility.CELL_TYPE.HEADING,
267
275
  tokens: themeTokens,
268
276
  isFirstCol: true,
269
277
  isHeaderVisible: isHeaderVisible,
278
+ hidePreviousRowBorder: isFirstRowExpanded,
270
279
  children: HeaderCheckBoxDisplay
271
280
  }), columnsData.map(column => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_DataGridCell.default, {
272
281
  type: _utility.CELL_TYPE.HEADING,
273
282
  tokens: themeTokens,
274
283
  isSortable: isSortable,
275
284
  isHeaderVisible: isHeaderVisible,
285
+ hidePreviousRowBorder: isFirstRowExpanded,
286
+ textAlign: column.textAlign || 'start',
276
287
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
277
288
  block: true,
278
289
  variant: {
@@ -329,7 +340,9 @@ DataGrid.propTypes = {
329
340
  dataType: _propTypes.default.oneOf(['string', 'number']),
330
341
  isSortable: _propTypes.default.bool,
331
342
  // Set this to true to enable sorting for this column
332
- fn: _propTypes.default.func
343
+ fn: _propTypes.default.func,
344
+ textAlign: _propTypes.default.oneOf(['start', 'center', 'end']),
345
+ displayedComponent: _propTypes.default.func
333
346
  })).isRequired,
334
347
  /**
335
348
  * Use `groupedRows` to pass the grouped data for display
@@ -16,12 +16,17 @@ const StyledHeaderCell = /*#__PURE__*/_styledComponents.default.th.withConfig({
16
16
  displayName: "DataGridCell__StyledHeaderCell",
17
17
  componentId: "[object Object]__sc-6nkvhz-0"
18
18
  })(["", ""], props => {
19
- return (0, _styledComponents.css)(["background-color:", ";border-top:solid ", "px ", ";border-bottom:solid ", "px ", ";padding:", "px;text-align:", ";box-sizing:border-box;font-size:", "px;font-weight:bold;line-height:", "px;color:", ";width:", ";font-family:", ";"], props.headerRowBackgroundColor, props.headerBorderTopWidth, props.headerBorderTopColor, props.headerBorderBottomWidth, props.headerBorderBottomColor, props.headerPadding, props.headerTextAlign, props.headerFontSize, props.headerLineHeight * props.headerFontSize, props.headerTextColor, props.firstColWidth, props.headerFontFamily);
19
+ return (0, _styledComponents.css)(["background-color:", ";border-top:solid ", "px ", ";border-bottom:", ";padding:", "px;padding-left:", "px;padding-right:", "px;text-align:", ";box-sizing:border-box;font-size:", "px;font-weight:bold;line-height:", "px;color:", ";width:", ";font-family:", ";"], props.headerRowBackgroundColor, props.headerBorderTopWidth, props.headerBorderTopColor, props.hidePreviousRowBorder ? `none` : `solid ${props.headerBorderBottomWidth}px ${props.headerBorderBottomColor}`, props.headerPadding, props.headerCellHorizontalPadding, props.headerCellHorizontalPadding, props.headerTextAlign, props.headerFontSize, props.headerLineHeight * props.headerFontSize, props.headerTextColor, props.firstColWidth, props.headerFontFamily);
20
20
  });
21
21
  const StyledHeaderCellDiv = /*#__PURE__*/_styledComponents.default.div.withConfig({
22
22
  displayName: "DataGridCell__StyledHeaderCellDiv",
23
23
  componentId: "[object Object]__sc-6nkvhz-1"
24
- })(["display:flex;align-items:center;"]);
24
+ })(["display:flex;align-items:center;justify-content:", ";"], _ref => {
25
+ let {
26
+ textAlign
27
+ } = _ref;
28
+ return textAlign;
29
+ });
25
30
  const StyledHeaderCellHiddenHeader = /*#__PURE__*/_styledComponents.default.th.withConfig({
26
31
  displayName: "DataGridCell__StyledHeaderCellHiddenHeader",
27
32
  componentId: "[object Object]__sc-6nkvhz-2"
@@ -37,7 +42,7 @@ const StyledGroupHeaderCell = /*#__PURE__*/_styledComponents.default.td.withConf
37
42
  const StyledGroupHeaderCellDiv = /*#__PURE__*/_styledComponents.default.div.withConfig({
38
43
  displayName: "DataGridCell__StyledGroupHeaderCellDiv",
39
44
  componentId: "[object Object]__sc-6nkvhz-4"
40
- })(["display:flex;align-items:center;justify-content:start;"]);
45
+ })(["display:flex;align-items:center;"]);
41
46
  const StyledExpandedCell = /*#__PURE__*/_styledComponents.default.td.withConfig({
42
47
  displayName: "DataGridCell__StyledExpandedCell",
43
48
  componentId: "[object Object]__sc-6nkvhz-5"
@@ -57,9 +62,9 @@ const StyledCell = exports.StyledCell = /*#__PURE__*/_styledComponents.default.t
57
62
  if (props.isExpandedRowOpen) {
58
63
  return (0, _styledComponents.css)(["padding:", "px;text-align:", ";font-size:", "px;font-weight:normal;line-height:", "px;color:", ";font-family:", ";border-top:solid ", "px ", ";"], props.cellPadding, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily, props.headerBorderTopWidth, props.headerBorderTopColor);
59
64
  }
60
- return (0, _styledComponents.css)(["padding:", "px;border-bottom:", ";text-align:", ";font-size:", "px;font-weight:normal;line-height:", "px;color:", ";font-family:", ";"], props.cellPadding, props.hideRowBottomBorder === 1 ? `none` : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor}`, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily);
65
+ return (0, _styledComponents.css)(["padding:", "px;border-bottom:", ";text-align:", ";font-size:", "px;font-weight:normal;line-height:", "px;color:", ";font-family:", ";"], props.cellPadding, props.hideRowBottomBorder === 1 || props.hidePreviousRowBorder ? `none` : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor}`, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily);
61
66
  });
62
- const DataGridCell = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
67
+ const DataGridCell = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
63
68
  let {
64
69
  children,
65
70
  tokens,
@@ -68,14 +73,18 @@ const DataGridCell = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
68
73
  showCheckbox = false,
69
74
  isFirstCol = false,
70
75
  isExpandedRowOpen = false,
71
- isHeaderVisible = true
72
- } = _ref;
76
+ isHeaderVisible = true,
77
+ hidePreviousRowBorder = false,
78
+ textAlign = 'start'
79
+ } = _ref2;
73
80
  if (type === _utility.CELL_TYPE.HEADING) {
74
81
  return isHeaderVisible ? /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledHeaderCell, {
75
82
  ...tokens,
83
+ hidePreviousRowBorder: hidePreviousRowBorder,
76
84
  firstColWidth: isFirstCol ? tokens.firstColWidth : 'auto',
77
85
  ref: ref,
78
86
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledHeaderCellDiv, {
87
+ textAlign: textAlign,
79
88
  children: children
80
89
  })
81
90
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledHeaderCellHiddenHeader, {
@@ -111,6 +120,7 @@ const DataGridCell = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
111
120
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledCell, {
112
121
  ...tokens,
113
122
  isExpandedRowOpen: isExpandedRowOpen,
123
+ hidePreviousRowBorder: hidePreviousRowBorder,
114
124
  ref: ref,
115
125
  children: children
116
126
  });
@@ -148,6 +158,14 @@ DataGridCell.propTypes = {
148
158
  /**
149
159
  * Passed to the component to determine if header is displayed. Set to false to hide header of datagrid. Set to true by default
150
160
  */
151
- isHeaderVisible: _propTypes.default.bool
161
+ isHeaderVisible: _propTypes.default.bool,
162
+ /**
163
+ * Passed to the component to hide the bottom-border of previous row if current row is expanded (to avoid double border). Set to false by default
164
+ */
165
+ hidePreviousRowBorder: _propTypes.default.bool,
166
+ /**
167
+ * Passed to the component to determine the header text alignment
168
+ */
169
+ textAlign: _propTypes.default.oneOf(['start', 'center', 'end'])
152
170
  };
153
171
  var _default = exports.default = DataGridCell;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.toggleRowCheckbox = exports.toggleExpandedRow = exports.toggleAllCheckBoxes = exports.resetRowData = exports.resetColumnsData = exports.isAtLeastOneRowUnselected = exports.isAtLeastOneRowEnabled = exports.hasEveryRowHiddenItsCheckbox = exports.SORT_DIRECTION = exports.ROW_TYPE = exports.DATA_TYPE = exports.CELL_TYPE = void 0;
6
+ exports.toggleRowCheckbox = exports.toggleExpandedRow = exports.toggleAllCheckBoxes = exports.resetRowData = exports.resetColumnsData = exports.isAtLeastOneRowUnselected = exports.isAtLeastOneRowEnabled = exports.hideRowBottomBorder = exports.hasEveryRowHiddenItsCheckbox = exports.SORT_DIRECTION = exports.ROW_TYPE = exports.DATA_TYPE = exports.CELL_TYPE = void 0;
7
7
  const ROW_TYPE = exports.ROW_TYPE = {
8
8
  HEADING: 'heading',
9
9
  SUBHEADING: 'subHeading',
@@ -113,4 +113,18 @@ const toggleExpandedRow = (array, rowId) => {
113
113
  isExpandedRowOpen: el.id === rowId ? !el.isExpandedRowOpen : el.isExpandedRowOpen
114
114
  }));
115
115
  };
116
- exports.toggleExpandedRow = toggleExpandedRow;
116
+ exports.toggleExpandedRow = toggleExpandedRow;
117
+ const hideRowBottomBorder = function () {
118
+ let array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
119
+ return array.map((row, index) => {
120
+ const eachRow = {
121
+ ...row
122
+ };
123
+ // setting prop to disable previous row bottom border if current row is expanded
124
+ if (index < array.length - 1 && array[index + 1]?.isExpandedRowOpen) {
125
+ eachRow.hidePreviousRowBorder = true;
126
+ }
127
+ return eachRow;
128
+ });
129
+ };
130
+ exports.hideRowBottomBorder = hideRowBottomBorder;
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { Typography, Checkbox, useCopy, useThemeTokens, variantProp, IconButton } from '@telus-uds/components-base';
4
4
  import styled from 'styled-components';
5
5
  import dictionary from './dictionary';
6
- import { resetColumnsData, resetRowData, DATA_TYPE, SORT_DIRECTION, isAtLeastOneRowUnselected, isAtLeastOneRowEnabled, hasEveryRowHiddenItsCheckbox, toggleAllCheckBoxes, toggleExpandedRow, toggleRowCheckbox, ROW_TYPE, CELL_TYPE } from './utility';
6
+ import { resetColumnsData, resetRowData, DATA_TYPE, SORT_DIRECTION, isAtLeastOneRowUnselected, isAtLeastOneRowEnabled, hasEveryRowHiddenItsCheckbox, toggleAllCheckBoxes, toggleExpandedRow, toggleRowCheckbox, ROW_TYPE, CELL_TYPE, hideRowBottomBorder } from './utility';
7
7
  import DataGridTable from './DataGridTable';
8
8
  import DataGridHead from './DataGridHead';
9
9
  import DataGridBody from './DataGridBody';
@@ -45,29 +45,29 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
45
45
  const [disableHeaderCheckbox, setDisableHeaderCheckbox] = React.useState(false);
46
46
  const [hideHeaderCheckBoxByRows, setHideHeaderCheckBoxByRows] = React.useState(false);
47
47
  useEffect(() => {
48
- let _isAtLeastOneRowUnselected = null;
49
- let _isAtLeastOneRowEnabled = null;
50
- let _hideHeaderCheckBoxByRows = null;
48
+ let isAtLeastOneRowUnselectedCheck = null;
49
+ let isAtLeastOneRowEnabledCheck = null;
50
+ let hideHeaderCheckBoxByRowsCheck = null;
51
51
  if (groupedRows) {
52
- _isAtLeastOneRowUnselected = Object.keys(data).some(el => {
52
+ isAtLeastOneRowUnselectedCheck = Object.keys(data).some(el => {
53
53
  return isAtLeastOneRowUnselected(data[el].data);
54
54
  });
55
- _isAtLeastOneRowEnabled = Object.keys(data).some(el => {
55
+ isAtLeastOneRowEnabledCheck = Object.keys(data).some(el => {
56
56
  return isAtLeastOneRowEnabled(data[el].data);
57
57
  });
58
- _hideHeaderCheckBoxByRows = Object.keys(data).some(el => {
58
+ hideHeaderCheckBoxByRowsCheck = Object.keys(data).some(el => {
59
59
  return hasEveryRowHiddenItsCheckbox(data[el].data);
60
60
  });
61
61
  } else {
62
- _isAtLeastOneRowUnselected = isAtLeastOneRowUnselected(data);
63
- _isAtLeastOneRowEnabled = isAtLeastOneRowEnabled(data);
64
- _hideHeaderCheckBoxByRows = hasEveryRowHiddenItsCheckbox(data);
62
+ isAtLeastOneRowUnselectedCheck = isAtLeastOneRowUnselected(data);
63
+ isAtLeastOneRowEnabledCheck = isAtLeastOneRowEnabled(data);
64
+ hideHeaderCheckBoxByRowsCheck = hasEveryRowHiddenItsCheckbox(data);
65
65
  }
66
- setCheckAllState(_isAtLeastOneRowEnabled === false ? false : !_isAtLeastOneRowUnselected);
67
- setDisableHeaderCheckbox(!_isAtLeastOneRowEnabled);
68
- setHideHeaderCheckBoxByRows(_hideHeaderCheckBoxByRows);
66
+ setCheckAllState(isAtLeastOneRowEnabledCheck === false ? false : !isAtLeastOneRowUnselectedCheck);
67
+ setDisableHeaderCheckbox(!isAtLeastOneRowEnabledCheck);
68
+ setHideHeaderCheckBoxByRows(hideHeaderCheckBoxByRowsCheck);
69
69
  }, [data, groupedRows]);
70
- const shouldDisplayIconColumn = (allData, _showCheckbox) => {
70
+ const shouldDisplayIconColumn = (allData, shouldShowCheckbox) => {
71
71
  let doesOneRowHaveExpandedContent = null;
72
72
  if (groupedRows) {
73
73
  doesOneRowHaveExpandedContent = Object.keys(allData).some(el => {
@@ -76,54 +76,53 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
76
76
  } else {
77
77
  doesOneRowHaveExpandedContent = allData.some(el => el.hasExpandedRow === true);
78
78
  }
79
- return !!(_showCheckbox || doesOneRowHaveExpandedContent);
79
+ return !!(shouldShowCheckbox || doesOneRowHaveExpandedContent);
80
80
  };
81
81
  const toggleSelectAll = () => {
82
- let _rows = null;
82
+ let tempRows = {};
83
83
  if (groupedRows) {
84
- _rows = {};
85
84
  Object.keys(data).forEach(el => {
86
- _rows[el] = {
85
+ tempRows[el] = {
87
86
  ...data[el]
88
87
  };
89
- _rows[el].data = toggleAllCheckBoxes(data[el].data, checkAllState);
88
+ tempRows[el].data = toggleAllCheckBoxes(data[el].data, checkAllState);
90
89
  });
91
90
  } else {
92
- _rows = toggleAllCheckBoxes(data, checkAllState);
91
+ tempRows = toggleAllCheckBoxes(data, checkAllState);
93
92
  }
94
- setData(_rows);
93
+ setData(tempRows);
95
94
  setCheckAllState(!checkAllState);
96
95
  };
97
96
  const toggleCheckbox = (rowId, row) => {
98
- let _data = null;
97
+ let tempData = null;
99
98
  if (typeof row.checkBoxProps?.onChange === 'function') {
100
99
  row.checkBoxProps.onChange();
101
100
  }
102
101
  if (groupedRows) {
103
- const [group, _] = rowId.split('-');
104
- const id = parseInt(_, 10);
105
- _data = {
102
+ const [group, splitID] = rowId.split('-');
103
+ const id = parseInt(splitID, 10);
104
+ tempData = {
106
105
  ...data
107
106
  };
108
- _data[group].data = toggleRowCheckbox(_data[group].data, id);
107
+ tempData[group].data = toggleRowCheckbox(tempData[group].data, id);
109
108
  } else {
110
- _data = toggleRowCheckbox(data, rowId);
109
+ tempData = toggleRowCheckbox(data, rowId);
111
110
  }
112
- setData(_data);
111
+ setData(tempData);
113
112
  };
114
113
  const toggleRowExpansion = rowId => {
115
- let _row = null;
114
+ let tempRow = null;
116
115
  if (groupedRows) {
117
- const [group, _] = rowId.split('-');
118
- const id = parseInt(_, 10);
119
- _row = {
116
+ const [group, splitId] = rowId.split('-');
117
+ const id = parseInt(splitId, 10);
118
+ tempRow = {
120
119
  ...data
121
120
  };
122
- _row[group].data = toggleExpandedRow(_row[group].data, id);
121
+ tempRow[group].data = toggleExpandedRow(tempRow[group].data, id);
123
122
  } else {
124
- _row = toggleExpandedRow(data, rowId);
123
+ tempRow = toggleExpandedRow(data, rowId);
125
124
  }
126
- setData(_row);
125
+ setData(tempRow);
127
126
  };
128
127
  const HeaderCheckBoxDisplay = showCheckbox && !hideHeaderCheckBoxByRows && /*#__PURE__*/_jsx(Checkbox, {
129
128
  label: getCopy('all'),
@@ -131,8 +130,8 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
131
130
  inactive: disableHeaderCheckbox,
132
131
  onChange: toggleSelectAll
133
132
  });
134
- const buildCheckBoxDisplay = (_showCheckbox, row, rowId) => {
135
- return _showCheckbox && !row.hideCheckbox && /*#__PURE__*/_jsx(Checkbox, {
133
+ const buildCheckBoxDisplay = (shouldShowCheckbox, row, rowId) => {
134
+ return shouldShowCheckbox && !row.hideCheckbox && /*#__PURE__*/_jsx(Checkbox, {
136
135
  ...row.checkBoxProps,
137
136
  onChange: () => toggleCheckbox(rowId, row)
138
137
  });
@@ -157,25 +156,24 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
157
156
  children: row.expandedRowChildComponent.component
158
157
  })
159
158
  });
160
- const buildRowContent = (row, rowId, _showCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow) => /*#__PURE__*/_jsxs(React.Fragment, {
159
+ const buildRowContent = (row, rowId, shouldShowCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow) => /*#__PURE__*/_jsxs(React.Fragment, {
161
160
  children: [/*#__PURE__*/_jsxs(DataGridRow, {
162
161
  tokens: themeTokens,
163
162
  rowId: rowId,
164
163
  isExpandedRowOpen: row.isExpandedRowOpen,
165
164
  hasExpandedContent: row.hasExpandedRow,
166
165
  onClick: toggleRowExpansion,
167
- children: [shouldDisplayIconColumn(data, _showCheckbox) && /*#__PURE__*/_jsx(DataGridCell, {
166
+ children: [shouldDisplayIconColumn(data, shouldShowCheckbox) && /*#__PURE__*/_jsx(DataGridCell, {
168
167
  tokens: themeTokens,
169
168
  isExpandedRowOpen: row.isExpandedRowOpen,
169
+ hidePreviousRowBorder: row.hidePreviousRowBorder,
170
170
  isHeaderVisible: isHeaderVisible,
171
171
  children: /*#__PURE__*/_jsxs(StyledIconContainer, {
172
172
  children: [CheckBoxDisplay, DisplayCaret]
173
173
  })
174
- }), columnsData.map(column => /*#__PURE__*/_jsx(DataGridCell, {
175
- tokens: themeTokens,
176
- isExpandedRowOpen: row.isExpandedRowOpen,
177
- isHeaderVisible: isHeaderVisible,
178
- children: /*#__PURE__*/_jsx(Typography, {
174
+ }), columnsData.map(column => {
175
+ const currentColumn = columns.find(el => el.key === column.key);
176
+ const columnContent = typeof currentColumn?.displayedComponent === 'function' ? currentColumn.displayedComponent(row[column.key]) : /*#__PURE__*/_jsx(Typography, {
179
177
  block: true,
180
178
  variant: {
181
179
  size: 'small'
@@ -184,31 +182,38 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
184
182
  color: themeTokens.cellTextColor
185
183
  },
186
184
  children: row[column.key]
187
- })
188
- }, `${rowId}-${column.key}`))]
185
+ });
186
+ return /*#__PURE__*/_jsx(DataGridCell, {
187
+ tokens: themeTokens,
188
+ isExpandedRowOpen: row.isExpandedRowOpen,
189
+ hidePreviousRowBorder: row.hidePreviousRowBorder,
190
+ isHeaderVisible: isHeaderVisible,
191
+ children: columnContent
192
+ }, `${rowId}-${column.key}`);
193
+ })]
189
194
  }, rowId), ExpandedRow]
190
195
  }, rowId);
191
196
  const sortColumn = column => {
192
- const _col = {
197
+ const currentColumn = {
193
198
  ...column
194
199
  };
195
200
  if (!groupedRows) {
196
- const _data = [...data].sort((a, b) => {
197
- const first = _col.dataType === DATA_TYPE.NUMBER ? parseFloat(a[_col.key]) : a[_col.key].toUpperCase();
198
- const next = _col.dataType === DATA_TYPE.NUMBER ? parseFloat(b[_col.key]) : b[_col.key].toUpperCase();
199
- if (_col.sortDirection === SORT_DIRECTION.DESC) {
201
+ const currentData = [...data].sort((a, b) => {
202
+ const first = currentColumn.dataType === DATA_TYPE.NUMBER ? parseFloat(a[currentColumn.key]) : a[currentColumn.key].toUpperCase();
203
+ const next = currentColumn.dataType === DATA_TYPE.NUMBER ? parseFloat(b[currentColumn.key]) : b[currentColumn.key].toUpperCase();
204
+ if (currentColumn.sortDirection === SORT_DIRECTION.DESC) {
200
205
  if (first < next) return -1;
201
206
  return next === first ? 0 : 1;
202
207
  }
203
208
  if (next < first) return -1;
204
209
  return first === next ? 0 : 1;
205
210
  });
206
- _col.sortDirection = _col.sortDirection === SORT_DIRECTION.DESC ? SORT_DIRECTION.ASC : SORT_DIRECTION.DESC;
207
- _col.currentSort = true;
208
- const _columns = resetColumnsData(columnsData);
209
- _columns[columnsData.findIndex(_el => _el.key === column.key)] = _col;
210
- setColumnsData(_columns);
211
- setData(_data);
211
+ currentColumn.sortDirection = currentColumn.sortDirection === SORT_DIRECTION.DESC ? SORT_DIRECTION.ASC : SORT_DIRECTION.DESC;
212
+ currentColumn.currentSort = true;
213
+ const tempColumns = resetColumnsData(columnsData);
214
+ tempColumns[columnsData.findIndex(el => el.key === column.key)] = currentColumn;
215
+ setColumnsData(tempColumns);
216
+ setData(currentData);
212
217
  }
213
218
  };
214
219
  let HeaderContent = null;
@@ -232,7 +237,8 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
232
237
  children: data[group].groupHeaderComponent || DefaultSubHeading
233
238
  })
234
239
  }, group);
235
- const DataRow = data[group].data.map(row => {
240
+ const modifiedData = hideRowBottomBorder([...data[group].data]);
241
+ const DataRow = modifiedData.map(row => {
236
242
  const rowId = `${group}-${row.id}`;
237
243
  const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId);
238
244
  const DisplayCaret = buildDisplayCaret(row, rowId);
@@ -244,7 +250,8 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
244
250
  }, group);
245
251
  });
246
252
  } else {
247
- BodyContent = data.map(row => {
253
+ const modifiedData = hideRowBottomBorder([...data]);
254
+ BodyContent = modifiedData.map(row => {
248
255
  const rowId = row.id;
249
256
  const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId);
250
257
  const DisplayCaret = buildDisplayCaret(row, rowId);
@@ -252,18 +259,22 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
252
259
  return buildRowContent(row, rowId, showCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow);
253
260
  });
254
261
  }
262
+ const isFirstRowExpanded = data[0]?.isExpandedRowOpen;
255
263
  HeaderContent = /*#__PURE__*/_jsxs(_Fragment, {
256
264
  children: [shouldDisplayIconColumn(data, showCheckbox) && /*#__PURE__*/_jsx(DataGridCell, {
257
265
  type: CELL_TYPE.HEADING,
258
266
  tokens: themeTokens,
259
267
  isFirstCol: true,
260
268
  isHeaderVisible: isHeaderVisible,
269
+ hidePreviousRowBorder: isFirstRowExpanded,
261
270
  children: HeaderCheckBoxDisplay
262
271
  }), columnsData.map(column => /*#__PURE__*/_jsxs(DataGridCell, {
263
272
  type: CELL_TYPE.HEADING,
264
273
  tokens: themeTokens,
265
274
  isSortable: isSortable,
266
275
  isHeaderVisible: isHeaderVisible,
276
+ hidePreviousRowBorder: isFirstRowExpanded,
277
+ textAlign: column.textAlign || 'start',
267
278
  children: [/*#__PURE__*/_jsx(Typography, {
268
279
  block: true,
269
280
  variant: {
@@ -320,7 +331,9 @@ DataGrid.propTypes = {
320
331
  dataType: PropTypes.oneOf(['string', 'number']),
321
332
  isSortable: PropTypes.bool,
322
333
  // Set this to true to enable sorting for this column
323
- fn: PropTypes.func
334
+ fn: PropTypes.func,
335
+ textAlign: PropTypes.oneOf(['start', 'center', 'end']),
336
+ displayedComponent: PropTypes.func
324
337
  })).isRequired,
325
338
  /**
326
339
  * Use `groupedRows` to pass the grouped data for display
@@ -7,12 +7,17 @@ const StyledHeaderCell = /*#__PURE__*/styled.th.withConfig({
7
7
  displayName: "DataGridCell__StyledHeaderCell",
8
8
  componentId: "[object Object]__sc-6nkvhz-0"
9
9
  })(["", ""], props => {
10
- return css(["background-color:", ";border-top:solid ", "px ", ";border-bottom:solid ", "px ", ";padding:", "px;text-align:", ";box-sizing:border-box;font-size:", "px;font-weight:bold;line-height:", "px;color:", ";width:", ";font-family:", ";"], props.headerRowBackgroundColor, props.headerBorderTopWidth, props.headerBorderTopColor, props.headerBorderBottomWidth, props.headerBorderBottomColor, props.headerPadding, props.headerTextAlign, props.headerFontSize, props.headerLineHeight * props.headerFontSize, props.headerTextColor, props.firstColWidth, props.headerFontFamily);
10
+ return css(["background-color:", ";border-top:solid ", "px ", ";border-bottom:", ";padding:", "px;padding-left:", "px;padding-right:", "px;text-align:", ";box-sizing:border-box;font-size:", "px;font-weight:bold;line-height:", "px;color:", ";width:", ";font-family:", ";"], props.headerRowBackgroundColor, props.headerBorderTopWidth, props.headerBorderTopColor, props.hidePreviousRowBorder ? `none` : `solid ${props.headerBorderBottomWidth}px ${props.headerBorderBottomColor}`, props.headerPadding, props.headerCellHorizontalPadding, props.headerCellHorizontalPadding, props.headerTextAlign, props.headerFontSize, props.headerLineHeight * props.headerFontSize, props.headerTextColor, props.firstColWidth, props.headerFontFamily);
11
11
  });
12
12
  const StyledHeaderCellDiv = /*#__PURE__*/styled.div.withConfig({
13
13
  displayName: "DataGridCell__StyledHeaderCellDiv",
14
14
  componentId: "[object Object]__sc-6nkvhz-1"
15
- })(["display:flex;align-items:center;"]);
15
+ })(["display:flex;align-items:center;justify-content:", ";"], _ref => {
16
+ let {
17
+ textAlign
18
+ } = _ref;
19
+ return textAlign;
20
+ });
16
21
  const StyledHeaderCellHiddenHeader = /*#__PURE__*/styled.th.withConfig({
17
22
  displayName: "DataGridCell__StyledHeaderCellHiddenHeader",
18
23
  componentId: "[object Object]__sc-6nkvhz-2"
@@ -28,7 +33,7 @@ const StyledGroupHeaderCell = /*#__PURE__*/styled.td.withConfig({
28
33
  const StyledGroupHeaderCellDiv = /*#__PURE__*/styled.div.withConfig({
29
34
  displayName: "DataGridCell__StyledGroupHeaderCellDiv",
30
35
  componentId: "[object Object]__sc-6nkvhz-4"
31
- })(["display:flex;align-items:center;justify-content:start;"]);
36
+ })(["display:flex;align-items:center;"]);
32
37
  const StyledExpandedCell = /*#__PURE__*/styled.td.withConfig({
33
38
  displayName: "DataGridCell__StyledExpandedCell",
34
39
  componentId: "[object Object]__sc-6nkvhz-5"
@@ -48,9 +53,9 @@ export const StyledCell = /*#__PURE__*/styled.td.withConfig({
48
53
  if (props.isExpandedRowOpen) {
49
54
  return css(["padding:", "px;text-align:", ";font-size:", "px;font-weight:normal;line-height:", "px;color:", ";font-family:", ";border-top:solid ", "px ", ";"], props.cellPadding, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily, props.headerBorderTopWidth, props.headerBorderTopColor);
50
55
  }
51
- return css(["padding:", "px;border-bottom:", ";text-align:", ";font-size:", "px;font-weight:normal;line-height:", "px;color:", ";font-family:", ";"], props.cellPadding, props.hideRowBottomBorder === 1 ? `none` : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor}`, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily);
56
+ return css(["padding:", "px;border-bottom:", ";text-align:", ";font-size:", "px;font-weight:normal;line-height:", "px;color:", ";font-family:", ";"], props.cellPadding, props.hideRowBottomBorder === 1 || props.hidePreviousRowBorder ? `none` : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor}`, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily);
52
57
  });
53
- const DataGridCell = /*#__PURE__*/React.forwardRef((_ref, ref) => {
58
+ const DataGridCell = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
54
59
  let {
55
60
  children,
56
61
  tokens,
@@ -59,14 +64,18 @@ const DataGridCell = /*#__PURE__*/React.forwardRef((_ref, ref) => {
59
64
  showCheckbox = false,
60
65
  isFirstCol = false,
61
66
  isExpandedRowOpen = false,
62
- isHeaderVisible = true
63
- } = _ref;
67
+ isHeaderVisible = true,
68
+ hidePreviousRowBorder = false,
69
+ textAlign = 'start'
70
+ } = _ref2;
64
71
  if (type === CELL_TYPE.HEADING) {
65
72
  return isHeaderVisible ? /*#__PURE__*/_jsx(StyledHeaderCell, {
66
73
  ...tokens,
74
+ hidePreviousRowBorder: hidePreviousRowBorder,
67
75
  firstColWidth: isFirstCol ? tokens.firstColWidth : 'auto',
68
76
  ref: ref,
69
77
  children: /*#__PURE__*/_jsx(StyledHeaderCellDiv, {
78
+ textAlign: textAlign,
70
79
  children: children
71
80
  })
72
81
  }) : /*#__PURE__*/_jsx(StyledHeaderCellHiddenHeader, {
@@ -102,6 +111,7 @@ const DataGridCell = /*#__PURE__*/React.forwardRef((_ref, ref) => {
102
111
  return /*#__PURE__*/_jsx(StyledCell, {
103
112
  ...tokens,
104
113
  isExpandedRowOpen: isExpandedRowOpen,
114
+ hidePreviousRowBorder: hidePreviousRowBorder,
105
115
  ref: ref,
106
116
  children: children
107
117
  });
@@ -139,6 +149,14 @@ DataGridCell.propTypes = {
139
149
  /**
140
150
  * Passed to the component to determine if header is displayed. Set to false to hide header of datagrid. Set to true by default
141
151
  */
142
- isHeaderVisible: PropTypes.bool
152
+ isHeaderVisible: PropTypes.bool,
153
+ /**
154
+ * Passed to the component to hide the bottom-border of previous row if current row is expanded (to avoid double border). Set to false by default
155
+ */
156
+ hidePreviousRowBorder: PropTypes.bool,
157
+ /**
158
+ * Passed to the component to determine the header text alignment
159
+ */
160
+ textAlign: PropTypes.oneOf(['start', 'center', 'end'])
143
161
  };
144
162
  export default DataGridCell;
@@ -99,4 +99,17 @@ export const toggleExpandedRow = (array, rowId) => {
99
99
  ...el,
100
100
  isExpandedRowOpen: el.id === rowId ? !el.isExpandedRowOpen : el.isExpandedRowOpen
101
101
  }));
102
+ };
103
+ export const hideRowBottomBorder = function () {
104
+ let array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
105
+ return array.map((row, index) => {
106
+ const eachRow = {
107
+ ...row
108
+ };
109
+ // setting prop to disable previous row bottom border if current row is expanded
110
+ if (index < array.length - 1 && array[index + 1]?.isExpandedRowOpen) {
111
+ eachRow.hidePreviousRowBorder = true;
112
+ }
113
+ return eachRow;
114
+ });
102
115
  };
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "prop-types": "^15.7.2",
8
- "@telus-uds/components-web": "^4.4.0",
9
- "@telus-uds/components-base": "^3.5.0",
8
+ "@telus-uds/components-web": "^4.4.2",
9
+ "@telus-uds/components-base": "^3.5.2",
10
10
  "@telus-uds/system-theme-tokens": "^4.3.0",
11
11
  "styled-components": "6.1.13",
12
12
  "smooth-scrollbar": "8.8.4",
@@ -46,5 +46,5 @@
46
46
  "standard-engine": {
47
47
  "skip": true
48
48
  },
49
- "version": "1.2.2"
49
+ "version": "1.3.0"
50
50
  }
package/src/DataGrid.jsx CHANGED
@@ -22,7 +22,8 @@ import {
22
22
  toggleExpandedRow,
23
23
  toggleRowCheckbox,
24
24
  ROW_TYPE,
25
- CELL_TYPE
25
+ CELL_TYPE,
26
+ hideRowBottomBorder
26
27
  } from './utility'
27
28
  import DataGridTable from './DataGridTable'
28
29
  import DataGridHead from './DataGridHead'
@@ -67,34 +68,36 @@ const DataGrid = React.forwardRef(
67
68
  const [hideHeaderCheckBoxByRows, setHideHeaderCheckBoxByRows] = React.useState(false)
68
69
 
69
70
  useEffect(() => {
70
- let _isAtLeastOneRowUnselected = null
71
- let _isAtLeastOneRowEnabled = null
72
- let _hideHeaderCheckBoxByRows = null
71
+ let isAtLeastOneRowUnselectedCheck = null
72
+ let isAtLeastOneRowEnabledCheck = null
73
+ let hideHeaderCheckBoxByRowsCheck = null
73
74
 
74
75
  if (groupedRows) {
75
- _isAtLeastOneRowUnselected = Object.keys(data).some((el) => {
76
+ isAtLeastOneRowUnselectedCheck = Object.keys(data).some((el) => {
76
77
  return isAtLeastOneRowUnselected(data[el].data)
77
78
  })
78
79
 
79
- _isAtLeastOneRowEnabled = Object.keys(data).some((el) => {
80
+ isAtLeastOneRowEnabledCheck = Object.keys(data).some((el) => {
80
81
  return isAtLeastOneRowEnabled(data[el].data)
81
82
  })
82
83
 
83
- _hideHeaderCheckBoxByRows = Object.keys(data).some((el) => {
84
+ hideHeaderCheckBoxByRowsCheck = Object.keys(data).some((el) => {
84
85
  return hasEveryRowHiddenItsCheckbox(data[el].data)
85
86
  })
86
87
  } else {
87
- _isAtLeastOneRowUnselected = isAtLeastOneRowUnselected(data)
88
- _isAtLeastOneRowEnabled = isAtLeastOneRowEnabled(data)
89
- _hideHeaderCheckBoxByRows = hasEveryRowHiddenItsCheckbox(data)
88
+ isAtLeastOneRowUnselectedCheck = isAtLeastOneRowUnselected(data)
89
+ isAtLeastOneRowEnabledCheck = isAtLeastOneRowEnabled(data)
90
+ hideHeaderCheckBoxByRowsCheck = hasEveryRowHiddenItsCheckbox(data)
90
91
  }
91
92
 
92
- setCheckAllState(_isAtLeastOneRowEnabled === false ? false : !_isAtLeastOneRowUnselected)
93
- setDisableHeaderCheckbox(!_isAtLeastOneRowEnabled)
94
- setHideHeaderCheckBoxByRows(_hideHeaderCheckBoxByRows)
93
+ setCheckAllState(
94
+ isAtLeastOneRowEnabledCheck === false ? false : !isAtLeastOneRowUnselectedCheck
95
+ )
96
+ setDisableHeaderCheckbox(!isAtLeastOneRowEnabledCheck)
97
+ setHideHeaderCheckBoxByRows(hideHeaderCheckBoxByRowsCheck)
95
98
  }, [data, groupedRows])
96
99
 
97
- const shouldDisplayIconColumn = (allData, _showCheckbox) => {
100
+ const shouldDisplayIconColumn = (allData, shouldShowCheckbox) => {
98
101
  let doesOneRowHaveExpandedContent = null
99
102
  if (groupedRows) {
100
103
  doesOneRowHaveExpandedContent = Object.keys(allData).some((el) => {
@@ -104,53 +107,52 @@ const DataGrid = React.forwardRef(
104
107
  doesOneRowHaveExpandedContent = allData.some((el) => el.hasExpandedRow === true)
105
108
  }
106
109
 
107
- return !!(_showCheckbox || doesOneRowHaveExpandedContent)
110
+ return !!(shouldShowCheckbox || doesOneRowHaveExpandedContent)
108
111
  }
109
112
 
110
113
  const toggleSelectAll = () => {
111
- let _rows = null
114
+ let tempRows = {}
112
115
  if (groupedRows) {
113
- _rows = {}
114
116
  Object.keys(data).forEach((el) => {
115
- _rows[el] = { ...data[el] }
116
- _rows[el].data = toggleAllCheckBoxes(data[el].data, checkAllState)
117
+ tempRows[el] = { ...data[el] }
118
+ tempRows[el].data = toggleAllCheckBoxes(data[el].data, checkAllState)
117
119
  })
118
120
  } else {
119
- _rows = toggleAllCheckBoxes(data, checkAllState)
121
+ tempRows = toggleAllCheckBoxes(data, checkAllState)
120
122
  }
121
- setData(_rows)
123
+ setData(tempRows)
122
124
  setCheckAllState(!checkAllState)
123
125
  }
124
126
 
125
127
  const toggleCheckbox = (rowId, row) => {
126
- let _data = null
128
+ let tempData = null
127
129
 
128
130
  if (typeof row.checkBoxProps?.onChange === 'function') {
129
131
  row.checkBoxProps.onChange()
130
132
  }
131
133
 
132
134
  if (groupedRows) {
133
- const [group, _] = rowId.split('-')
134
- const id = parseInt(_, 10)
135
- _data = { ...data }
136
- _data[group].data = toggleRowCheckbox(_data[group].data, id)
135
+ const [group, splitID] = rowId.split('-')
136
+ const id = parseInt(splitID, 10)
137
+ tempData = { ...data }
138
+ tempData[group].data = toggleRowCheckbox(tempData[group].data, id)
137
139
  } else {
138
- _data = toggleRowCheckbox(data, rowId)
140
+ tempData = toggleRowCheckbox(data, rowId)
139
141
  }
140
- setData(_data)
142
+ setData(tempData)
141
143
  }
142
144
 
143
145
  const toggleRowExpansion = (rowId) => {
144
- let _row = null
146
+ let tempRow = null
145
147
  if (groupedRows) {
146
- const [group, _] = rowId.split('-')
147
- const id = parseInt(_, 10)
148
- _row = { ...data }
149
- _row[group].data = toggleExpandedRow(_row[group].data, id)
148
+ const [group, splitId] = rowId.split('-')
149
+ const id = parseInt(splitId, 10)
150
+ tempRow = { ...data }
151
+ tempRow[group].data = toggleExpandedRow(tempRow[group].data, id)
150
152
  } else {
151
- _row = toggleExpandedRow(data, rowId)
153
+ tempRow = toggleExpandedRow(data, rowId)
152
154
  }
153
- setData(_row)
155
+ setData(tempRow)
154
156
  }
155
157
 
156
158
  const HeaderCheckBoxDisplay = showCheckbox && !hideHeaderCheckBoxByRows && (
@@ -162,9 +164,9 @@ const DataGrid = React.forwardRef(
162
164
  />
163
165
  )
164
166
 
165
- const buildCheckBoxDisplay = (_showCheckbox, row, rowId) => {
167
+ const buildCheckBoxDisplay = (shouldShowCheckbox, row, rowId) => {
166
168
  return (
167
- _showCheckbox &&
169
+ shouldShowCheckbox &&
168
170
  !row.hideCheckbox && (
169
171
  <Checkbox {...row.checkBoxProps} onChange={() => toggleCheckbox(rowId, row)} />
170
172
  )
@@ -206,7 +208,7 @@ const DataGrid = React.forwardRef(
206
208
  const buildRowContent = (
207
209
  row,
208
210
  rowId,
209
- _showCheckbox,
211
+ shouldShowCheckbox,
210
212
  CheckBoxDisplay,
211
213
  DisplayCaret,
212
214
  ExpandedRow
@@ -220,10 +222,11 @@ const DataGrid = React.forwardRef(
220
222
  hasExpandedContent={row.hasExpandedRow}
221
223
  onClick={toggleRowExpansion}
222
224
  >
223
- {shouldDisplayIconColumn(data, _showCheckbox) && (
225
+ {shouldDisplayIconColumn(data, shouldShowCheckbox) && (
224
226
  <DataGridCell
225
227
  tokens={themeTokens}
226
228
  isExpandedRowOpen={row.isExpandedRowOpen}
229
+ hidePreviousRowBorder={row.hidePreviousRowBorder}
227
230
  isHeaderVisible={isHeaderVisible}
228
231
  >
229
232
  <StyledIconContainer>
@@ -232,37 +235,51 @@ const DataGrid = React.forwardRef(
232
235
  </StyledIconContainer>
233
236
  </DataGridCell>
234
237
  )}
235
- {columnsData.map((column) => (
236
- <DataGridCell
237
- tokens={themeTokens}
238
- isExpandedRowOpen={row.isExpandedRowOpen}
239
- isHeaderVisible={isHeaderVisible}
240
- key={`${rowId}-${column.key}`}
241
- >
242
- <Typography
243
- block
244
- variant={{ size: 'small' }}
245
- tokens={{ color: themeTokens.cellTextColor }}
238
+ {columnsData.map((column) => {
239
+ const currentColumn = columns.find((el) => el.key === column.key)
240
+ const columnContent =
241
+ typeof currentColumn?.displayedComponent === 'function' ? (
242
+ currentColumn.displayedComponent(row[column.key])
243
+ ) : (
244
+ <Typography
245
+ block
246
+ variant={{ size: 'small' }}
247
+ tokens={{ color: themeTokens.cellTextColor }}
248
+ >
249
+ {row[column.key]}
250
+ </Typography>
251
+ )
252
+ return (
253
+ <DataGridCell
254
+ tokens={themeTokens}
255
+ isExpandedRowOpen={row.isExpandedRowOpen}
256
+ hidePreviousRowBorder={row.hidePreviousRowBorder}
257
+ isHeaderVisible={isHeaderVisible}
258
+ key={`${rowId}-${column.key}`}
246
259
  >
247
- {row[column.key]}
248
- </Typography>
249
- </DataGridCell>
250
- ))}
260
+ {columnContent}
261
+ </DataGridCell>
262
+ )
263
+ })}
251
264
  </DataGridRow>
252
265
  {ExpandedRow}
253
266
  </React.Fragment>
254
267
  )
255
268
 
256
269
  const sortColumn = (column) => {
257
- const _col = { ...column }
270
+ const currentColumn = { ...column }
258
271
  if (!groupedRows) {
259
- const _data = [...data].sort((a, b) => {
272
+ const currentData = [...data].sort((a, b) => {
260
273
  const first =
261
- _col.dataType === DATA_TYPE.NUMBER ? parseFloat(a[_col.key]) : a[_col.key].toUpperCase()
274
+ currentColumn.dataType === DATA_TYPE.NUMBER
275
+ ? parseFloat(a[currentColumn.key])
276
+ : a[currentColumn.key].toUpperCase()
262
277
  const next =
263
- _col.dataType === DATA_TYPE.NUMBER ? parseFloat(b[_col.key]) : b[_col.key].toUpperCase()
278
+ currentColumn.dataType === DATA_TYPE.NUMBER
279
+ ? parseFloat(b[currentColumn.key])
280
+ : b[currentColumn.key].toUpperCase()
264
281
 
265
- if (_col.sortDirection === SORT_DIRECTION.DESC) {
282
+ if (currentColumn.sortDirection === SORT_DIRECTION.DESC) {
266
283
  if (first < next) return -1
267
284
  return next === first ? 0 : 1
268
285
  }
@@ -270,15 +287,17 @@ const DataGrid = React.forwardRef(
270
287
  return first === next ? 0 : 1
271
288
  })
272
289
 
273
- _col.sortDirection =
274
- _col.sortDirection === SORT_DIRECTION.DESC ? SORT_DIRECTION.ASC : SORT_DIRECTION.DESC
275
- _col.currentSort = true
290
+ currentColumn.sortDirection =
291
+ currentColumn.sortDirection === SORT_DIRECTION.DESC
292
+ ? SORT_DIRECTION.ASC
293
+ : SORT_DIRECTION.DESC
294
+ currentColumn.currentSort = true
276
295
 
277
- const _columns = resetColumnsData(columnsData)
278
- _columns[columnsData.findIndex((_el) => _el.key === column.key)] = _col
296
+ const tempColumns = resetColumnsData(columnsData)
297
+ tempColumns[columnsData.findIndex((el) => el.key === column.key)] = currentColumn
279
298
 
280
- setColumnsData(_columns)
281
- setData(_data)
299
+ setColumnsData(tempColumns)
300
+ setData(currentData)
282
301
  }
283
302
  }
284
303
 
@@ -301,8 +320,8 @@ const DataGrid = React.forwardRef(
301
320
  </DataGridCell>
302
321
  </DataGridRow>
303
322
  )
304
-
305
- const DataRow = data[group].data.map((row) => {
323
+ const modifiedData = hideRowBottomBorder([...data[group].data])
324
+ const DataRow = modifiedData.map((row) => {
306
325
  const rowId = `${group}-${row.id}`
307
326
  const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId)
308
327
 
@@ -328,7 +347,8 @@ const DataGrid = React.forwardRef(
328
347
  )
329
348
  })
330
349
  } else {
331
- BodyContent = data.map((row) => {
350
+ const modifiedData = hideRowBottomBorder([...data])
351
+ BodyContent = modifiedData.map((row) => {
332
352
  const rowId = row.id
333
353
 
334
354
  const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId)
@@ -341,6 +361,7 @@ const DataGrid = React.forwardRef(
341
361
  })
342
362
  }
343
363
 
364
+ const isFirstRowExpanded = data[0]?.isExpandedRowOpen
344
365
  HeaderContent = (
345
366
  <>
346
367
  {shouldDisplayIconColumn(data, showCheckbox) && (
@@ -349,6 +370,7 @@ const DataGrid = React.forwardRef(
349
370
  tokens={themeTokens}
350
371
  isFirstCol={true}
351
372
  isHeaderVisible={isHeaderVisible}
373
+ hidePreviousRowBorder={isFirstRowExpanded}
352
374
  >
353
375
  {HeaderCheckBoxDisplay}
354
376
  </DataGridCell>
@@ -361,6 +383,8 @@ const DataGrid = React.forwardRef(
361
383
  tokens={themeTokens}
362
384
  isSortable={isSortable}
363
385
  isHeaderVisible={isHeaderVisible}
386
+ hidePreviousRowBorder={isFirstRowExpanded}
387
+ textAlign={column.textAlign || 'start'}
364
388
  >
365
389
  <Typography
366
390
  block
@@ -427,7 +451,9 @@ DataGrid.propTypes = {
427
451
  width: PropTypes.string,
428
452
  dataType: PropTypes.oneOf(['string', 'number']),
429
453
  isSortable: PropTypes.bool, // Set this to true to enable sorting for this column
430
- fn: PropTypes.func
454
+ fn: PropTypes.func,
455
+ textAlign: PropTypes.oneOf(['start', 'center', 'end']),
456
+ displayedComponent: PropTypes.func
431
457
  })
432
458
  ).isRequired,
433
459
  /**
@@ -8,8 +8,12 @@ const StyledHeaderCell = styled.th`
8
8
  return css`
9
9
  background-color: ${props.headerRowBackgroundColor};
10
10
  border-top: solid ${props.headerBorderTopWidth}px ${props.headerBorderTopColor};
11
- border-bottom: solid ${props.headerBorderBottomWidth}px ${props.headerBorderBottomColor};
11
+ border-bottom: ${props.hidePreviousRowBorder
12
+ ? `none`
13
+ : `solid ${props.headerBorderBottomWidth}px ${props.headerBorderBottomColor}`};
12
14
  padding: ${props.headerPadding}px;
15
+ padding-left: ${props.headerCellHorizontalPadding}px;
16
+ padding-right: ${props.headerCellHorizontalPadding}px;
13
17
  text-align: ${props.headerTextAlign};
14
18
  box-sizing: border-box;
15
19
  font-size: ${props.headerFontSize}px;
@@ -24,6 +28,7 @@ const StyledHeaderCell = styled.th`
24
28
  const StyledHeaderCellDiv = styled.div`
25
29
  display: flex;
26
30
  align-items: center;
31
+ justify-content: ${({ textAlign }) => textAlign};
27
32
  `
28
33
  const StyledHeaderCellHiddenHeader = styled.th`
29
34
  ${(props) => {
@@ -56,7 +61,6 @@ const StyledGroupHeaderCell = styled.td`
56
61
  const StyledGroupHeaderCellDiv = styled.div`
57
62
  display: flex;
58
63
  align-items: center;
59
- justify-content: start;
60
64
  `
61
65
 
62
66
  const StyledExpandedCell = styled.td`
@@ -107,7 +111,7 @@ export const StyledCell = styled.td`
107
111
  }
108
112
  return css`
109
113
  padding: ${props.cellPadding}px;
110
- border-bottom: ${props.hideRowBottomBorder === 1
114
+ border-bottom: ${props.hideRowBottomBorder === 1 || props.hidePreviousRowBorder
111
115
  ? `none`
112
116
  : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor}`};
113
117
  text-align: ${props.cellTextAlign};
@@ -130,7 +134,9 @@ const DataGridCell = React.forwardRef(
130
134
  showCheckbox = false,
131
135
  isFirstCol = false,
132
136
  isExpandedRowOpen = false,
133
- isHeaderVisible = true
137
+ isHeaderVisible = true,
138
+ hidePreviousRowBorder = false,
139
+ textAlign = 'start'
134
140
  },
135
141
  ref
136
142
  ) => {
@@ -138,10 +144,11 @@ const DataGridCell = React.forwardRef(
138
144
  return isHeaderVisible ? (
139
145
  <StyledHeaderCell
140
146
  {...tokens}
147
+ hidePreviousRowBorder={hidePreviousRowBorder}
141
148
  firstColWidth={isFirstCol ? tokens.firstColWidth : 'auto'}
142
149
  ref={ref}
143
150
  >
144
- <StyledHeaderCellDiv>{children}</StyledHeaderCellDiv>
151
+ <StyledHeaderCellDiv textAlign={textAlign}>{children}</StyledHeaderCellDiv>
145
152
  </StyledHeaderCell>
146
153
  ) : (
147
154
  <StyledHeaderCellHiddenHeader
@@ -173,7 +180,12 @@ const DataGridCell = React.forwardRef(
173
180
  )
174
181
  }
175
182
  return (
176
- <StyledCell {...tokens} isExpandedRowOpen={isExpandedRowOpen} ref={ref}>
183
+ <StyledCell
184
+ {...tokens}
185
+ isExpandedRowOpen={isExpandedRowOpen}
186
+ hidePreviousRowBorder={hidePreviousRowBorder}
187
+ ref={ref}
188
+ >
177
189
  {children}
178
190
  </StyledCell>
179
191
  )
@@ -214,7 +226,15 @@ DataGridCell.propTypes = {
214
226
  /**
215
227
  * Passed to the component to determine if header is displayed. Set to false to hide header of datagrid. Set to true by default
216
228
  */
217
- isHeaderVisible: PropTypes.bool
229
+ isHeaderVisible: PropTypes.bool,
230
+ /**
231
+ * Passed to the component to hide the bottom-border of previous row if current row is expanded (to avoid double border). Set to false by default
232
+ */
233
+ hidePreviousRowBorder: PropTypes.bool,
234
+ /**
235
+ * Passed to the component to determine the header text alignment
236
+ */
237
+ textAlign: PropTypes.oneOf(['start', 'center', 'end'])
218
238
  }
219
239
 
220
240
  export default DataGridCell
package/src/utility.jsx CHANGED
@@ -110,3 +110,14 @@ export const toggleExpandedRow = (array, rowId) => {
110
110
  isExpandedRowOpen: el.id === rowId ? !el.isExpandedRowOpen : el.isExpandedRowOpen
111
111
  }))
112
112
  }
113
+
114
+ export const hideRowBottomBorder = (array = []) => {
115
+ return array.map((row, index) => {
116
+ const eachRow = { ...row }
117
+ // setting prop to disable previous row bottom border if current row is expanded
118
+ if (index < array.length - 1 && array[index + 1]?.isExpandedRowOpen) {
119
+ eachRow.hidePreviousRowBorder = true
120
+ }
121
+ return eachRow
122
+ })
123
+ }