@telus-uds/components-community.data-grid 0.1.1 → 1.0.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,34 @@
1
1
  # Change Log - @telus-uds/components-community.data-grid
2
2
 
3
- This log was last generated on Fri, 10 Jan 2025 21:41:25 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 31 Jan 2025 20:49:19 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.0.0
8
+
9
+ Fri, 31 Jan 2025 20:49:19 GMT
10
+
11
+ ### Major changes
12
+
13
+ - Add CommonJS builds along with ESM (shahzaibkhalidmalik@outlook.com)
14
+ - Bump @telus-uds/components-web to v4.0.0
15
+ - Bump @telus-uds/components-base to v3.0.0
16
+ - Bump @telus-uds/system-theme-tokens to v4.0.0
17
+ - Bump @telus-uds/browserslist-config to v1.0.5
18
+
19
+ ## 0.1.2
20
+
21
+ Wed, 22 Jan 2025 21:08:36 GMT
22
+
23
+ ### Patches
24
+
25
+ - Bump @telus-uds/components-web to v3.4.0
26
+ - Bump @telus-uds/components-base to v2.5.0
27
+ - Bump @telus-uds/browserslist-config to v1.0.5
28
+
7
29
  ## 0.1.1
8
30
 
9
- Fri, 10 Jan 2025 21:41:25 GMT
31
+ Fri, 10 Jan 2025 21:49:25 GMT
10
32
 
11
33
  ### Patches
12
34
 
package/jest.config.cjs CHANGED
@@ -9,7 +9,7 @@ module.exports = () => ({
9
9
  '.+\\.(otf|png|jpg)$': 'identity-obj-proxy',
10
10
  '\\.icon.svg': '<rootDir>/__mocks__/iconMock.jsx',
11
11
  '\\.css': '<rootDir>/__mocks__/styleMock.js',
12
- '^@telus-uds/components-base/server$': '<rootDir>/../../../components-base/lib/server.js'
12
+ '^@telus-uds/components-base/server$': '<rootDir>/../../../components-base/lib/cjs/server.js'
13
13
  },
14
14
  setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
15
15
  transformIgnorePatterns: [
@@ -0,0 +1,369 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.StyledIconContainer = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _componentsBase = require("@telus-uds/components-base");
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+ var _dictionary = _interopRequireDefault(require("./dictionary"));
12
+ var _utility = require("./utility");
13
+ var _DataGridTable = _interopRequireDefault(require("./DataGridTable"));
14
+ var _DataGridHead = _interopRequireDefault(require("./DataGridHead"));
15
+ var _DataGridBody = _interopRequireDefault(require("./DataGridBody"));
16
+ var _DataGridRow = _interopRequireDefault(require("./DataGridRow"));
17
+ var _DataGridCell = _interopRequireDefault(require("./DataGridCell"));
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ const StyledIconContainer = exports.StyledIconContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
21
+ displayName: "DataGrid__StyledIconContainer",
22
+ componentId: "[object Object]__sc-1ddcmt-0"
23
+ })(["display:flex;box-sizing:border-box;align-items:center;width:60px;justify-content:space-between;"]);
24
+ const DataGrid = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
25
+ let {
26
+ rows = [],
27
+ columns = [],
28
+ groupedRows,
29
+ showCheckbox = false,
30
+ isSortable = false,
31
+ makeScrollBarAlwaysVisible = true,
32
+ tokens,
33
+ variant,
34
+ copy = 'en',
35
+ testID = 'data-grid'
36
+ } = _ref;
37
+ const themeTokens = (0, _componentsBase.useThemeTokens)('DataGrid', tokens, variant);
38
+ const getCopy = (0, _componentsBase.useCopy)({
39
+ dictionary: _dictionary.default,
40
+ copy
41
+ });
42
+ const {
43
+ expandRowIcon,
44
+ hideExpandedRowIcon,
45
+ sortColumnIconDown,
46
+ sortColumnIconUp
47
+ } = themeTokens;
48
+ const [data, setData] = _react.default.useState(groupedRows ? (0, _utility.resetRowData)([...groupedRows], true) : (0, _utility.resetRowData)([...rows]));
49
+ const [columnsData, setColumnsData] = _react.default.useState((0, _utility.resetColumnsData)(columns));
50
+ const [checkAllState, setCheckAllState] = _react.default.useState(false);
51
+ const shouldCheckHeaderBox = allData => {
52
+ let isARowUnselectedInAllGroups = null;
53
+ if (groupedRows) {
54
+ isARowUnselectedInAllGroups = Object.keys(allData).some(el => {
55
+ return (0, _utility.isAtLeastOneRowUnselected)(allData[el].data);
56
+ });
57
+ } else {
58
+ isARowUnselectedInAllGroups = (0, _utility.isAtLeastOneRowUnselected)(allData);
59
+ }
60
+ return !isARowUnselectedInAllGroups;
61
+ };
62
+ const shouldDisplayIconColumn = (allData, _showCheckbox) => {
63
+ let doesOneRowHaveExpandedContent = null;
64
+ if (groupedRows) {
65
+ doesOneRowHaveExpandedContent = Object.keys(allData).some(el => {
66
+ return allData[el].data.some(eachData => eachData.hasExpandedRow === true);
67
+ });
68
+ } else {
69
+ doesOneRowHaveExpandedContent = allData.some(el => el.hasExpandedRow === true);
70
+ }
71
+ return !!(_showCheckbox || doesOneRowHaveExpandedContent);
72
+ };
73
+ const toggleSelectAll = () => {
74
+ let _rows = null;
75
+ if (groupedRows) {
76
+ _rows = {};
77
+ Object.keys(data).forEach(el => {
78
+ _rows[el] = {
79
+ ...data[el]
80
+ };
81
+ _rows[el].data = (0, _utility.toggleAllCheckBoxes)(data[el].data, checkAllState);
82
+ });
83
+ } else {
84
+ _rows = (0, _utility.toggleAllCheckBoxes)(data, checkAllState);
85
+ }
86
+ setData(_rows);
87
+ setCheckAllState(!checkAllState);
88
+ };
89
+ const toggleCheckbox = rowId => {
90
+ let _data = null;
91
+ if (groupedRows) {
92
+ const [group, _] = rowId.split('-');
93
+ const id = parseInt(_, 10);
94
+ _data = {
95
+ ...data
96
+ };
97
+ _data[group].data = (0, _utility.toggleRowCheckbox)(_data[group].data, id);
98
+ } else {
99
+ _data = (0, _utility.toggleRowCheckbox)(data, rowId);
100
+ }
101
+ setData(_data);
102
+ };
103
+ const toggleRowExpansion = rowId => {
104
+ let _row = null;
105
+ if (groupedRows) {
106
+ const [group, _] = rowId.split('-');
107
+ const id = parseInt(_, 10);
108
+ _row = {
109
+ ...data
110
+ };
111
+ _row[group].data = (0, _utility.toggleExpandedRow)(_row[group].data, id);
112
+ } else {
113
+ _row = (0, _utility.toggleExpandedRow)(data, rowId);
114
+ }
115
+ setData(_row);
116
+ };
117
+ const HeaderCheckBoxDisplay = showCheckbox && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Checkbox, {
118
+ label: getCopy('all'),
119
+ checked: shouldCheckHeaderBox(data),
120
+ onChange: toggleSelectAll
121
+ });
122
+ const buildCheckBoxDisplay = (_showCheckbox, row, rowId) => _showCheckbox && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Checkbox, {
123
+ checked: row.isSelected,
124
+ onChange: () => toggleCheckbox(rowId)
125
+ });
126
+ const buildDisplayCaret = (row, rowId) => row.hasExpandedRow && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.IconButton, {
127
+ onPress: () => toggleRowExpansion(rowId),
128
+ icon: row.isExpandedRowOpen === true ? hideExpandedRowIcon : expandRowIcon,
129
+ accessibilityRole: `button-${rowId}`,
130
+ accessibilityLabel: row.isExpandedRowOpen === true ? getCopy('hideRow') : getCopy('expandRow')
131
+ });
132
+ const buildExpandedRow = (row, rowId) => row.isExpandedRowOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridRow.default, {
133
+ type: _utility.ROW_TYPE.EXPANDEDROW,
134
+ tokens: themeTokens,
135
+ rowId: rowId,
136
+ isExpandedRowOpen: row.isExpandedRowOpen,
137
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
138
+ type: _utility.CELL_TYPE.EXPANDEDROWCELL,
139
+ tokens: themeTokens,
140
+ columnsLength: columns.length,
141
+ showCheckbox: showCheckbox,
142
+ isExpandedRowOpen: row.isExpandedRowOpen,
143
+ children: row.expandedRowChildComponent.component
144
+ })
145
+ });
146
+ const buildRowContent = (row, rowId, _showCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
147
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_DataGridRow.default, {
148
+ tokens: themeTokens,
149
+ rowId: rowId,
150
+ isExpandedRowOpen: row.isExpandedRowOpen,
151
+ hasExpandedContent: row.hasExpandedRow,
152
+ onClick: toggleRowExpansion,
153
+ children: [shouldDisplayIconColumn(data, _showCheckbox) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
154
+ tokens: themeTokens,
155
+ isExpandedRowOpen: row.isExpandedRowOpen,
156
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledIconContainer, {
157
+ children: [CheckBoxDisplay, DisplayCaret]
158
+ })
159
+ }), columnsData.map(column => /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
160
+ tokens: themeTokens,
161
+ isExpandedRowOpen: row.isExpandedRowOpen,
162
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
163
+ block: true,
164
+ variant: {
165
+ size: 'small'
166
+ },
167
+ tokens: {
168
+ color: themeTokens.cellTextColor
169
+ },
170
+ children: row[column.key]
171
+ })
172
+ }, `${rowId}-${column.key}`))]
173
+ }, rowId), ExpandedRow]
174
+ }, rowId);
175
+ const sortColumn = column => {
176
+ const _col = {
177
+ ...column
178
+ };
179
+ if (!groupedRows) {
180
+ const _data = [...data].sort((a, b) => {
181
+ const first = _col.dataType === _utility.DATA_TYPE.NUMBER ? parseFloat(a[_col.key]) : a[_col.key].toUpperCase();
182
+ const next = _col.dataType === _utility.DATA_TYPE.NUMBER ? parseFloat(b[_col.key]) : b[_col.key].toUpperCase();
183
+ if (_col.sortDirection === _utility.SORT_DIRECTION.DESC) {
184
+ if (first < next) return -1;
185
+ return next === first ? 0 : 1;
186
+ }
187
+ if (next < first) return -1;
188
+ return first === next ? 0 : 1;
189
+ });
190
+ _col.sortDirection = _col.sortDirection === _utility.SORT_DIRECTION.DESC ? _utility.SORT_DIRECTION.ASC : _utility.SORT_DIRECTION.DESC;
191
+ _col.currentSort = true;
192
+ const _columns = (0, _utility.resetColumnsData)(columnsData);
193
+ _columns[columnsData.findIndex(_el => _el.key === column.key)] = _col;
194
+ setColumnsData(_columns);
195
+ setData(_data);
196
+ }
197
+ };
198
+ let HeaderContent = null;
199
+ let BodyContent = null;
200
+ if (groupedRows) {
201
+ BodyContent = Object.keys(data).map(group => {
202
+ const DefaultSubHeading = /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
203
+ variant: {
204
+ size: 'h3'
205
+ },
206
+ children: data[group].name
207
+ });
208
+ const GroupHeaderRow = /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridRow.default, {
209
+ type: _utility.ROW_TYPE.EXPANDEDROW,
210
+ tokens: themeTokens,
211
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
212
+ type: _utility.CELL_TYPE.SUBHEADING,
213
+ tokens: themeTokens,
214
+ columnsLength: columnsData.length,
215
+ children: data[group].groupHeaderComponent || DefaultSubHeading
216
+ })
217
+ }, group);
218
+ const DataRow = data[group].data.map(row => {
219
+ const rowId = `${group}-${row.id}`;
220
+ const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId);
221
+ const DisplayCaret = buildDisplayCaret(row, rowId);
222
+ const ExpandedRow = buildExpandedRow(row, rowId);
223
+ return buildRowContent(row, rowId, showCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow);
224
+ });
225
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
226
+ children: [GroupHeaderRow, DataRow]
227
+ }, group);
228
+ });
229
+ } else {
230
+ BodyContent = data.map(row => {
231
+ const rowId = row.id;
232
+ const CheckBoxDisplay = buildCheckBoxDisplay(showCheckbox, row, rowId);
233
+ const DisplayCaret = buildDisplayCaret(row, rowId);
234
+ const ExpandedRow = buildExpandedRow(row, rowId);
235
+ return buildRowContent(row, rowId, showCheckbox, CheckBoxDisplay, DisplayCaret, ExpandedRow);
236
+ });
237
+ }
238
+ HeaderContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
239
+ children: [shouldDisplayIconColumn(data, showCheckbox) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridCell.default, {
240
+ type: _utility.CELL_TYPE.HEADING,
241
+ tokens: themeTokens,
242
+ isFirstCol: true,
243
+ children: HeaderCheckBoxDisplay
244
+ }), columnsData.map(column => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_DataGridCell.default, {
245
+ type: _utility.CELL_TYPE.HEADING,
246
+ tokens: themeTokens,
247
+ isSortable: isSortable,
248
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
249
+ block: true,
250
+ variant: {
251
+ size: 'h4'
252
+ },
253
+ tokens: {
254
+ color: themeTokens.headerTextColor
255
+ },
256
+ children: column.label
257
+ }), isSortable && column.isSortable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.IconButton, {
258
+ variant: {
259
+ size: 'small'
260
+ },
261
+ tokens: {
262
+ iconColor: column.currentSort ? themeTokens.sortColumnIconActiveColor : themeTokens.sortColumnIconDefaultColor
263
+ },
264
+ onPress: () => {
265
+ if (typeof column.fn === 'function') {
266
+ column.fn(column, data, setData, columnsData, setColumnsData);
267
+ } else sortColumn(column);
268
+ },
269
+ icon: column.sortDirection === _utility.SORT_DIRECTION.ASC ? sortColumnIconUp : sortColumnIconDown,
270
+ accessibilityRole: "sort-button",
271
+ accessibilityLabel: getCopy('button')
272
+ })]
273
+ }, column.key))]
274
+ });
275
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridTable.default, {
276
+ tokens: themeTokens,
277
+ makeScrollBarAlwaysVisible: makeScrollBarAlwaysVisible,
278
+ ref: ref,
279
+ testID: testID,
280
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
281
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridHead.default, {
282
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridRow.default, {
283
+ type: _utility.ROW_TYPE.HEADING,
284
+ children: HeaderContent
285
+ })
286
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DataGridBody.default, {
287
+ children: BodyContent
288
+ })]
289
+ })
290
+ });
291
+ });
292
+ DataGrid.displayName = 'DataGrid';
293
+ DataGrid.propTypes = {
294
+ /**
295
+ * Use `columns` to pass the data for data-grid column header items.
296
+ */
297
+ columns: _propTypes.default.arrayOf(_propTypes.default.shape({
298
+ key: _propTypes.default.string.isRequired,
299
+ label: _propTypes.default.string.isRequired,
300
+ width: _propTypes.default.string,
301
+ dataType: _propTypes.default.oneOf(['string', 'number']),
302
+ isSortable: _propTypes.default.bool,
303
+ // Set this to true to enable sorting for this column
304
+ fn: _propTypes.default.func
305
+ })).isRequired,
306
+ /**
307
+ * Use `groupedRows` to pass the grouped data for display
308
+ */
309
+ groupedRows: _propTypes.default.arrayOf(_propTypes.default.shape({
310
+ key: _propTypes.default.string.isRequired,
311
+ name: _propTypes.default.string.isRequired,
312
+ groupHeaderComponent: _propTypes.default.node,
313
+ data: _propTypes.default.arrayOf(_propTypes.default.shape({
314
+ id: _propTypes.default.number.isRequired,
315
+ expandedRow: _propTypes.default.shape({
316
+ rows: _propTypes.default.arrayOf(_propTypes.default.shape({
317
+ id: _propTypes.default.number.isRequired
318
+ })),
319
+ columns: _propTypes.default.arrayOf(_propTypes.default.shape({
320
+ key: _propTypes.default.string.isRequired,
321
+ label: _propTypes.default.string.isRequired
322
+ }))
323
+ }),
324
+ expandedRowChildComponent: _propTypes.default.shape({
325
+ component: _propTypes.default.node,
326
+ displayOnLoad: _propTypes.default.bool.isRequired
327
+ })
328
+ }))
329
+ })),
330
+ /**
331
+ * Use `rows` to pass ungrouped data for data-grid row cells items.
332
+ */
333
+ rows: _propTypes.default.arrayOf(_propTypes.default.shape({
334
+ id: _propTypes.default.number.isRequired,
335
+ expandedRowChildComponent: _propTypes.default.shape({
336
+ component: _propTypes.default.node,
337
+ displayOnLoad: _propTypes.default.bool.isRequired
338
+ })
339
+ })),
340
+ /**
341
+ * Set this to true to enable columns to become sortable.
342
+ */
343
+ isSortable: _propTypes.default.bool,
344
+ /**
345
+ * Set this to true to make scrollbar always visible when content is larger than the grid
346
+ */
347
+ makeScrollBarAlwaysVisible: _propTypes.default.bool,
348
+ /**
349
+ * Set this to true to enable checkboxes in the first column.
350
+ */
351
+ showCheckbox: _propTypes.default.bool,
352
+ /**
353
+ * Use tokens prop to override theme tokens
354
+ */
355
+ tokens: _propTypes.default.object,
356
+ /**
357
+ * No available variants
358
+ */
359
+ variant: _componentsBase.variantProp.propType,
360
+ /**
361
+ * Use copy for localisations of keys.
362
+ */
363
+ copy: _propTypes.default.oneOf(['en', 'fr']),
364
+ /**
365
+ * Use in tests if the datagrid test cases need to find the element with the id.
366
+ */
367
+ testID: _propTypes.default.string
368
+ };
369
+ var _default = exports.default = DataGrid;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const DataGridBody = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
12
+ let {
13
+ children
14
+ } = _ref;
15
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
16
+ ref: ref,
17
+ children: children
18
+ });
19
+ });
20
+ DataGridBody.displayName = 'DataGridBody';
21
+ DataGridBody.propTypes = {
22
+ /**
23
+ * Accepts any React or HTML node
24
+ */
25
+ children: _propTypes.default.node.isRequired
26
+ };
27
+ var _default = exports.default = DataGridBody;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.StyledCell = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
10
+ var _utility = require("./utility");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ const StyledHeaderCell = /*#__PURE__*/_styledComponents.default.th.withConfig({
16
+ displayName: "DataGridCell__StyledHeaderCell",
17
+ componentId: "[object Object]__sc-6nkvhz-0"
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);
20
+ });
21
+ const StyledHeaderCellDiv = /*#__PURE__*/_styledComponents.default.div.withConfig({
22
+ displayName: "DataGridCell__StyledHeaderCellDiv",
23
+ componentId: "[object Object]__sc-6nkvhz-1"
24
+ })(["display:flex;align-items:center;"]);
25
+ const StyledGroupHeaderCell = /*#__PURE__*/_styledComponents.default.td.withConfig({
26
+ displayName: "DataGridCell__StyledGroupHeaderCell",
27
+ componentId: "[object Object]__sc-6nkvhz-2"
28
+ })(["", ""], props => {
29
+ return (0, _styledComponents.css)(["background-color:", ";padding:", "px;border-top:solid ", "px ", ";text-align:", ";font-size:", "px;font-weight:normal;line-height:", "px;color:", ";font-family:", ";"], props.subHeadingBackgroundColor, props.cellPadding, props.cellBorderBottomWidth, props.cellBorderBottomColor, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily);
30
+ });
31
+ const StyledGroupHeaderCellDiv = /*#__PURE__*/_styledComponents.default.div.withConfig({
32
+ displayName: "DataGridCell__StyledGroupHeaderCellDiv",
33
+ componentId: "[object Object]__sc-6nkvhz-3"
34
+ })(["display:flex;align-items:center;justify-content:start;"]);
35
+ const StyledExpandedCell = /*#__PURE__*/_styledComponents.default.td.withConfig({
36
+ displayName: "DataGridCell__StyledExpandedCell",
37
+ componentId: "[object Object]__sc-6nkvhz-4"
38
+ })(["", ""], props => {
39
+ 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.isExpandedRowOpen ? `solid ${props.cellBorderBottomWidth}px ${props.headerBorderBottomColor};` : `solid ${props.cellBorderBottomWidth}px ${props.cellBorderBottomColor};`, props.cellTextAlign, props.cellFontSize, props.cellLineHeight * props.cellFontSize, props.cellTextColor, props.cellFontFamily);
40
+ });
41
+ const StyledExpandedCellDiv = /*#__PURE__*/_styledComponents.default.div.withConfig({
42
+ displayName: "DataGridCell__StyledExpandedCellDiv",
43
+ componentId: "[object Object]__sc-6nkvhz-5"
44
+ })(["", ""], props => {
45
+ return (0, _styledComponents.css)(["display:flex;align-items:center;justify-content:", ";padding-left:", ";"], props.expandedContentAlignment ? props.expandedContentAlignment : 'start', props.showCheckbox ? `${props.expandedContentLeftPadding}px` : `${props.expandedContentDefaultLeftPadding}px`);
46
+ });
47
+ const StyledCell = exports.StyledCell = /*#__PURE__*/_styledComponents.default.td.withConfig({
48
+ displayName: "DataGridCell__StyledCell",
49
+ componentId: "[object Object]__sc-6nkvhz-6"
50
+ })(["", ""], props => {
51
+ if (props.isExpandedRowOpen) {
52
+ 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);
53
+ }
54
+ 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);
55
+ });
56
+ const DataGridCell = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
57
+ let {
58
+ children,
59
+ tokens,
60
+ type,
61
+ columnsLength,
62
+ showCheckbox = false,
63
+ isFirstCol = false,
64
+ isExpandedRowOpen = false
65
+ } = _ref;
66
+ if (type === _utility.CELL_TYPE.HEADING) {
67
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledHeaderCell, {
68
+ ...tokens,
69
+ firstColWidth: isFirstCol ? tokens.firstColWidth : 'auto',
70
+ ref: ref,
71
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledHeaderCellDiv, {
72
+ children: children
73
+ })
74
+ });
75
+ }
76
+ if (type === _utility.CELL_TYPE.SUBHEADING) {
77
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGroupHeaderCell, {
78
+ colSpan: columnsLength + 1,
79
+ ...tokens,
80
+ ref: ref,
81
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledGroupHeaderCellDiv, {
82
+ ...tokens,
83
+ children: children
84
+ })
85
+ });
86
+ }
87
+ if (type === _utility.CELL_TYPE.EXPANDEDROWCELL) {
88
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledExpandedCell, {
89
+ colSpan: columnsLength + 1,
90
+ ...tokens,
91
+ isExpandedRowOpen: isExpandedRowOpen,
92
+ ref: ref,
93
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledExpandedCellDiv, {
94
+ showCheckbox: showCheckbox,
95
+ ...tokens,
96
+ children: children
97
+ })
98
+ });
99
+ }
100
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledCell, {
101
+ ...tokens,
102
+ isExpandedRowOpen: isExpandedRowOpen,
103
+ ref: ref,
104
+ children: children
105
+ });
106
+ });
107
+ DataGridCell.displayName = 'DataGridCell';
108
+ DataGridCell.propTypes = {
109
+ /**
110
+ cell type
111
+ */
112
+ type: _propTypes.default.oneOf(['heading', 'subHeading', 'expandedRowCell']),
113
+ /**
114
+ * Accepts any React or HTML node
115
+ */
116
+ children: _propTypes.default.node,
117
+ /**
118
+ * Tokens passed to the component
119
+ */
120
+ tokens: _propTypes.default.object,
121
+ /**
122
+ * columnsLength passed to the component for certain scenarios in which colSpan is required
123
+ */
124
+ columnsLength: _propTypes.default.number,
125
+ /**
126
+ * showCheckbox passed to the component for certain scenarios in which checkbox visibility impacts the display design
127
+ */
128
+ showCheckbox: _propTypes.default.bool,
129
+ /**
130
+ * isFirstCol passed to the component to determine if cell is first within the row
131
+ */
132
+ isFirstCol: _propTypes.default.bool,
133
+ /**
134
+ * isExpandedRowOpen passed to the component to determine if cell is displaying additional data
135
+ */
136
+ isExpandedRowOpen: _propTypes.default.bool
137
+ };
138
+ var _default = exports.default = DataGridCell;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ const DataGridHead = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
12
+ let {
13
+ children
14
+ } = _ref;
15
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
16
+ ref: ref,
17
+ children: children
18
+ });
19
+ });
20
+ DataGridHead.displayName = 'DataGridHead';
21
+ DataGridHead.propTypes = {
22
+ /**
23
+ * Accepts any React or HTML node
24
+ */
25
+ children: _propTypes.default.node
26
+ };
27
+ var _default = exports.default = DataGridHead;