@telus-uds/components-community.data-grid 1.5.4 → 1.6.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 +15 -2
- package/lib/cjs/DataGrid.js +33 -9
- package/lib/esm/DataGrid.js +33 -9
- package/package.json +4 -4
- package/src/DataGrid.jsx +45 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-community.data-grid
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 04 Sep 2025 06:46:41 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.6.0
|
|
8
|
+
|
|
9
|
+
Thu, 04 Sep 2025 06:46:41 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `Datagrid`: Remove gap between checkbox and chevron icon (vishal.jindal@telus.com)
|
|
14
|
+
- `DataGrid`: Enhancement to enable custom business logic on chevron toggle (sam.obisesan@telus.com)
|
|
15
|
+
- Bump @telus-uds/components-web to v4.11.0
|
|
16
|
+
- Bump @telus-uds/components-base to v3.14.0
|
|
17
|
+
- Bump @telus-uds/system-theme-tokens to v4.13.0
|
|
18
|
+
- Bump @telus-uds/browserslist-config to v1.0.5
|
|
19
|
+
|
|
7
20
|
## 1.5.4
|
|
8
21
|
|
|
9
|
-
Fri, 15 Aug 2025 00:
|
|
22
|
+
Fri, 15 Aug 2025 00:52:15 GMT
|
|
10
23
|
|
|
11
24
|
### Patches
|
|
12
25
|
|
package/lib/cjs/DataGrid.js
CHANGED
|
@@ -22,7 +22,15 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
22
22
|
const StyledIconContainer = exports.StyledIconContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
23
23
|
displayName: "DataGrid__StyledIconContainer",
|
|
24
24
|
componentId: "[object Object]__sc-1ddcmt-0"
|
|
25
|
-
})(["
|
|
25
|
+
})(["", ""], props => {
|
|
26
|
+
return `
|
|
27
|
+
display: flex;
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
align-items: center;
|
|
30
|
+
width: ${props.checkboxChevronIconGap < 0 ? 34 : props.checkboxChevronIconGap + 34}px;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
`;
|
|
33
|
+
});
|
|
26
34
|
const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
27
35
|
let {
|
|
28
36
|
rows = [],
|
|
@@ -47,7 +55,8 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
47
55
|
expandRowIcon,
|
|
48
56
|
hideExpandedRowIcon,
|
|
49
57
|
sortColumnIconDown,
|
|
50
|
-
sortColumnIconUp
|
|
58
|
+
sortColumnIconUp,
|
|
59
|
+
checkboxChevronIconGap
|
|
51
60
|
} = themeTokens;
|
|
52
61
|
const [data, setData] = _react.default.useState(groupedRows ? (0, _utility.resetRowData)([...groupedRows], true) : (0, _utility.resetRowData)([...rows]));
|
|
53
62
|
const [columnsData, setColumnsData] = _react.default.useState((0, _utility.resetColumnsData)(columns));
|
|
@@ -121,18 +130,31 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
121
130
|
setData(tempData);
|
|
122
131
|
};
|
|
123
132
|
const toggleRowExpansion = rowId => {
|
|
124
|
-
let
|
|
133
|
+
let tempData = null;
|
|
125
134
|
if (groupedRows) {
|
|
126
135
|
const [group, splitId] = rowId.split('-');
|
|
127
|
-
const
|
|
128
|
-
|
|
136
|
+
const childId = parseInt(splitId, 10);
|
|
137
|
+
tempData = {
|
|
129
138
|
...data
|
|
130
139
|
};
|
|
131
|
-
|
|
140
|
+
tempData[group].data = (0, _utility.toggleExpandedRow)(tempData[group].data, childId);
|
|
141
|
+
const childIndex = tempData[group].data.findIndex(value => value.id === childId);
|
|
142
|
+
if (tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle && typeof tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle === 'function') {
|
|
143
|
+
const newData = tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle(tempData, rowId);
|
|
144
|
+
setData(newData);
|
|
145
|
+
} else {
|
|
146
|
+
setData(tempData);
|
|
147
|
+
}
|
|
132
148
|
} else {
|
|
133
|
-
|
|
149
|
+
tempData = (0, _utility.toggleExpandedRow)(data, rowId);
|
|
150
|
+
const thisRow = data.find(innerData => innerData.id === rowId);
|
|
151
|
+
if (typeof thisRow.expandedRowChildComponent?.onChevronToggle === 'function') {
|
|
152
|
+
const newData = thisRow.expandedRowChildComponent.onChevronToggle(tempData, rowId);
|
|
153
|
+
setData(newData);
|
|
154
|
+
} else {
|
|
155
|
+
setData(tempData);
|
|
156
|
+
}
|
|
134
157
|
}
|
|
135
|
-
setData(tempRow);
|
|
136
158
|
};
|
|
137
159
|
const HeaderCheckBoxDisplay = showCheckbox && !hideHeaderCheckBoxByRows && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Checkbox, {
|
|
138
160
|
label: getCopy('all'),
|
|
@@ -179,6 +201,7 @@ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
179
201
|
hidePreviousRowBorder: row.hidePreviousRowBorder,
|
|
180
202
|
isHeaderVisible: isHeaderVisible,
|
|
181
203
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledIconContainer, {
|
|
204
|
+
checkboxChevronIconGap: checkboxChevronIconGap,
|
|
182
205
|
children: [CheckBoxDisplay, DisplayCaret]
|
|
183
206
|
})
|
|
184
207
|
}), columnsData.map(column => {
|
|
@@ -377,7 +400,8 @@ DataGrid.propTypes = {
|
|
|
377
400
|
id: _propTypes.default.number.isRequired,
|
|
378
401
|
expandedRowChildComponent: _propTypes.default.shape({
|
|
379
402
|
component: _propTypes.default.node,
|
|
380
|
-
displayOnLoad: _propTypes.default.bool.isRequired
|
|
403
|
+
displayOnLoad: _propTypes.default.bool.isRequired,
|
|
404
|
+
onChevronToggle: _propTypes.default.func
|
|
381
405
|
}),
|
|
382
406
|
/**
|
|
383
407
|
* Set this to true to hide checkbox for the specified row
|
package/lib/esm/DataGrid.js
CHANGED
|
@@ -13,7 +13,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
13
13
|
export const StyledIconContainer = /*#__PURE__*/styled.div.withConfig({
|
|
14
14
|
displayName: "DataGrid__StyledIconContainer",
|
|
15
15
|
componentId: "[object Object]__sc-1ddcmt-0"
|
|
16
|
-
})(["
|
|
16
|
+
})(["", ""], props => {
|
|
17
|
+
return `
|
|
18
|
+
display: flex;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
align-items: center;
|
|
21
|
+
width: ${props.checkboxChevronIconGap < 0 ? 34 : props.checkboxChevronIconGap + 34}px;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
`;
|
|
24
|
+
});
|
|
17
25
|
const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
18
26
|
let {
|
|
19
27
|
rows = [],
|
|
@@ -38,7 +46,8 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
38
46
|
expandRowIcon,
|
|
39
47
|
hideExpandedRowIcon,
|
|
40
48
|
sortColumnIconDown,
|
|
41
|
-
sortColumnIconUp
|
|
49
|
+
sortColumnIconUp,
|
|
50
|
+
checkboxChevronIconGap
|
|
42
51
|
} = themeTokens;
|
|
43
52
|
const [data, setData] = React.useState(groupedRows ? resetRowData([...groupedRows], true) : resetRowData([...rows]));
|
|
44
53
|
const [columnsData, setColumnsData] = React.useState(resetColumnsData(columns));
|
|
@@ -112,18 +121,31 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
112
121
|
setData(tempData);
|
|
113
122
|
};
|
|
114
123
|
const toggleRowExpansion = rowId => {
|
|
115
|
-
let
|
|
124
|
+
let tempData = null;
|
|
116
125
|
if (groupedRows) {
|
|
117
126
|
const [group, splitId] = rowId.split('-');
|
|
118
|
-
const
|
|
119
|
-
|
|
127
|
+
const childId = parseInt(splitId, 10);
|
|
128
|
+
tempData = {
|
|
120
129
|
...data
|
|
121
130
|
};
|
|
122
|
-
|
|
131
|
+
tempData[group].data = toggleExpandedRow(tempData[group].data, childId);
|
|
132
|
+
const childIndex = tempData[group].data.findIndex(value => value.id === childId);
|
|
133
|
+
if (tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle && typeof tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle === 'function') {
|
|
134
|
+
const newData = tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle(tempData, rowId);
|
|
135
|
+
setData(newData);
|
|
136
|
+
} else {
|
|
137
|
+
setData(tempData);
|
|
138
|
+
}
|
|
123
139
|
} else {
|
|
124
|
-
|
|
140
|
+
tempData = toggleExpandedRow(data, rowId);
|
|
141
|
+
const thisRow = data.find(innerData => innerData.id === rowId);
|
|
142
|
+
if (typeof thisRow.expandedRowChildComponent?.onChevronToggle === 'function') {
|
|
143
|
+
const newData = thisRow.expandedRowChildComponent.onChevronToggle(tempData, rowId);
|
|
144
|
+
setData(newData);
|
|
145
|
+
} else {
|
|
146
|
+
setData(tempData);
|
|
147
|
+
}
|
|
125
148
|
}
|
|
126
|
-
setData(tempRow);
|
|
127
149
|
};
|
|
128
150
|
const HeaderCheckBoxDisplay = showCheckbox && !hideHeaderCheckBoxByRows && /*#__PURE__*/_jsx(Checkbox, {
|
|
129
151
|
label: getCopy('all'),
|
|
@@ -170,6 +192,7 @@ const DataGrid = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
170
192
|
hidePreviousRowBorder: row.hidePreviousRowBorder,
|
|
171
193
|
isHeaderVisible: isHeaderVisible,
|
|
172
194
|
children: /*#__PURE__*/_jsxs(StyledIconContainer, {
|
|
195
|
+
checkboxChevronIconGap: checkboxChevronIconGap,
|
|
173
196
|
children: [CheckBoxDisplay, DisplayCaret]
|
|
174
197
|
})
|
|
175
198
|
}), columnsData.map(column => {
|
|
@@ -368,7 +391,8 @@ DataGrid.propTypes = {
|
|
|
368
391
|
id: PropTypes.number.isRequired,
|
|
369
392
|
expandedRowChildComponent: PropTypes.shape({
|
|
370
393
|
component: PropTypes.node,
|
|
371
|
-
displayOnLoad: PropTypes.bool.isRequired
|
|
394
|
+
displayOnLoad: PropTypes.bool.isRequired,
|
|
395
|
+
onChevronToggle: PropTypes.func
|
|
372
396
|
}),
|
|
373
397
|
/**
|
|
374
398
|
* Set this to true to hide checkbox for the specified row
|
package/package.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
],
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"prop-types": "^15.7.2",
|
|
8
|
-
"@telus-uds/components-web": "^4.
|
|
9
|
-
"@telus-uds/components-base": "^3.
|
|
10
|
-
"@telus-uds/system-theme-tokens": "^4.
|
|
8
|
+
"@telus-uds/components-web": "^4.11.0",
|
|
9
|
+
"@telus-uds/components-base": "^3.14.0",
|
|
10
|
+
"@telus-uds/system-theme-tokens": "^4.13.0",
|
|
11
11
|
"styled-components": "6.1.13"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"standard-engine": {
|
|
45
45
|
"skip": true
|
|
46
46
|
},
|
|
47
|
-
"version": "1.
|
|
47
|
+
"version": "1.6.0"
|
|
48
48
|
}
|
package/src/DataGrid.jsx
CHANGED
|
@@ -32,11 +32,15 @@ import DataGridRow from './DataGridRow'
|
|
|
32
32
|
import DataGridCell from './DataGridCell'
|
|
33
33
|
|
|
34
34
|
export const StyledIconContainer = styled.div`
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
${(props) => {
|
|
36
|
+
return `
|
|
37
|
+
display: flex;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
align-items: center;
|
|
40
|
+
width: ${props.checkboxChevronIconGap < 0 ? 34 : props.checkboxChevronIconGap + 34}px;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
`
|
|
43
|
+
}}
|
|
40
44
|
`
|
|
41
45
|
|
|
42
46
|
const DataGrid = React.forwardRef(
|
|
@@ -59,7 +63,13 @@ const DataGrid = React.forwardRef(
|
|
|
59
63
|
) => {
|
|
60
64
|
const themeTokens = useThemeTokens('DataGrid', tokens, variant)
|
|
61
65
|
const getCopy = useCopy({ dictionary, copy })
|
|
62
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
expandRowIcon,
|
|
68
|
+
hideExpandedRowIcon,
|
|
69
|
+
sortColumnIconDown,
|
|
70
|
+
sortColumnIconUp,
|
|
71
|
+
checkboxChevronIconGap
|
|
72
|
+
} = themeTokens
|
|
63
73
|
const [data, setData] = React.useState(
|
|
64
74
|
groupedRows ? resetRowData([...groupedRows], true) : resetRowData([...rows])
|
|
65
75
|
)
|
|
@@ -144,16 +154,36 @@ const DataGrid = React.forwardRef(
|
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
const toggleRowExpansion = (rowId) => {
|
|
147
|
-
let
|
|
157
|
+
let tempData = null
|
|
148
158
|
if (groupedRows) {
|
|
149
159
|
const [group, splitId] = rowId.split('-')
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
160
|
+
const childId = parseInt(splitId, 10)
|
|
161
|
+
tempData = { ...data }
|
|
162
|
+
tempData[group].data = toggleExpandedRow(tempData[group].data, childId)
|
|
163
|
+
const childIndex = tempData[group].data.findIndex((value) => value.id === childId)
|
|
164
|
+
if (
|
|
165
|
+
tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle &&
|
|
166
|
+
typeof tempData[group].data[childIndex].expandedRowChildComponent?.onChevronToggle ===
|
|
167
|
+
'function'
|
|
168
|
+
) {
|
|
169
|
+
const newData = tempData[group].data[
|
|
170
|
+
childIndex
|
|
171
|
+
].expandedRowChildComponent?.onChevronToggle(tempData, rowId)
|
|
172
|
+
|
|
173
|
+
setData(newData)
|
|
174
|
+
} else {
|
|
175
|
+
setData(tempData)
|
|
176
|
+
}
|
|
153
177
|
} else {
|
|
154
|
-
|
|
178
|
+
tempData = toggleExpandedRow(data, rowId)
|
|
179
|
+
const thisRow = data.find((innerData) => innerData.id === rowId)
|
|
180
|
+
if (typeof thisRow.expandedRowChildComponent?.onChevronToggle === 'function') {
|
|
181
|
+
const newData = thisRow.expandedRowChildComponent.onChevronToggle(tempData, rowId)
|
|
182
|
+
setData(newData)
|
|
183
|
+
} else {
|
|
184
|
+
setData(tempData)
|
|
185
|
+
}
|
|
155
186
|
}
|
|
156
|
-
setData(tempRow)
|
|
157
187
|
}
|
|
158
188
|
|
|
159
189
|
const HeaderCheckBoxDisplay = showCheckbox && !hideHeaderCheckBoxByRows && (
|
|
@@ -230,7 +260,7 @@ const DataGrid = React.forwardRef(
|
|
|
230
260
|
hidePreviousRowBorder={row.hidePreviousRowBorder}
|
|
231
261
|
isHeaderVisible={isHeaderVisible}
|
|
232
262
|
>
|
|
233
|
-
<StyledIconContainer>
|
|
263
|
+
<StyledIconContainer checkboxChevronIconGap={checkboxChevronIconGap}>
|
|
234
264
|
{CheckBoxDisplay}
|
|
235
265
|
{DisplayCaret}
|
|
236
266
|
</StyledIconContainer>
|
|
@@ -497,7 +527,8 @@ DataGrid.propTypes = {
|
|
|
497
527
|
id: PropTypes.number.isRequired,
|
|
498
528
|
expandedRowChildComponent: PropTypes.shape({
|
|
499
529
|
component: PropTypes.node,
|
|
500
|
-
displayOnLoad: PropTypes.bool.isRequired
|
|
530
|
+
displayOnLoad: PropTypes.bool.isRequired,
|
|
531
|
+
onChevronToggle: PropTypes.func
|
|
501
532
|
}),
|
|
502
533
|
/**
|
|
503
534
|
* Set this to true to hide checkbox for the specified row
|