@commercetools-uikit/data-table 16.0.0 → 16.1.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.
@@ -54,174 +54,139 @@ const getPaddingStyle = props => {
54
54
  if (props.isCondensed) return /*#__PURE__*/react.css("padding:", designSystem.designTokens.paddingForTableCellAsCondensed, ";" + ("" ), "" );
55
55
  return /*#__PURE__*/react.css("padding:", designSystem.designTokens.paddingForTableCell, ";" + ("" ), "" );
56
56
  };
57
-
58
57
  var _ref8 = {
59
58
  name: "9nkbgg",
60
59
  styles: "text-align:left;justify-self:flex-start"
61
60
  } ;
62
-
63
61
  var _ref9 = {
64
62
  name: "1p06wbt",
65
63
  styles: "text-align:right;justify-self:flex-end"
66
64
  } ;
67
-
68
65
  var _ref10 = {
69
66
  name: "weshh4",
70
67
  styles: "text-align:center;justify-self:center"
71
68
  } ;
72
-
73
69
  const getHorizontalAlignmentStyle = props => {
74
70
  if (props.horizontalCellAlignment === 'center') {
75
71
  return _ref10;
76
72
  }
77
-
78
73
  if (props.horizontalCellAlignment === 'right') {
79
74
  return _ref9;
80
75
  }
81
-
82
76
  return _ref8;
83
77
  };
84
-
85
78
  var _ref5 = {
86
79
  name: "xyzkeb",
87
80
  styles: "align-self:flex-start"
88
81
  } ;
89
-
90
82
  var _ref6 = {
91
83
  name: "1duj7gx",
92
84
  styles: "align-self:flex-end"
93
85
  } ;
94
-
95
86
  var _ref7 = {
96
87
  name: "qbt5ty",
97
88
  styles: "align-self:center"
98
89
  } ;
99
-
100
90
  const getVerticalAlignmentStyle = props => {
101
91
  if (props.verticalCellAlignment === 'center') {
102
92
  return _ref7;
103
93
  }
104
-
105
94
  if (props.verticalCellAlignment === 'bottom') {
106
95
  return _ref6;
107
96
  }
108
-
109
97
  return _ref5;
110
98
  };
111
-
112
99
  var _ref4 = {
113
100
  name: "ucb1au",
114
101
  styles: "overflow:hidden;white-space:nowrap;text-overflow:ellipsis"
115
102
  } ;
116
-
117
103
  const getTruncatedStyle = props => {
118
104
  if (props.isTruncated) {
119
105
  return _ref4;
120
106
  }
121
-
122
107
  return '';
123
108
  };
109
+
124
110
  /* the :focus-within state doesn't enable the outline styles,
125
111
  so we have to set them manually. */
126
-
127
-
128
112
  const outlineStyles = {
129
113
  name: "1oudntj",
130
114
  styles: "outline-offset:-3px;:not(:focus):focus-within{outline-style:auto;outline-color:Highlight;outline-color:activeborder;outline-color:-moz-mac-focusring;outline-color:-webkit-focus-ring-color;}"
131
115
  } ;
132
-
133
116
  const getCellInnerStyles = props => {
134
117
  return [getVerticalAlignmentStyle(props), getHorizontalAlignmentStyle(props), getTruncatedStyle(props), outlineStyles];
135
118
  };
119
+
136
120
  /**
137
121
  * The `shouldClipContent` overflow rule should only be enabled upon manual column resizing,
138
122
  * otherwise it will change the way css-grid automatically allocates space for the cells of the table,
139
123
  * preferring to clip the cells instead and adding horizontal scrollbar to the table container
140
124
  */
141
-
142
-
143
125
  var _ref3 = {
144
126
  name: "d3v9zr",
145
127
  styles: "overflow:hidden"
146
128
  } ;
147
-
148
129
  const CellInner = /*#__PURE__*/_styled__default["default"]("div", {
149
130
  target: "e10u1n7e3"
150
131
  } )("box-sizing:border-box;flex:1;", getPaddingStyle, " ", getCellInnerStyles, " ", props => props.shouldClipContent ? _ref3 : '', ";" + ("" ));
151
-
152
132
  var _ref$1 = {
153
133
  name: "1a5erbp",
154
134
  styles: "cursor:auto"
155
135
  } ;
156
-
157
136
  var _ref2 = {
158
137
  name: "d3v9zr",
159
138
  styles: "overflow:hidden"
160
139
  } ;
161
-
162
140
  const BaseCell = /*#__PURE__*/_styled__default["default"]("td", {
163
141
  target: "e10u1n7e2"
164
142
  } )("position:relative;display:flex;background-color:", designSystem.designTokens.colorSurface, ";border-bottom:", props => props.shouldRenderBottomBorder ? "1px solid ".concat(designSystem.designTokens.colorNeutral90, ";") : 'none', ";font-size:", designSystem.designTokens.fontSizeForTable, ";", props => props.shouldClipContent ? _ref2 : '', " ", props => props.shouldIgnoreRowClick ? _ref$1 : '', ";" + ("" ));
165
-
166
143
  /*#__PURE__*/_styled__default["default"]("td", {
167
144
  target: "e10u1n7e1"
168
145
  } )("position:", props => props.disableFooterStickiness ? 'relative' : 'sticky', ";left:0;bottom:0;grid-column:1/", props => props.numberOfColumns, ";background-color:", designSystem.designTokens.colorSurface, ";border-bottom:1px solid ", designSystem.designTokens.colorNeutral90, ";border-top:1px solid ", designSystem.designTokens.colorNeutral90, ";margin-top:-1px;" + ("" ));
169
-
170
146
  const RowExpandCollapseButton = /*#__PURE__*/_styled__default["default"](AccessibleButton__default["default"], {
171
147
  target: "e10u1n7e0"
172
148
  } )("cursor:", props => props.isRowCollapsed ? /*#__PURE__*/react.css("" , "" ) : /*#__PURE__*/react.css("" , "" ), ";position:absolute;height:16px;width:16px;bottom:0;right:0;opacity:0;display:flex;justify-content:flex-end;align-items:flex-end;" + ("" ));
173
149
 
174
150
  const convertNumericDimensionToPixelValue = dimensionValue => typeof dimensionValue === 'number' ? "".concat(dimensionValue, "px") : dimensionValue;
175
-
176
151
  var convertNumericDimensionToPixelValue$1 = convertNumericDimensionToPixelValue;
177
152
 
178
153
  const getClickableRowStyle = props => {
179
154
  if (props.isRowClickable) {
180
155
  return /*#__PURE__*/react.css("cursor:pointer;&:hover td{background:", designSystem.designTokens.backgroundColorForTableCellWhenHovered, ";}" + ("" ), "" );
181
156
  }
182
-
183
157
  return '';
184
158
  };
185
-
186
159
  var _ref = {
187
160
  name: "1jff5cf",
188
161
  styles: "position:unset;overflow-x:unset;overflow-y:unset"
189
162
  } ;
190
-
191
163
  const getDisabledSelfContainmentStyles = props => {
192
164
  if (props.disableSelfContainment) {
193
165
  return _ref;
194
166
  }
195
-
196
167
  return '';
197
168
  };
198
-
199
169
  const TableContainer = /*#__PURE__*/_styled__default["default"]("div", {
200
170
  target: "epk01s24"
201
171
  } )("position:relative;z-index:0;overflow-x:auto;", props => props.maxWidth && !props.disableSelfContainment ? "max-width: ".concat(convertNumericDimensionToPixelValue$1(props.maxWidth), ";") : '', " ", props => props.isBeingResized && "\n * {\n user-select: none;\n }", " ", getDisabledSelfContainmentStyles, ";" + ("" ));
202
-
203
172
  const TableGrid = /*#__PURE__*/_styled__default["default"]("table", {
204
173
  target: "epk01s23"
205
174
  } )("display:grid;grid-template-columns:", props => {
206
175
  var _context;
207
-
208
176
  return props.columns && _mapInstanceProperty__default["default"](_context = props.columns).call(_context, column => column.width || 'auto').join(' ');
209
177
  }, ";overflow-y:auto;", props => props.maxHeight && !props.disableSelfContainment ? "max-height: ".concat(convertNumericDimensionToPixelValue$1(props.maxHeight), ";") : '', " ", props => props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '', " ", getDisabledSelfContainmentStyles, ";" + ("" ));
210
-
211
178
  const TableHeader = /*#__PURE__*/_styled__default["default"]("thead", {
212
179
  target: "epk01s22"
213
180
  } )({
214
181
  name: "49aokf",
215
182
  styles: "display:contents"
216
183
  } );
217
-
218
184
  const TableBody = /*#__PURE__*/_styled__default["default"]("tbody", {
219
185
  target: "epk01s21"
220
186
  } )({
221
187
  name: "49aokf",
222
188
  styles: "display:contents"
223
189
  } );
224
-
225
190
  const TableRow = /*#__PURE__*/_styled__default["default"]("tr", {
226
191
  target: "epk01s20"
227
192
  } )("display:contents;", getClickableRowStyle, " :hover,:focus-within{", RowExpandCollapseButton, "{opacity:1;}}" + ("" ));
@@ -229,16 +194,15 @@ const TableRow = /*#__PURE__*/_styled__default["default"]("tr", {
229
194
  const defaultProps$4 = {
230
195
  horizontalCellAlignment: 'left'
231
196
  };
232
-
233
197
  const Footer = /*#__PURE__*/_styled__default["default"]("div", {
234
198
  target: "e2ce7vj0"
235
199
  } )("box-sizing:border-box;display:block;", getPaddingStyle, " ", getHorizontalAlignmentStyle, " background-color:", designSystem.designTokens.colorSurface, ";border-top:1px solid ", designSystem.designTokens.colorNeutral90, ";border-bottom:1px solid ", designSystem.designTokens.colorNeutral90, ";", props => props.resizedTotalWidth ? "max-width: ".concat(props.resizedTotalWidth, "px;") : '', ";" + ("" ));
236
-
237
200
  Footer.displayName = 'Footer';
238
201
  Footer.defaultProps = defaultProps$4;
239
202
  var Footer$1 = Footer;
240
203
 
241
204
  const getButtonStyle = () => /*#__PURE__*/react.css("cursor:pointer;border:none;background:none;text-decoration:none;color:inherit;font:inherit;font-size:", designSystem.designTokens.fontSizeForTable, ";font-family:inherit;" + ("" ), "" );
205
+
242
206
  /* A sortable header has the two arrow svg icons
243
207
  * GIVEN column is sortable and is not focused
244
208
  * THEN AngleUpDown icon is shown (default behaviour)
@@ -249,21 +213,16 @@ const getButtonStyle = () => /*#__PURE__*/react.css("cursor:pointer;border:none;
249
213
  * AND AngleUp or AngleDown icon is shown
250
214
  */
251
215
 
252
-
253
216
  const getSortableHeaderStyles = props => /*#__PURE__*/react.css("width:100%;display:flex;align-items:center;svg[data-icon-state='inactive'],svg[data-icon-state='active']{margin-left:", designSystem.designTokens.spacing20, ";flex-shrink:0;}svg[data-icon-state='inactive']{display:", props.isActive ? 'none' : 'inline-block', ";}svg[data-icon-state='active']{display:", props.isActive ? 'inline-block' : 'none', ";}>svg *{fill:", designSystem.designTokens.fontColorForTableHeader, "!important;}:hover,:focus{svg[data-icon-state='inactive']{display:none;}svg[data-icon-state='active']{display:inline-block;}}" + ("" ), "" );
254
-
255
217
  const HeaderCellInner = /*#__PURE__*/_styled__default["default"]("div", {
256
218
  target: "e1ipt8n23"
257
219
  } )("box-sizing:border-box;display:flex;justify-content:space-between;padding:0 ", props => props.isCondensed ? designSystem.designTokens.paddingForTableHeaderAsCondensed : designSystem.designTokens.paddingForTableHeader, ";", getCellInnerStyles, " ", props => props.isSortable ? getSortableHeaderStyles(props) : '', ";", props => props.as === 'button' ? getButtonStyle() : '', ";", props => props.shouldWrap ? '' : 'white-space: nowrap', ";" + ("" ));
258
-
259
220
  const BaseHeaderCell = /*#__PURE__*/_styled__default["default"]("th", {
260
221
  target: "e1ipt8n22"
261
222
  } )("color:", designSystem.designTokens.fontColorForTableHeader, ";background-color:", designSystem.designTokens.backgroundColorForTableHeader, ";position:", props => props.disableHeaderStickiness ? 'relative' : 'sticky', ";top:0;z-index:1;line-height:", designSystem.designTokens.lineHeightForTableHeader, ";padding:0;font-weight:", designSystem.designTokens.fontWeightForTableHeader, ";font-size:", designSystem.designTokens.fontSizeForTable, ";box-shadow:inset -1px 0 ", designSystem.designTokens.borderColorForTableHeader, ";:hover,:active{z-index:2;}", props => !props.isNewTheme && ":before {\n content: '';\n position: absolute;\n z-index: -1;\n width: 100%;\n height: 1px;\n bottom: 0;\n left: 0;\n background-color: ".concat(designSystem.designTokens.borderColorForTableHeaderAsBottom, ";\n };"), " ", HeaderCellInner, "{", props => props.shouldClipContent ? 'overflow: hidden;' : '', ";}" + ("" ));
262
-
263
223
  const HeaderLabelWrapper = /*#__PURE__*/_styled__default["default"]("div", {
264
224
  target: "e1ipt8n21"
265
225
  } )("min-height:1.4em;margin:", designSystem.designTokens.marginForTableHeader, " 0;flex:1;" + ("" ));
266
-
267
226
  const HeaderIconWrapper = /*#__PURE__*/_styled__default["default"]("div", {
268
227
  target: "e1ipt8n20"
269
228
  } )("display:inline-flex;align-items:center;justify-content:center;margin-left:", designSystem.designTokens.spacing20, ";vertical-align:middle;" + ("" ));
@@ -272,11 +231,9 @@ const ResizerIndicator = /*#__PURE__*/_styled__default["default"]("div", {
272
231
  target: "e1ccic7f1"
273
232
  } )("height:100%;width:3px;background:", designSystem.designTokens.colorInfo, ";visibility:hidden;cursor:col-resize;", (props // extra 1px of height to appear above the bottom horizontal row border
274
233
  ) => props.isOnDataCell ? 'visibility: visible; height: calc(100% + 1px);' : '', ";" + ("" ));
275
-
276
234
  const DraggableArea = /*#__PURE__*/_styled__default["default"]("div", {
277
235
  target: "e1ccic7f0"
278
236
  } )("display:flex;justify-content:flex-end;height:100%;position:absolute;top:0;right:0;width:6px;cursor:col-resize;user-select:none;&:hover ", ResizerIndicator, "{height:100%;visibility:visible;}&:active{width:20px;right:-10px;", ResizerIndicator, "{margin-right:10px;visibility:visible;}}" + ("" ));
279
-
280
237
  const ColumnResizer = props => jsxRuntime.jsx(DraggableArea, {
281
238
  role: "presentation",
282
239
  onMouseDown: props.onMouseDown,
@@ -284,7 +241,6 @@ const ColumnResizer = props => jsxRuntime.jsx(DraggableArea, {
284
241
  isOnDataCell: props.isOnDataCell
285
242
  })
286
243
  });
287
-
288
244
  ColumnResizer.propTypes = {};
289
245
  ColumnResizer.displayName = 'ColumnResizer';
290
246
  var Resizer = ColumnResizer;
@@ -294,43 +250,31 @@ var ColumnResizingContext = /*#__PURE__*/react$1.createContext({});
294
250
  const isFixedWidthValue = value => {
295
251
  return !_Number$isNaN__default["default"](_parseInt__default["default"](String(value), 10));
296
252
  };
297
-
298
253
  var isFixedWidthValue$1 = isFixedWidthValue;
299
254
 
300
255
  function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
301
-
302
256
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
303
-
304
257
  const HeaderCellWrapper = props => {
305
258
  var _headerRef$current2;
306
-
307
259
  const _useTheme = designSystem.useTheme(),
308
- isNewTheme = _useTheme.isNewTheme;
309
-
260
+ isNewTheme = _useTheme.isNewTheme;
310
261
  const columnResizingReducer = react$1.useContext(ColumnResizingContext);
311
262
  const headerRef = react$1.useRef(null);
312
-
313
263
  const onStartResizing = event => {
314
264
  columnResizingReducer.startResizing(headerRef, event);
315
265
  };
316
-
317
266
  const onDrag = event => {
318
267
  var _headerRef$current;
319
-
320
268
  return columnResizingReducer.onDragResizing(event, (_headerRef$current = headerRef.current) === null || _headerRef$current === void 0 ? void 0 : _headerRef$current.cellIndex);
321
269
  };
322
-
323
270
  const onDragEnd = () => {
324
271
  const finalSizes = columnResizingReducer.finishResizing();
325
-
326
272
  if (props.onColumnResized) {
327
273
  props.onColumnResized(finalSizes);
328
274
  }
329
-
330
275
  window.removeEventListener('mousemove', onDrag);
331
276
  window.removeEventListener('mouseup', onDragEnd);
332
277
  };
333
-
334
278
  if (columnResizingReducer.getIsColumnBeingResized((_headerRef$current2 = headerRef.current) === null || _headerRef$current2 === void 0 ? void 0 : _headerRef$current2.cellIndex)) {
335
279
  window.addEventListener('mousemove', onDrag);
336
280
  window.addEventListener('mouseup', onDragEnd);
@@ -340,8 +284,6 @@ const HeaderCellWrapper = props => {
340
284
  * OR the width of the current column is a fixed value
341
285
  * THEN the header content should be clipped
342
286
  */
343
-
344
-
345
287
  const shouldClipContent = props.columnWidth && isFixedWidthValue$1(props.columnWidth) || columnResizingReducer.getHasTableBeenResized() || columnResizingReducer.getIsAnyColumnBeingResized();
346
288
  return jsxRuntime.jsxs(BaseHeaderCell, {
347
289
  ref: headerRef,
@@ -355,18 +297,15 @@ const HeaderCellWrapper = props => {
355
297
  })]
356
298
  });
357
299
  };
358
-
359
300
  HeaderCellWrapper.displayName = 'HeaderCellWrapper';
360
301
  const defaultProps$3 = {
361
302
  sortDirection: 'desc',
362
303
  disableHeaderStickiness: false,
363
304
  horizontalCellAlignment: 'left'
364
305
  };
365
-
366
306
  const HeaderCell = props => {
367
307
  let sortableHeaderProps = {};
368
308
  let SortingIcon;
369
-
370
309
  if (props.isSortable) {
371
310
  const isActive = props.sortedBy === props.columnKey;
372
311
  const nextSortDirection = !isActive || props.sortDirection === 'desc' ? 'asc' : 'desc';
@@ -379,7 +318,6 @@ const HeaderCell = props => {
379
318
  isSortable: true
380
319
  };
381
320
  }
382
-
383
321
  return jsxRuntime.jsx(HeaderCellWrapper, {
384
322
  columnWidth: props.columnWidth,
385
323
  columnKey: props.columnKey,
@@ -409,23 +347,19 @@ const HeaderCell = props => {
409
347
  }))
410
348
  });
411
349
  };
412
-
413
350
  HeaderCell.propTypes = {};
414
351
  HeaderCell.displayName = 'HeaderCell';
415
352
  HeaderCell.defaultProps = defaultProps$3;
416
353
  var HeaderCell$1 = HeaderCell;
417
354
 
418
355
  function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
419
-
420
356
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
421
357
  const defaultProps$2 = {
422
358
  isTruncated: false,
423
359
  shouldRenderBottomBorder: true
424
360
  };
425
-
426
361
  const DataCell = props => {
427
362
  if (props.shouldRenderCollapseButton) ;
428
-
429
363
  const Icon = props.isRowCollapsed ? icons.RightTriangleFilledIcon : icons.RightTriangleLinearIcon;
430
364
  return jsxRuntime.jsxs(BaseCell, {
431
365
  onClick: props.onCellClick,
@@ -454,7 +388,6 @@ const DataCell = props => {
454
388
  })]
455
389
  });
456
390
  };
457
-
458
391
  DataCell.propTypes = {};
459
392
  DataCell.displayName = 'DataCell';
460
393
  DataCell.defaultProps = defaultProps$2;
@@ -464,7 +397,6 @@ const defaultItemRenderer = (row, column) => {
464
397
  // @ts-ignore
465
398
  return row[column.key];
466
399
  };
467
-
468
400
  const defaultProps$1 = {
469
401
  isCondensed: false,
470
402
  shouldClipContent: false,
@@ -473,25 +405,20 @@ const defaultProps$1 = {
473
405
  shouldRenderBottomBorder: true,
474
406
  itemRenderer: defaultItemRenderer
475
407
  };
476
-
477
408
  const DataRow = props => {
478
409
  var _context, _context2;
479
-
480
410
  const _ref = react$1.useContext(ColumnResizingContext),
481
- getIsColumnBeingResized = _ref.getIsColumnBeingResized;
482
-
411
+ getIsColumnBeingResized = _ref.getIsColumnBeingResized;
483
412
  const rowHasTruncatedColumn = _someInstanceProperty__default["default"](_context = props.columns).call(_context, column => column.isTruncated);
484
-
485
413
  const _useState = react$1.useState(rowHasTruncatedColumn),
486
- _useState2 = _slicedToArray(_useState, 2),
487
- isRowCollapsed = _useState2[0],
488
- collapseRow = _useState2[1];
489
-
414
+ _useState2 = _slicedToArray(_useState, 2),
415
+ isRowCollapsed = _useState2[0],
416
+ collapseRow = _useState2[1];
490
417
  const handleRowCollapseClick = () => {
491
418
  collapseRow(!isRowCollapsed);
492
- }; // update the collapsed state if isTruncated options are changed for the whole row
493
-
419
+ };
494
420
 
421
+ // update the collapsed state if isTruncated options are changed for the whole row
495
422
  react$1.useEffect(() => {
496
423
  if (rowHasTruncatedColumn) {
497
424
  collapseRow(true);
@@ -499,14 +426,11 @@ const DataRow = props => {
499
426
  collapseRow(false);
500
427
  }
501
428
  }, [rowHasTruncatedColumn]);
502
-
503
429
  const shouldRenderCollapseButton = (totalColumnsLength, currentColumnIndex) => rowHasTruncatedColumn && totalColumnsLength - 1 === currentColumnIndex;
504
-
505
430
  return jsxRuntime.jsx(TableRow, {
506
431
  isRowClickable: Boolean(props.onRowClick),
507
432
  children: _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, (column, columnIndex) => {
508
433
  var _context3, _context4;
509
-
510
434
  return jsxRuntime.jsx(DataCell$1, {
511
435
  "data-testid": _concatInstanceProperty__default["default"](_context4 = "cell-".concat(props.rowIndex, "-")).call(_context4, column.key),
512
436
  isTruncated: column.isTruncated && isRowCollapsed,
@@ -519,7 +443,6 @@ const DataRow = props => {
519
443
  shouldRenderCollapseButton: shouldRenderCollapseButton(props.columns.length, columnIndex),
520
444
  onCellClick: props.onRowClick && !column.shouldIgnoreRowClick ? () => {
521
445
  var _props$onRowClick;
522
-
523
446
  return (_props$onRowClick = props.onRowClick) === null || _props$onRowClick === void 0 ? void 0 : _props$onRowClick.call(props, props.row, props.rowIndex, column.key);
524
447
  } : undefined,
525
448
  shouldRenderBottomBorder: props.shouldRenderBottomBorder,
@@ -529,17 +452,16 @@ const DataRow = props => {
529
452
  })
530
453
  });
531
454
  };
532
-
533
455
  DataRow.propTypes = {};
534
456
  DataRow.defaultProps = defaultProps$1;
535
457
  DataRow.displayName = 'DataRow';
536
458
  var DataRow$1 = DataRow;
537
459
 
538
460
  function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
539
-
540
461
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$1(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$1(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
541
- const MINIMUM_COLUMN_SIZE = 32; // calculates size on mouse-drag and enforces a minimum size
462
+ const MINIMUM_COLUMN_SIZE = 32;
542
463
 
464
+ // calculates size on mouse-drag and enforces a minimum size
543
465
  const calculateNewSize = function () {
544
466
  let initialSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
545
467
  let initialMousePosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
@@ -548,21 +470,19 @@ const calculateNewSize = function () {
548
470
  const newSize = initialSize - (initialMousePosition - newMousePosition);
549
471
  return minSize > newSize ? minSize : newSize;
550
472
  };
551
-
552
473
  const setColumnWidth = function () {
553
474
  let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
554
475
  let position = arguments.length > 1 ? arguments[1] : undefined;
555
476
  let value = arguments.length > 2 ? arguments[2] : undefined;
556
477
  // columns => comes from state.sizes which reflects component's state
557
478
  // any update to the columns results in updating the state
479
+
558
480
  columns[position] = _objectSpread$1(_objectSpread$1({}, columns[position]), {}, {
559
481
  width: value
560
482
  });
561
483
  return columns;
562
484
  };
563
-
564
485
  const getGridTemplateColumnsStyle = columns => "".concat(_mapInstanceProperty__default["default"](columns).call(columns, width => "".concat(width || 0, "px")).join(' '));
565
-
566
486
  const initialState = tableRef => ({
567
487
  initialColWidth: undefined,
568
488
  initialMousePosition: undefined,
@@ -571,28 +491,24 @@ const initialState = tableRef => ({
571
491
  sizes: undefined,
572
492
  tableRef
573
493
  });
574
-
575
494
  function reducer(state, action) {
576
495
  switch (action.type) {
577
496
  case 'reset':
578
497
  {
579
498
  return _objectSpread$1({}, initialState(state.tableRef));
580
499
  }
581
-
582
500
  case 'registerColumnMeasurements':
583
501
  {
584
502
  return _objectSpread$1(_objectSpread$1({}, state), {}, {
585
503
  sizes: action.payload.sizes
586
504
  });
587
505
  }
588
-
589
506
  case 'startResizing':
590
507
  return _objectSpread$1(_objectSpread$1({}, state), {}, {
591
508
  initialColWidth: action.payload.initialColWidth,
592
509
  initialMousePosition: action.payload.initialMousePosition,
593
510
  columnBeingResized: action.payload.columnBeingResized
594
511
  });
595
-
596
512
  case 'finishResizing':
597
513
  return _objectSpread$1(_objectSpread$1({}, state), {}, {
598
514
  initialColWidth: undefined,
@@ -600,43 +516,35 @@ function reducer(state, action) {
600
516
  columnBeingResized: undefined,
601
517
  hasBeenResized: true
602
518
  });
603
-
604
519
  default:
605
520
  return state;
606
521
  }
607
522
  }
608
-
609
523
  const useManualResizingReducer = tableRef => {
610
524
  const _useReducer = react$1.useReducer(reducer, initialState(tableRef)),
611
- _useReducer2 = _slicedToArray(_useReducer, 2),
612
- manualResizingState = _useReducer2[0],
613
- dispatch = _useReducer2[1];
614
-
525
+ _useReducer2 = _slicedToArray(_useReducer, 2),
526
+ manualResizingState = _useReducer2[0],
527
+ dispatch = _useReducer2[1];
615
528
  react$1.useDebugValue(manualResizingState);
616
529
  return [manualResizingState, dispatch];
617
530
  };
618
-
619
531
  const useManualColumnResizing = tableRef => {
620
532
  var _state$tableRef;
621
-
622
533
  const _useManualResizingRed = useManualResizingReducer(tableRef),
623
- _useManualResizingRed2 = _slicedToArray(_useManualResizingRed, 2),
624
- state = _useManualResizingRed2[0],
625
- dispatch = _useManualResizingRed2[1]; // if the table element has been rendered and we haven't yet measured the columns
626
-
534
+ _useManualResizingRed2 = _slicedToArray(_useManualResizingRed, 2),
535
+ state = _useManualResizingRed2[0],
536
+ dispatch = _useManualResizingRed2[1];
627
537
 
538
+ // if the table element has been rendered and we haven't yet measured the columns
628
539
  if ((_state$tableRef = state.tableRef) !== null && _state$tableRef !== void 0 && _state$tableRef.current && !state.sizes) {
629
540
  var _context;
630
-
631
541
  const renderedColumnMeasurements = [];
632
-
633
542
  _forEachInstanceProperty__default["default"](_context = state.tableRef.current.querySelectorAll('th')).call(_context, header => {
634
543
  renderedColumnMeasurements.push({
635
544
  key: header.getAttribute('data-id'),
636
545
  width: header.getBoundingClientRect().width
637
546
  });
638
547
  });
639
-
640
548
  dispatch({
641
549
  type: 'registerColumnMeasurements',
642
550
  payload: {
@@ -644,7 +552,6 @@ const useManualColumnResizing = tableRef => {
644
552
  }
645
553
  });
646
554
  }
647
-
648
555
  const startResizing = (headerRef, mouseEvent) => {
649
556
  dispatch({
650
557
  type: 'startResizing',
@@ -655,54 +562,41 @@ const useManualColumnResizing = tableRef => {
655
562
  }
656
563
  });
657
564
  };
658
-
659
565
  const onDragResizing = (event, columnIndex) => {
660
566
  // throttle and sync resizing update rate with screen refresh rate
661
567
  requestAnimationFrame(() => {
662
568
  var _state$tableRef2;
663
-
664
569
  const width = calculateNewSize(state.initialColWidth, state.initialMousePosition, event.clientX);
665
570
  const newColumnsSizes = setColumnWidth(state.sizes, columnIndex, width);
666
571
  if (!((_state$tableRef2 = state.tableRef) !== null && _state$tableRef2 !== void 0 && _state$tableRef2.current)) return;
667
572
  state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty__default["default"](newColumnsSizes).call(newColumnsSizes, newColumnsSize => newColumnsSize.width.toString()));
668
573
  });
669
574
  };
670
-
671
575
  const finishResizing = () => {
672
576
  dispatch({
673
577
  type: 'finishResizing'
674
578
  });
675
579
  return state.sizes;
676
580
  };
677
-
678
581
  const getIsColumnBeingResized = columnIndex => state.columnBeingResized !== undefined ? state.columnBeingResized === columnIndex : false;
679
-
680
582
  const getIsAnyColumnBeingResized = () => state.columnBeingResized !== undefined;
681
-
682
583
  const getHasTableBeenResized = () => state.hasBeenResized;
683
-
684
584
  const getTotalResizedTableWidth = () => {
685
585
  var _context2;
686
-
687
586
  if (!state.hasBeenResized || !state.sizes) {
688
587
  return -1;
689
588
  }
690
-
691
589
  return _reduceInstanceProperty__default["default"](_context2 = state.sizes).call(_context2, (a, b) => a + b.width, 0);
692
590
  };
693
-
694
591
  const reset = () => {
695
592
  var _state$tableRef3;
696
-
697
593
  if (!((_state$tableRef3 = state.tableRef) !== null && _state$tableRef3 !== void 0 && _state$tableRef3.current)) return;
698
594
  state.tableRef.current.style.gridTemplateColumns = '';
699
595
  return dispatch({
700
596
  type: 'reset'
701
597
  });
702
598
  };
703
-
704
599
  const getSizes = () => state.sizes;
705
-
706
600
  react$1.useDebugValue(state);
707
601
  return {
708
602
  reset,
@@ -716,24 +610,19 @@ const useManualColumnResizing = tableRef => {
716
610
  getTotalResizedTableWidth
717
611
  };
718
612
  };
719
-
720
613
  var useManualColumnResizing$1 = useManualColumnResizing;
721
614
 
722
615
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
723
-
724
616
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
725
-
726
617
  const getColumnsLayoutInfo = columns => _reduceInstanceProperty__default["default"](columns).call(columns, (acc, currentValue) => [...acc, {
727
618
  key: currentValue.key,
728
619
  width: currentValue.width
729
620
  }], []);
730
-
731
621
  const shouldRenderRowBottomBorder = (rowIndex, rowCount, footer) => {
732
622
  if (!footer) return true;
733
623
  if (rowIndex + 1 < rowCount) return true;
734
624
  return false;
735
625
  };
736
-
737
626
  const defaultProps = {
738
627
  columns: [],
739
628
  isCondensed: false,
@@ -744,14 +633,14 @@ const defaultProps = {
744
633
  // @ts-ignore
745
634
  itemRenderer: (row, column) => row[column.key]
746
635
  };
747
-
748
636
  const DataTable = props => {
749
637
  var _context, _context2;
750
638
  const tableRef = react$1.useRef();
751
- const columnResizingReducer = useManualColumnResizing$1(tableRef); // if the table columns have been measured
639
+ const columnResizingReducer = useManualColumnResizing$1(tableRef);
640
+
641
+ // if the table columns have been measured
752
642
  // and if the list of columns, their width field, or the isCondensed prop has changed
753
643
  // then we need to reset the resized column widths
754
-
755
644
  const columnsInfo = getColumnsLayoutInfo(props.columns);
756
645
  const prevLayout = hooks.usePrevious({
757
646
  columns: columnsInfo,
@@ -768,7 +657,8 @@ const DataTable = props => {
768
657
  }
769
658
  }, [columnResizingReducer, hasLayoutChanged]);
770
659
  const hasTableBeenResized = columnResizingReducer.getHasTableBeenResized();
771
- const resizedTotalWidth = hasTableBeenResized && tableRef.current ? columnResizingReducer.getTotalResizedTableWidth() + ( // if the table has a maxHeight, it might add a scrollbar which takes space inside the container
660
+ const resizedTotalWidth = hasTableBeenResized && tableRef.current ? columnResizingReducer.getTotalResizedTableWidth() + (
661
+ // if the table has a maxHeight, it might add a scrollbar which takes space inside the container
772
662
  tableRef.current.offsetWidth - tableRef.current.clientWidth) : undefined;
773
663
  return jsxRuntime.jsxs(TableContainer, {
774
664
  maxWidth: props.maxWidth,
@@ -795,8 +685,7 @@ const DataTable = props => {
795
685
  horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
796
686
  disableHeaderStickiness: props.disableHeaderStickiness,
797
687
  columnWidth: column.width
798
- /* Sorting Props */
799
- ,
688
+ /* Sorting Props */,
800
689
  onClick: props.onSortChange && props.onSortChange,
801
690
  sortedBy: props.sortedBy,
802
691
  columnKey: column.key,
@@ -824,14 +713,13 @@ const DataTable = props => {
824
713
  })]
825
714
  });
826
715
  };
827
-
828
716
  DataTable.propTypes = {};
829
717
  DataTable.defaultProps = defaultProps;
830
718
  DataTable.displayName = 'DataTable';
831
719
  var DataTable$1 = DataTable;
832
720
 
833
721
  // NOTE: This string will be replaced on build time with the package version.
834
- var version = "16.0.0";
722
+ var version = "16.1.0";
835
723
 
836
724
  Object.defineProperty(exports, 'useRowSelection', {
837
725
  enumerable: true,