@commercetools-uikit/data-table 12.2.5 → 12.2.9

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/README.md CHANGED
@@ -62,7 +62,7 @@ export default Example;
62
62
  | Props | Type | Required | Default | Description |
63
63
  | ------------------------- | -------------------------------------------------------------- | :------: | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
64
  | `rows` | `Array: Row[]`<br/>[See signature.](#signature-rows) | ✅ | | The list of data that needs to be rendered in the table. Each object in the list can&#xA;have any shape as long as it has a unique identifier.&#xA;The data is rendered by using the callback render function `itemRenderer`. |
65
- | `columns` | `Array: TColumn[]`<br/>[See signature.](#signature-columns) || | Each object requires a unique `key` which should correspond to property key of&#xA;the items of `rows` that you want to render under this column, and a `label`&#xA;which defines the name shown on the header.&#xA;The list of columns to be rendered.&#xA;Each column can be customized (see properties below). |
65
+ | `columns` | `Array: TColumn[]`<br/>[See signature.](#signature-columns) | | `[]` | Each object requires a unique `key` which should correspond to property key of&#xA;the items of `rows` that you want to render under this column, and a `label`&#xA;which defines the name shown on the header.&#xA;The list of columns to be rendered.&#xA;Each column can be customized (see properties below). |
66
66
  | `footer` | `ReactNode` | | | Element to render within the `tfoot` (footer) element of the table. |
67
67
  | `maxWidth` | `union`<br/>Possible values:<br/>`number , string` | | | The max width (a number of pixels or a css value string with units) for which the table&#xA;is allowed to grow. If unset, the table will grow horizontally to fill its parent. |
68
68
  | `maxHeight` | `union`<br/>Possible values:<br/>`number , string` | | | The max height (a number of pixels or a css value string with units) for which the table&#xA;is allowed to grow. If unset, the table will grow vertically to fill its parent. |
@@ -112,7 +112,7 @@ export default Example;
112
112
  *
113
113
  * @@defaultValue@@: auto
114
114
  */
115
- width?: number;
115
+ width?: string;
116
116
  /**
117
117
  * Use this to override the table's own `horizontalCellAlignment` prop for this specific column.
118
118
  */
@@ -7,7 +7,6 @@ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArr
7
7
  var _pt = require('prop-types');
8
8
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
9
9
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
10
- var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
11
10
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
12
11
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
13
12
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
@@ -37,7 +36,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
37
36
  var _pt__default = /*#__PURE__*/_interopDefault(_pt);
38
37
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
39
38
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
40
- var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
41
39
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
42
40
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
43
41
  var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
@@ -529,14 +527,6 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
529
527
  });
530
528
  };
531
529
 
532
- HeaderCellWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
533
- children: _pt__default["default"].node.isRequired,
534
- columnKey: _pt__default["default"].string.isRequired,
535
- columnWidth: _pt__default["default"].number,
536
- disableResizing: _pt__default["default"].bool,
537
- onColumnResized: _pt__default["default"].func,
538
- disableHeaderStickiness: _pt__default["default"].bool
539
- } : {};
540
530
  HeaderCellWrapper.displayName = 'HeaderCellWrapper';
541
531
  var defaultProps$3 = {
542
532
  sortDirection: 'desc',
@@ -599,7 +589,7 @@ HeaderCell.propTypes = process.env.NODE_ENV !== "production" ? {
599
589
  sortedBy: _pt__default["default"].string,
600
590
  children: _pt__default["default"].node.isRequired,
601
591
  columnKey: _pt__default["default"].string.isRequired,
602
- columnWidth: _pt__default["default"].number,
592
+ columnWidth: _pt__default["default"].string,
603
593
  shouldWrap: _pt__default["default"].bool,
604
594
  isSortable: _pt__default["default"].bool,
605
595
  isCondensed: _pt__default["default"].bool,
@@ -894,7 +884,7 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
894
884
  var newColumnsSizes = setColumnWidth(state.sizes, columnIndex, width);
895
885
  if (!((_state$tableRef2 = state.tableRef) !== null && _state$tableRef2 !== void 0 && _state$tableRef2.current)) return;
896
886
  state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty__default["default"](newColumnsSizes).call(newColumnsSizes, function (newColumnsSize) {
897
- return newColumnsSize.width;
887
+ return newColumnsSize.width.toString();
898
888
  }));
899
889
  });
900
890
  };
@@ -982,6 +972,7 @@ var shouldRenderRowBottomBorder = function shouldRenderRowBottomBorder(rowIndex,
982
972
  };
983
973
 
984
974
  var defaultProps = {
975
+ columns: [],
985
976
  isCondensed: false,
986
977
  wrapHeaderLabels: true,
987
978
  verticalCellAlignment: 'top',
@@ -996,7 +987,7 @@ var defaultProps = {
996
987
  var DataTable = function DataTable(props) {
997
988
  var _context2, _context3;
998
989
 
999
- process.env.NODE_ENV !== "production" ? utils.warning(_Array$isArray__default["default"](props.columns), "ui-kit/DataTable: the prop \"columns\" is required.") : void 0;
990
+ process.env.NODE_ENV !== "production" ? utils.warning(props.columns.length > 0, "ui-kit/DataTable: empty table \"columns\", expected at least one column. If you are using DataTableManager you need to pass the \"columns\" there and they will be injected into DataTable.") : void 0;
1000
991
  var tableRef = react$1.useRef();
1001
992
  var columnResizingReducer = useManualColumnResizing$1(tableRef); // if the table columns have been measured
1002
993
  // and if the list of columns, their width field, or the isCondensed prop has changed
@@ -1035,7 +1026,7 @@ var DataTable = function DataTable(props) {
1035
1026
  value: columnResizingReducer,
1036
1027
  children: [jsxRuntime.jsx(Header, {
1037
1028
  children: jsxRuntime.jsx(Row, {
1038
- children: props.columns && _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column) {
1029
+ children: _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column) {
1039
1030
  return jsxRuntime.jsx(HeaderCell$1, {
1040
1031
  shouldWrap: props.wrapHeaderLabels,
1041
1032
  isCondensed: props.isCondensed,
@@ -1083,7 +1074,7 @@ DataTable.propTypes = process.env.NODE_ENV !== "production" ? {
1083
1074
  columns: _pt__default["default"].arrayOf(_pt__default["default"].shape({
1084
1075
  key: _pt__default["default"].string.isRequired,
1085
1076
  label: _pt__default["default"].node.isRequired,
1086
- width: _pt__default["default"].number,
1077
+ width: _pt__default["default"].string,
1087
1078
  align: _pt__default["default"].oneOf(['left', 'center', 'right']),
1088
1079
  onClick: _pt__default["default"].func,
1089
1080
  renderItem: _pt__default["default"].func,
@@ -1114,7 +1105,7 @@ DataTable.displayName = 'DataTable';
1114
1105
  var DataTable$1 = DataTable;
1115
1106
 
1116
1107
  // NOTE: This string will be replaced on build time with the package version.
1117
- var version = "12.2.5";
1108
+ var version = "12.2.9";
1118
1109
 
1119
1110
  Object.defineProperty(exports, 'useRowSelection', {
1120
1111
  enumerable: true,
@@ -7,7 +7,6 @@ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArr
7
7
  require('prop-types');
8
8
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
9
9
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
10
- require('@babel/runtime-corejs3/core-js-stable/array/is-array');
11
10
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
12
11
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
13
12
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
@@ -402,7 +401,6 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
402
401
  });
403
402
  };
404
403
 
405
- HeaderCellWrapper.propTypes = {};
406
404
  HeaderCellWrapper.displayName = 'HeaderCellWrapper';
407
405
  var defaultProps$3 = {
408
406
  sortDirection: 'desc',
@@ -722,7 +720,7 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
722
720
  var newColumnsSizes = setColumnWidth(state.sizes, columnIndex, width);
723
721
  if (!((_state$tableRef2 = state.tableRef) !== null && _state$tableRef2 !== void 0 && _state$tableRef2.current)) return;
724
722
  state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty__default["default"](newColumnsSizes).call(newColumnsSizes, function (newColumnsSize) {
725
- return newColumnsSize.width;
723
+ return newColumnsSize.width.toString();
726
724
  }));
727
725
  });
728
726
  };
@@ -810,6 +808,7 @@ var shouldRenderRowBottomBorder = function shouldRenderRowBottomBorder(rowIndex,
810
808
  };
811
809
 
812
810
  var defaultProps = {
811
+ columns: [],
813
812
  isCondensed: false,
814
813
  wrapHeaderLabels: true,
815
814
  verticalCellAlignment: 'top',
@@ -861,7 +860,7 @@ var DataTable = function DataTable(props) {
861
860
  value: columnResizingReducer,
862
861
  children: [jsxRuntime.jsx(Header, {
863
862
  children: jsxRuntime.jsx(Row, {
864
- children: props.columns && _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column) {
863
+ children: _mapInstanceProperty__default["default"](_context2 = props.columns).call(_context2, function (column) {
865
864
  return jsxRuntime.jsx(HeaderCell$1, {
866
865
  shouldWrap: props.wrapHeaderLabels,
867
866
  isCondensed: props.isCondensed,
@@ -910,7 +909,7 @@ DataTable.displayName = 'DataTable';
910
909
  var DataTable$1 = DataTable;
911
910
 
912
911
  // NOTE: This string will be replaced on build time with the package version.
913
- var version = "12.2.5";
912
+ var version = "12.2.9";
914
913
 
915
914
  Object.defineProperty(exports, 'useRowSelection', {
916
915
  enumerable: true,
@@ -3,7 +3,6 @@ import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableA
3
3
  import _pt from 'prop-types';
4
4
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
5
5
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
6
- import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
7
6
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
8
7
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
9
8
  import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
@@ -504,14 +503,6 @@ var HeaderCellWrapper = function HeaderCellWrapper(props) {
504
503
  });
505
504
  };
506
505
 
507
- HeaderCellWrapper.propTypes = process.env.NODE_ENV !== "production" ? {
508
- children: _pt.node.isRequired,
509
- columnKey: _pt.string.isRequired,
510
- columnWidth: _pt.number,
511
- disableResizing: _pt.bool,
512
- onColumnResized: _pt.func,
513
- disableHeaderStickiness: _pt.bool
514
- } : {};
515
506
  HeaderCellWrapper.displayName = 'HeaderCellWrapper';
516
507
  var defaultProps$3 = {
517
508
  sortDirection: 'desc',
@@ -574,7 +565,7 @@ HeaderCell.propTypes = process.env.NODE_ENV !== "production" ? {
574
565
  sortedBy: _pt.string,
575
566
  children: _pt.node.isRequired,
576
567
  columnKey: _pt.string.isRequired,
577
- columnWidth: _pt.number,
568
+ columnWidth: _pt.string,
578
569
  shouldWrap: _pt.bool,
579
570
  isSortable: _pt.bool,
580
571
  isCondensed: _pt.bool,
@@ -869,7 +860,7 @@ var useManualColumnResizing = function useManualColumnResizing(tableRef) {
869
860
  var newColumnsSizes = setColumnWidth(state.sizes, columnIndex, width);
870
861
  if (!((_state$tableRef2 = state.tableRef) !== null && _state$tableRef2 !== void 0 && _state$tableRef2.current)) return;
871
862
  state.tableRef.current.style.gridTemplateColumns = getGridTemplateColumnsStyle(_mapInstanceProperty(newColumnsSizes).call(newColumnsSizes, function (newColumnsSize) {
872
- return newColumnsSize.width;
863
+ return newColumnsSize.width.toString();
873
864
  }));
874
865
  });
875
866
  };
@@ -957,6 +948,7 @@ var shouldRenderRowBottomBorder = function shouldRenderRowBottomBorder(rowIndex,
957
948
  };
958
949
 
959
950
  var defaultProps = {
951
+ columns: [],
960
952
  isCondensed: false,
961
953
  wrapHeaderLabels: true,
962
954
  verticalCellAlignment: 'top',
@@ -971,7 +963,7 @@ var defaultProps = {
971
963
  var DataTable = function DataTable(props) {
972
964
  var _context2, _context3;
973
965
 
974
- process.env.NODE_ENV !== "production" ? warning(_Array$isArray(props.columns), "ui-kit/DataTable: the prop \"columns\" is required.") : void 0;
966
+ process.env.NODE_ENV !== "production" ? warning(props.columns.length > 0, "ui-kit/DataTable: empty table \"columns\", expected at least one column. If you are using DataTableManager you need to pass the \"columns\" there and they will be injected into DataTable.") : void 0;
975
967
  var tableRef = useRef();
976
968
  var columnResizingReducer = useManualColumnResizing$1(tableRef); // if the table columns have been measured
977
969
  // and if the list of columns, their width field, or the isCondensed prop has changed
@@ -1010,7 +1002,7 @@ var DataTable = function DataTable(props) {
1010
1002
  value: columnResizingReducer,
1011
1003
  children: [jsx(Header, {
1012
1004
  children: jsx(Row, {
1013
- children: props.columns && _mapInstanceProperty(_context2 = props.columns).call(_context2, function (column) {
1005
+ children: _mapInstanceProperty(_context2 = props.columns).call(_context2, function (column) {
1014
1006
  return jsx(HeaderCell$1, {
1015
1007
  shouldWrap: props.wrapHeaderLabels,
1016
1008
  isCondensed: props.isCondensed,
@@ -1058,7 +1050,7 @@ DataTable.propTypes = process.env.NODE_ENV !== "production" ? {
1058
1050
  columns: _pt.arrayOf(_pt.shape({
1059
1051
  key: _pt.string.isRequired,
1060
1052
  label: _pt.node.isRequired,
1061
- width: _pt.number,
1053
+ width: _pt.string,
1062
1054
  align: _pt.oneOf(['left', 'center', 'right']),
1063
1055
  onClick: _pt.func,
1064
1056
  renderItem: _pt.func,
@@ -1089,6 +1081,6 @@ DataTable.displayName = 'DataTable';
1089
1081
  var DataTable$1 = DataTable;
1090
1082
 
1091
1083
  // NOTE: This string will be replaced on build time with the package version.
1092
- var version = "12.2.5";
1084
+ var version = "12.2.9";
1093
1085
 
1094
1086
  export { DataTable$1 as default, version };
@@ -13,13 +13,9 @@ export declare type TDataCell = {
13
13
  handleRowCollapseClick?: () => void;
14
14
  isRowCollapsed?: boolean;
15
15
  };
16
- declare type TDefaultProps = {
17
- isTruncated: boolean;
18
- shouldRenderBottomBorder: boolean;
19
- };
20
16
  declare const DataCell: {
21
17
  (props: TDataCell): import("@emotion/react/jsx-runtime").JSX.Element;
22
18
  displayName: string;
23
- defaultProps: TDefaultProps;
19
+ defaultProps: Pick<TDataCell, "isTruncated" | "shouldRenderBottomBorder">;
24
20
  };
25
21
  export default DataCell;
@@ -5,7 +5,7 @@ export interface TRow {
5
5
  export declare type TColumn<Row extends TRow = TRow> = {
6
6
  key: string;
7
7
  label: ReactNode;
8
- width?: number;
8
+ width?: string;
9
9
  align?: 'left' | 'center' | 'right';
10
10
  onClick?: (event: MouseEventHandler) => void;
11
11
  renderItem?: (row: Row, isRowCollapsed: boolean) => ReactNode;
@@ -36,7 +36,7 @@ export declare type TDataTableProps<Row extends TRow = TRow> = {
36
36
  };
37
37
  declare const DataTable: {
38
38
  <Row extends TRow = TRow>(props: TDataTableProps<Row>): import("@emotion/react/jsx-runtime").JSX.Element;
39
- defaultProps: Pick<TDataTableProps<TRow>, "isCondensed" | "wrapHeaderLabels" | "horizontalCellAlignment" | "verticalCellAlignment" | "disableSelfContainment" | "itemRenderer">;
39
+ defaultProps: Pick<TDataTableProps<TRow>, "columns" | "isCondensed" | "wrapHeaderLabels" | "horizontalCellAlignment" | "verticalCellAlignment" | "disableSelfContainment" | "itemRenderer">;
40
40
  displayName: string;
41
41
  };
42
42
  export default DataTable;
@@ -5,7 +5,7 @@ export declare type THeaderCell = {
5
5
  sortedBy?: string;
6
6
  children: ReactNode;
7
7
  columnKey: string;
8
- columnWidth?: number;
8
+ columnWidth?: string;
9
9
  shouldWrap?: boolean;
10
10
  isSortable?: boolean;
11
11
  isCondensed?: boolean;
@@ -6,7 +6,7 @@ declare type TGetSortableHeaderStyles = {
6
6
  declare const HeaderCellInner: import("@emotion/styled").StyledComponent<{
7
7
  theme?: import("@emotion/react").Theme | undefined;
8
8
  as?: import("react").ElementType<any> | undefined;
9
- } & Pick<THeaderCell, "isCondensed" | "horizontalCellAlignment" | "shouldWrap" | "isSortable"> & TGetSortableHeaderStyles, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
9
+ } & Pick<THeaderCell, "isCondensed" | "horizontalCellAlignment" | "isSortable" | "shouldWrap"> & TGetSortableHeaderStyles, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
10
10
  declare type TBaseHeaderCell = {
11
11
  disableHeaderStickiness?: boolean;
12
12
  shouldClipContent?: boolean;
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": "12.2.5",
4
+ "version": "12.2.9",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,12 +9,7 @@
9
9
  "directory": "packages/components/data-table"
10
10
  },
11
11
  "homepage": "https://uikit.commercetools.com",
12
- "keywords": [
13
- "javascript",
14
- "design system",
15
- "react",
16
- "uikit"
17
- ],
12
+ "keywords": ["javascript", "design system", "react", "uikit"],
18
13
  "license": "MIT",
19
14
  "publishConfig": {
20
15
  "access": "public"
@@ -22,18 +17,16 @@
22
17
  "sideEffects": false,
23
18
  "main": "dist/commercetools-uikit-data-table.cjs.js",
24
19
  "module": "dist/commercetools-uikit-data-table.esm.js",
25
- "files": [
26
- "dist"
27
- ],
20
+ "files": ["dist"],
28
21
  "dependencies": {
29
- "@babel/runtime": "7.16.3",
30
- "@babel/runtime-corejs3": "7.16.3",
31
- "@commercetools-uikit/accessible-button": "12.2.5",
32
- "@commercetools-uikit/design-system": "12.2.5",
33
- "@commercetools-uikit/hooks": "12.2.5",
34
- "@commercetools-uikit/icons": "12.2.5",
35
- "@commercetools-uikit/secondary-icon-button": "12.2.5",
36
- "@commercetools-uikit/utils": "12.2.5",
22
+ "@babel/runtime": "7.16.5",
23
+ "@babel/runtime-corejs3": "7.16.5",
24
+ "@commercetools-uikit/accessible-button": "12.2.9",
25
+ "@commercetools-uikit/design-system": "12.2.9",
26
+ "@commercetools-uikit/hooks": "12.2.9",
27
+ "@commercetools-uikit/icons": "12.2.9",
28
+ "@commercetools-uikit/secondary-icon-button": "12.2.9",
29
+ "@commercetools-uikit/utils": "12.2.9",
37
30
  "@emotion/react": "^11.4.0",
38
31
  "@emotion/styled": "^11.3.0",
39
32
  "lodash": "4.17.21",