@commercetools-uikit/data-table 19.20.1 → 19.22.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.
@@ -1,7 +1,3 @@
1
- import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
2
- import _pt from 'prop-types';
3
- import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
4
- import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
5
1
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
6
2
  import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
7
3
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
@@ -10,6 +6,11 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
10
6
  import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
11
7
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
12
8
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
+ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
11
+ import _pt from 'prop-types';
12
+ import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
13
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
13
14
  import { createContext, useContext, useRef, useState, useEffect, useDebugValue, useReducer, useLayoutEffect } from 'react';
14
15
  import isEqual from 'lodash/isEqual';
15
16
  import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
@@ -19,7 +20,7 @@ import _styled from '@emotion/styled/base';
19
20
  import { css, keyframes, createElement } from '@emotion/react';
20
21
  import { designTokens } from '@commercetools-uikit/design-system';
21
22
  import AccessibleButton from '@commercetools-uikit/accessible-button';
22
- import { ArrowDownIcon, ArrowUpIcon, AngleUpDownIcon, RightTriangleFilledIcon, RightTriangleLinearIcon } from '@commercetools-uikit/icons';
23
+ import { AngleUpDownIcon, ArrowDownIcon, ArrowUpIcon, RightTriangleFilledIcon, RightTriangleLinearIcon } from '@commercetools-uikit/icons';
23
24
  import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
24
25
  import _Number$isNaN from '@babel/runtime-corejs3/core-js-stable/number/is-nan';
25
26
  import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
@@ -360,7 +361,7 @@ const TableRow = /*#__PURE__*/_styled("tr", process.env.NODE_ENV === "production
360
361
  label: "TableRow"
361
362
  })("display:contents;", getClickableRowStyle, " :hover,:focus-within{", RowExpandCollapseButton, "{opacity:1;}}" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRhdGEtdGFibGUuc3R5bGVzLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFpSXNEIiwiZmlsZSI6ImRhdGEtdGFibGUuc3R5bGVzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcbmltcG9ydCB7IGRlc2lnblRva2VucyB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLXVpa2l0L2Rlc2lnbi1zeXN0ZW0nO1xuaW1wb3J0IHsgUm93RXhwYW5kQ29sbGFwc2VCdXR0b24gfSBmcm9tICcuL2NlbGwuc3R5bGVzJztcbmltcG9ydCB7IEJhc2VIZWFkZXJDZWxsIH0gZnJvbSAnLi9oZWFkZXItY2VsbC5zdHlsZXMnO1xuaW1wb3J0IGNvbnZlcnROdW1lcmljRGltZW5zaW9uVG9QaXhlbFZhbHVlIGZyb20gJy4vdX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XG4gICAgJHtSb3dFeHBhbmRDb2xsYXBzZUJ1dHRvbn0ge1xuICAgICAgb3BhY2l0eTogMTtcbiAgICB9XG4gIH1cbmA7XG5cbmV4cG9ydCB7IFRhYmxlQ29udGFpbmVyLCBUYWJsZUdyaWQsIFRhYmxlSGVhZGVyLCBUYWJsZUJvZHksIFRhYmxlUm93IH07XG4iXX0= */"));
362
363
 
363
- const defaultProps$4 = {
364
+ const defaultProps = {
364
365
  horizontalCellAlignment: 'left'
365
366
  };
366
367
  const Footer = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
@@ -370,7 +371,7 @@ const Footer = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production"
370
371
  label: "Footer"
371
372
  })("box-sizing:border-box;display:block;", getPaddingStyle, " ", getHorizontalAlignmentStyle, " background-color:", designTokens.colorSurface, ";border-top:1px solid ", designTokens.colorNeutral90, ";border-bottom:1px solid ", designTokens.colorNeutral90, ";width:100%;", props => props.resizedTotalWidth ? `max-width: ${props.resizedTotalWidth}px;` : '', ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZvb3Rlci50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBZ0JrQyIsImZpbGUiOiJmb290ZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgUmVhY3ROb2RlIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgZGVzaWduVG9rZW5zIH0gZnJvbSAnQGNvbW1lcmNldG9vbHMtdWlraXQvZGVzaWduLXN5c3RlbSc7XG5pbXBvcnQgeyBnZXRQYWRkaW5nU3R5bGUsIGdldEhvcml6b250YWxBbGlnbm1lbnRTdHlsZSB9IGZyb20gJy4vY2VsbC5zdHlsZXMnO1xuXG50eXBlIFRGb290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defaultProps = defaultProps$4;
374
+ Footer.defaultProps = defaultProps;
374
375
  var Footer$1 = Footer;
375
376
 
376
377
  const ResizerIndicator = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
@@ -407,6 +408,7 @@ const isFixedWidthValue = value => {
407
408
  };
408
409
  var isFixedWidthValue$1 = isFixedWidthValue;
409
410
 
411
+ const _excluded$3 = ["sortDirection", "disableHeaderStickiness", "horizontalCellAlignment"];
410
412
  function ownKeys$3(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
411
413
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
412
414
  const HeaderCellWrapper = props => {
@@ -446,21 +448,23 @@ const HeaderCellWrapper = props => {
446
448
  });
447
449
  };
448
450
  HeaderCellWrapper.displayName = 'HeaderCellWrapper';
449
- const defaultProps$3 = {
450
- sortDirection: 'desc',
451
- disableHeaderStickiness: false,
452
- horizontalCellAlignment: 'left'
453
- };
454
- const HeaderCell = props => {
451
+ const HeaderCell = _ref => {
452
+ let _ref$sortDirection = _ref.sortDirection,
453
+ sortDirection = _ref$sortDirection === void 0 ? 'desc' : _ref$sortDirection,
454
+ _ref$disableHeaderSti = _ref.disableHeaderStickiness,
455
+ disableHeaderStickiness = _ref$disableHeaderSti === void 0 ? false : _ref$disableHeaderSti,
456
+ _ref$horizontalCellAl = _ref.horizontalCellAlignment,
457
+ horizontalCellAlignment = _ref$horizontalCellAl === void 0 ? 'left' : _ref$horizontalCellAl,
458
+ props = _objectWithoutProperties(_ref, _excluded$3);
455
459
  let sortableHeaderProps = {};
456
460
  let SortingIcon;
457
461
  if (props.isSortable) {
458
462
  const isActive = props.sortedBy === props.columnKey;
459
- const nextSortDirection = !isActive || props.sortDirection === 'desc' ? 'asc' : 'desc';
460
- SortingIcon = props.sortDirection === 'desc' ? ArrowDownIcon : ArrowUpIcon;
463
+ const nextSortDirection = !isActive || sortDirection === 'desc' ? 'asc' : 'desc';
464
+ SortingIcon = sortDirection === 'desc' ? ArrowDownIcon : ArrowUpIcon;
461
465
  sortableHeaderProps = {
462
466
  as: 'button',
463
- label: props.sortDirection,
467
+ label: sortDirection,
464
468
  onClick: () => props.onClick && props.onClick(props.columnKey, nextSortDirection),
465
469
  isActive,
466
470
  isSortable: true
@@ -472,11 +476,11 @@ const HeaderCell = props => {
472
476
  columnKey: props.columnKey,
473
477
  onColumnResized: props.onColumnResized,
474
478
  disableResizing: props.disableResizing,
475
- disableHeaderStickiness: props.disableHeaderStickiness,
479
+ disableHeaderStickiness: disableHeaderStickiness,
476
480
  children: jsxs(HeaderCellInner, _objectSpread$3(_objectSpread$3({
477
481
  shouldWrap: props.shouldWrap,
478
482
  isCondensed: props.isCondensed,
479
- horizontalCellAlignment: props.horizontalCellAlignment
483
+ horizontalCellAlignment: horizontalCellAlignment
480
484
  }, sortableHeaderProps), {}, {
481
485
  children: [jsxs(HeaderLabelWrapper, {
482
486
  children: [jsx(HeaderLabelTextWrapper, {
@@ -510,21 +514,22 @@ HeaderCell.propTypes = process.env.NODE_ENV !== "production" ? {
510
514
  sortDirection: _pt.oneOf(['desc', 'asc']),
511
515
  disableResizing: _pt.bool,
512
516
  onColumnResized: _pt.func,
513
- disableHeaderStickiness: _pt.bool.isRequired,
514
- horizontalCellAlignment: _pt.oneOf(['left', 'center', 'right']).isRequired,
517
+ disableHeaderStickiness: _pt.bool,
518
+ horizontalCellAlignment: _pt.oneOf(['left', 'center', 'right']),
515
519
  iconComponent: _pt.node
516
520
  } : {};
517
521
  HeaderCell.displayName = 'HeaderCell';
518
- HeaderCell.defaultProps = defaultProps$3;
519
522
  var HeaderCell$1 = HeaderCell;
520
523
 
524
+ const _excluded$2 = ["isTruncated", "shouldRenderBottomBorder"];
521
525
  function ownKeys$2(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
522
526
  function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
523
- const defaultProps$2 = {
524
- isTruncated: false,
525
- shouldRenderBottomBorder: true
526
- };
527
- const DataCell = props => {
527
+ const DataCell = _ref => {
528
+ let _ref$isTruncated = _ref.isTruncated,
529
+ isTruncated = _ref$isTruncated === void 0 ? false : _ref$isTruncated,
530
+ _ref$shouldRenderBott = _ref.shouldRenderBottomBorder,
531
+ shouldRenderBottomBorder = _ref$shouldRenderBott === void 0 ? true : _ref$shouldRenderBott,
532
+ props = _objectWithoutProperties(_ref, _excluded$2);
528
533
  if (props.shouldRenderCollapseButton) {
529
534
  process.env.NODE_ENV !== "production" ? warning(typeof props.handleRowCollapseClick === 'function', 'DataTable: "handleRowCollapseClick" is required when shouldRenderCollapseButton is true.') : void 0;
530
535
  process.env.NODE_ENV !== "production" ? warning(typeof props.isRowCollapsed === 'boolean', 'DataTable: "isRowCollapsed" is required when shouldRenderCollapseButton is true.') : void 0;
@@ -533,14 +538,17 @@ const DataCell = props => {
533
538
  return jsxs(BaseCell, {
534
539
  onClick: props.onCellClick,
535
540
  shouldIgnoreRowClick: props.shouldIgnoreRowClick,
536
- shouldClipContent: props.isTruncated && !props.shouldRenderResizingIndicator,
537
- shouldRenderBottomBorder: props.shouldRenderBottomBorder,
541
+ shouldClipContent: isTruncated && !props.shouldRenderResizingIndicator,
542
+ shouldRenderBottomBorder: shouldRenderBottomBorder,
538
543
  children: [jsx(CellInner, _objectSpread$2(_objectSpread$2({
539
544
  isCondensed: props.isCondensed,
540
- isTruncated: props.isTruncated,
545
+ isTruncated: isTruncated,
541
546
  verticalCellAlignment: props.verticalCellAlignment,
542
547
  horizontalCellAlignment: props.horizontalCellAlignment
543
- }, filterDataAttributes(props)), {}, {
548
+ }, filterDataAttributes(_objectSpread$2({
549
+ isTruncated,
550
+ shouldRenderBottomBorder
551
+ }, props))), {}, {
544
552
  children: props.children
545
553
  })), props.shouldRenderCollapseButton && jsx(RowExpandCollapseButton, {
546
554
  label: "Expand/Collapse Row",
@@ -565,32 +573,36 @@ DataCell.propTypes = process.env.NODE_ENV !== "production" ? {
565
573
  shouldIgnoreRowClick: _pt.bool,
566
574
  verticalCellAlignment: _pt.oneOf(['top', 'center', 'bottom']),
567
575
  horizontalCellAlignment: _pt.oneOf(['left', 'center', 'right']),
568
- shouldRenderBottomBorder: _pt.bool.isRequired,
576
+ shouldRenderBottomBorder: _pt.bool,
569
577
  shouldRenderCollapseButton: _pt.bool.isRequired,
570
578
  shouldRenderResizingIndicator: _pt.bool.isRequired,
571
579
  handleRowCollapseClick: _pt.func,
572
580
  isRowCollapsed: _pt.bool
573
581
  } : {};
574
582
  DataCell.displayName = 'DataCell';
575
- DataCell.defaultProps = defaultProps$2;
576
583
  var DataCell$1 = DataCell;
577
584
 
578
- const defaultItemRenderer = (row, column) => {
585
+ const _excluded$1 = ["isCondensed", "shouldClipContent", "verticalCellAlignment", "horizontalCellAlignment", "shouldRenderBottomBorder", "itemRenderer"];
586
+ const defaultItemRenderer = (row, column, _isRowCollapsed) => {
579
587
  // @ts-ignore
580
588
  return row[column.key];
581
589
  };
582
- const defaultProps$1 = {
583
- isCondensed: true,
584
- shouldClipContent: false,
585
- verticalCellAlignment: 'top',
586
- horizontalCellAlignment: 'left',
587
- shouldRenderBottomBorder: true,
588
- itemRenderer: defaultItemRenderer
589
- };
590
- const DataRow = props => {
590
+ const DataRow = _ref => {
591
591
  var _context, _context2;
592
- const _ref = useContext(ColumnResizingContext),
593
- getIsColumnBeingResized = _ref.getIsColumnBeingResized;
592
+ let _ref$isCondensed = _ref.isCondensed,
593
+ isCondensed = _ref$isCondensed === void 0 ? true : _ref$isCondensed;
594
+ _ref.shouldClipContent;
595
+ let _ref$verticalCellAlig = _ref.verticalCellAlignment,
596
+ verticalCellAlignment = _ref$verticalCellAlig === void 0 ? 'top' : _ref$verticalCellAlig,
597
+ _ref$horizontalCellAl = _ref.horizontalCellAlignment,
598
+ horizontalCellAlignment = _ref$horizontalCellAl === void 0 ? 'left' : _ref$horizontalCellAl,
599
+ _ref$shouldRenderBott = _ref.shouldRenderBottomBorder,
600
+ shouldRenderBottomBorder = _ref$shouldRenderBott === void 0 ? true : _ref$shouldRenderBott,
601
+ _ref$itemRenderer = _ref.itemRenderer,
602
+ itemRenderer = _ref$itemRenderer === void 0 ? defaultItemRenderer : _ref$itemRenderer,
603
+ props = _objectWithoutProperties(_ref, _excluded$1);
604
+ const _ref2 = useContext(ColumnResizingContext),
605
+ getIsColumnBeingResized = _ref2.getIsColumnBeingResized;
594
606
  const rowHasTruncatedColumn = _someInstanceProperty(_context = props.columns).call(_context, column => column.isTruncated);
595
607
  const _useState = useState(rowHasTruncatedColumn),
596
608
  _useState2 = _slicedToArray(_useState, 2),
@@ -614,17 +626,17 @@ const DataRow = props => {
614
626
  children: _mapInstanceProperty(_context2 = props.columns).call(_context2, (column, columnIndex) => jsx(DataCell$1, {
615
627
  "data-testid": `cell-${props.rowIndex}-${column.key}`,
616
628
  isTruncated: column.isTruncated && isRowCollapsed,
617
- isCondensed: props.isCondensed,
629
+ isCondensed: isCondensed,
618
630
  isRowCollapsed: isRowCollapsed,
619
- verticalCellAlignment: props.verticalCellAlignment,
620
- horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
631
+ verticalCellAlignment: verticalCellAlignment,
632
+ horizontalCellAlignment: column.align ? column.align : horizontalCellAlignment,
621
633
  shouldIgnoreRowClick: column.shouldIgnoreRowClick,
622
634
  handleRowCollapseClick: handleRowCollapseClick,
623
635
  shouldRenderCollapseButton: shouldRenderCollapseButton(props.columns.length, columnIndex),
624
636
  onCellClick: props.onRowClick && !column.shouldIgnoreRowClick ? () => props.onRowClick?.(props.row, props.rowIndex, column.key) : undefined,
625
- shouldRenderBottomBorder: props.shouldRenderBottomBorder,
637
+ shouldRenderBottomBorder: shouldRenderBottomBorder,
626
638
  shouldRenderResizingIndicator: getIsColumnBeingResized(columnIndex),
627
- children: column.renderItem ? column.renderItem(props.row, isRowCollapsed) : props.itemRenderer(props.row, column, isRowCollapsed)
639
+ children: column.renderItem ? column.renderItem(props.row, isRowCollapsed) : itemRenderer(props.row, column, isRowCollapsed)
628
640
  }, `${props.row.id}-${column.key}`))
629
641
  });
630
642
  };
@@ -636,7 +648,6 @@ DataRow.propTypes = process.env.NODE_ENV !== "production" ? {
636
648
  shouldRenderBottomBorder: _pt.bool.isRequired,
637
649
  onExpandRow: _pt.func
638
650
  } : {};
639
- DataRow.defaultProps = defaultProps$1;
640
651
  DataRow.displayName = 'DataRow';
641
652
  var DataRow$1 = DataRow;
642
653
 
@@ -792,6 +803,7 @@ const useManualColumnResizing = tableRef => {
792
803
  };
793
804
  var useManualColumnResizing$1 = useManualColumnResizing;
794
805
 
806
+ const _excluded = ["columns", "isCondensed", "wrapHeaderLabels", "verticalCellAlignment", "horizontalCellAlignment", "disableSelfContainment", "itemRenderer"];
795
807
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
796
808
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
797
809
  const getColumnsLayoutInfo = columns => _reduceInstanceProperty(columns).call(columns, (acc, currentValue) => [...acc, {
@@ -803,24 +815,29 @@ const shouldRenderRowBottomBorder = (rowIndex, rowCount, footer) => {
803
815
  if (rowIndex + 1 < rowCount) return true;
804
816
  return false;
805
817
  };
806
- const defaultProps = {
807
- columns: [],
808
- isCondensed: true,
809
- wrapHeaderLabels: true,
810
- verticalCellAlignment: 'top',
811
- horizontalCellAlignment: 'left',
812
- disableSelfContainment: false,
813
- // @ts-ignore
814
- itemRenderer: (row, column) => row[column.key]
815
- };
816
- const DataTable = props => {
818
+ const DataTable = _ref => {
817
819
  var _context;
820
+ let _ref$columns = _ref.columns,
821
+ columns = _ref$columns === void 0 ? [] : _ref$columns,
822
+ _ref$isCondensed = _ref.isCondensed,
823
+ isCondensed = _ref$isCondensed === void 0 ? true : _ref$isCondensed,
824
+ _ref$wrapHeaderLabels = _ref.wrapHeaderLabels,
825
+ wrapHeaderLabels = _ref$wrapHeaderLabels === void 0 ? true : _ref$wrapHeaderLabels,
826
+ _ref$verticalCellAlig = _ref.verticalCellAlignment,
827
+ verticalCellAlignment = _ref$verticalCellAlig === void 0 ? 'top' : _ref$verticalCellAlig,
828
+ _ref$horizontalCellAl = _ref.horizontalCellAlignment,
829
+ horizontalCellAlignment = _ref$horizontalCellAl === void 0 ? 'left' : _ref$horizontalCellAl,
830
+ _ref$disableSelfConta = _ref.disableSelfContainment,
831
+ disableSelfContainment = _ref$disableSelfConta === void 0 ? false : _ref$disableSelfConta,
832
+ _ref$itemRenderer = _ref.itemRenderer,
833
+ itemRenderer = _ref$itemRenderer === void 0 ? (row, column) => row[column.key] : _ref$itemRenderer,
834
+ props = _objectWithoutProperties(_ref, _excluded);
818
835
  const _useDataTableManagerC = useDataTableManagerContext(),
819
- columns = _useDataTableManagerC.columns,
820
- isCondensed = _useDataTableManagerC.isCondensed;
821
- const isValueFromProvider = Boolean(columns && columns.length !== 0);
822
- const columnsData = isValueFromProvider ? columns : props.columns;
823
- const condensedValue = isValueFromProvider && isCondensed !== undefined ? isCondensed : props.isCondensed;
836
+ contextColumns = _useDataTableManagerC.columns,
837
+ contextIsCondensed = _useDataTableManagerC.isCondensed;
838
+ const isValueFromProvider = Boolean(contextColumns && contextColumns.length !== 0);
839
+ const columnsData = isValueFromProvider ? contextColumns : columns;
840
+ const condensedValue = isValueFromProvider && contextIsCondensed !== undefined ? contextIsCondensed : isCondensed;
824
841
 
825
842
  // TODO - initial poc for the nested rows
826
843
  // const [openedItemIds, setOpenedItemIds] = useState<string[]>([]);
@@ -861,13 +878,19 @@ const DataTable = props => {
861
878
  maxWidth: props.maxWidth,
862
879
  maxHeight: props.maxHeight,
863
880
  isBeingResized: columnResizingReducer.getIsAnyColumnBeingResized(),
864
- disableSelfContainment: !!props.disableSelfContainment,
881
+ disableSelfContainment: !!disableSelfContainment,
865
882
  children: [jsx(TableGrid, _objectSpread(_objectSpread({
866
883
  ref: tableRef
867
- }, filterDataAttributes(props)), {}, {
884
+ }, filterDataAttributes(_objectSpread({
885
+ isCondensed,
886
+ wrapHeaderLabels,
887
+ verticalCellAlignment,
888
+ horizontalCellAlignment,
889
+ disableSelfContainment
890
+ }, props))), {}, {
868
891
  columns: columnsData,
869
892
  maxHeight: props.maxHeight,
870
- disableSelfContainment: !!props.disableSelfContainment,
893
+ disableSelfContainment: !!disableSelfContainment,
871
894
  resizedTotalWidth: resizedTotalWidth,
872
895
  children: jsxs(ColumnResizingContext.Provider, {
873
896
  value: columnResizingReducer,
@@ -875,13 +898,13 @@ const DataTable = props => {
875
898
  children: jsx(TableRow, {
876
899
  isRowClickable: false,
877
900
  children: _mapInstanceProperty(columnsData).call(columnsData, column => jsx(HeaderCell$1, {
878
- shouldWrap: props.wrapHeaderLabels,
901
+ shouldWrap: wrapHeaderLabels,
879
902
  isCondensed: condensedValue,
880
903
  iconComponent: column.headerIcon,
881
904
  onColumnResized: props.onColumnResized,
882
905
  disableResizing: column.disableResizing,
883
- horizontalCellAlignment: column.align ? column.align : props.horizontalCellAlignment,
884
- disableHeaderStickiness: props.disableHeaderStickiness,
906
+ horizontalCellAlignment: column.align ? column.align : horizontalCellAlignment,
907
+ disableHeaderStickiness: Boolean(props.disableHeaderStickiness),
885
908
  columnWidth: column.width
886
909
  /* Sorting Props */,
887
910
  onClick: props.onSortChange && props.onSortChange,
@@ -894,12 +917,13 @@ const DataTable = props => {
894
917
  })
895
918
  }), jsx(TableBody, {
896
919
  children: _mapInstanceProperty(_context = props.rows).call(_context, (row, rowIndex) => createElement(DataRow$1, _objectSpread(_objectSpread({}, props), {}, {
920
+ itemRenderer: itemRenderer,
897
921
  isCondensed: condensedValue,
898
922
  columns: columnsData,
899
923
  row: row,
900
924
  key: row.id,
901
925
  rowIndex: rowIndex,
902
- shouldClipContent: columnResizingReducer.getIsAnyColumnBeingResized() || hasTableBeenResized,
926
+ shouldClipContent: columnResizingReducer.getIsAnyColumnBeingResized() || Boolean(hasTableBeenResized),
903
927
  shouldRenderBottomBorder: shouldRenderRowBottomBorder(rowIndex, props.rows.length, props.footer)
904
928
  })))
905
929
  })]
@@ -907,7 +931,7 @@ const DataTable = props => {
907
931
  })), props.footer && jsx(Footer$1, {
908
932
  "data-testid": "footer",
909
933
  isCondensed: condensedValue,
910
- horizontalCellAlignment: props.horizontalCellAlignment,
934
+ horizontalCellAlignment: horizontalCellAlignment,
911
935
  resizedTotalWidth: resizedTotalWidth,
912
936
  children: props.footer
913
937
  })]
@@ -927,7 +951,7 @@ DataTable.propTypes = process.env.NODE_ENV !== "production" ? {
927
951
  isSortable: _pt.bool,
928
952
  disableResizing: _pt.bool,
929
953
  shouldIgnoreRowClick: _pt.bool
930
- })).isRequired,
954
+ })),
931
955
  customColumns: _pt.arrayOf(_pt.shape({
932
956
  key: _pt.string.isRequired,
933
957
  label: _pt.node.isRequired,
@@ -949,7 +973,7 @@ DataTable.propTypes = process.env.NODE_ENV !== "production" ? {
949
973
  onColumnResized: _pt.func,
950
974
  disableSelfContainment: _pt.bool,
951
975
  disableHeaderStickiness: _pt.bool,
952
- itemRenderer: _pt.func.isRequired,
976
+ itemRenderer: _pt.func,
953
977
  wrapHeaderLabels: _pt.bool,
954
978
  verticalCellAlignment: _pt.oneOf(['top', 'center', 'bottom']),
955
979
  horizontalCellAlignment: _pt.oneOf(['left', 'center', 'right']),
@@ -959,11 +983,10 @@ DataTable.propTypes = process.env.NODE_ENV !== "production" ? {
959
983
  renderNestedRow: _pt.func,
960
984
  maxExpandableHeight: _pt.number
961
985
  } : {};
962
- DataTable.defaultProps = defaultProps;
963
986
  DataTable.displayName = 'DataTable';
964
987
  var DataTable$1 = DataTable;
965
988
 
966
989
  // NOTE: This string will be replaced on build time with the package version.
967
- var version = "19.20.1";
990
+ var version = "19.22.0";
968
991
 
969
992
  export { DataTable$1 as default, version };
@@ -110,7 +110,7 @@ export type TDataTableProps<Row extends TRow = TRow> = {
110
110
  *
111
111
  * [Colum signatures with description](/?path=/docs/components-datatable-readme--props#signatures)
112
112
  */
113
- columns: TColumn<Row>[];
113
+ columns?: TColumn<Row>[];
114
114
  /**
115
115
  * The columns of the nested items to be rendered in the table. Just like the columns, Each object requires a unique `key` which should correspond to property key of
116
116
  * the items of `rows` that you want to render under this column, and a `label`
@@ -165,7 +165,7 @@ export type TDataTableProps<Row extends TRow = TRow> = {
165
165
  * The default function used to render the content of each item in a cell.
166
166
  * In case a column has its own `renderItem` render function, it will take precedence over this function.
167
167
  */
168
- itemRenderer: (item: Row, column: TColumn<Row>, isRowCollapsed: boolean) => ReactNode;
168
+ itemRenderer?: (item: Row, column: TColumn<Row>, isRowCollapsed: boolean) => ReactNode;
169
169
  /**
170
170
  * Set this to `false` to ensure that every column can render their label in one line.
171
171
  * By default the header cell grows in height in case the label does not fit in one line.
@@ -204,8 +204,7 @@ export type TDataTableProps<Row extends TRow = TRow> = {
204
204
  maxExpandableHeight?: number;
205
205
  };
206
206
  declare const DataTable: {
207
- <Row extends TRow = TRow>(props: TDataTableProps<Row>): import("@emotion/react/jsx-runtime").JSX.Element;
208
- defaultProps: Pick<TDataTableProps<TRow>, "columns" | "isCondensed" | "wrapHeaderLabels" | "horizontalCellAlignment" | "verticalCellAlignment" | "disableSelfContainment" | "itemRenderer">;
207
+ <Row extends TRow = TRow>({ columns, isCondensed, wrapHeaderLabels, verticalCellAlignment, horizontalCellAlignment, disableSelfContainment, itemRenderer, ...props }: TDataTableProps<Row>): import("@emotion/react/jsx-runtime").JSX.Element;
209
208
  displayName: string;
210
209
  };
211
210
  export default DataTable;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/data-table",
3
3
  "description": "A component for rendering tabular data.",
4
- "version": "19.20.1",
4
+ "version": "19.22.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,13 +21,13 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/accessible-button": "19.20.1",
25
- "@commercetools-uikit/data-table-manager": "19.20.1",
26
- "@commercetools-uikit/design-system": "19.20.1",
27
- "@commercetools-uikit/hooks": "19.20.1",
28
- "@commercetools-uikit/icons": "19.20.1",
29
- "@commercetools-uikit/secondary-icon-button": "19.20.1",
30
- "@commercetools-uikit/utils": "19.20.1",
24
+ "@commercetools-uikit/accessible-button": "19.22.0",
25
+ "@commercetools-uikit/data-table-manager": "19.22.0",
26
+ "@commercetools-uikit/design-system": "19.22.0",
27
+ "@commercetools-uikit/hooks": "19.22.0",
28
+ "@commercetools-uikit/icons": "19.22.0",
29
+ "@commercetools-uikit/secondary-icon-button": "19.22.0",
30
+ "@commercetools-uikit/utils": "19.22.0",
31
31
  "@emotion/react": "^11.10.5",
32
32
  "@emotion/styled": "^11.10.5",
33
33
  "lodash": "4.17.21",