@carbon/ibm-products 2.42.1-canary.18 → 2.42.1-canary.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,16 +63,21 @@ var useNestedRows = function useNestedRows(hooks) {
63
63
  }
64
64
  }];
65
65
  };
66
+ var getIndentation = function getIndentation(depth) {
67
+ return 32 * depth + 16;
68
+ }; // row indentation padding
66
69
  var getCellProps = function getCellProps(props, _ref3) {
67
70
  var cell = _ref3.cell,
68
71
  instance = _ref3.instance;
69
- // reduce the "first cell"s width to compensate added (left) margin
72
+ // we add a dynamic -ve margin right only if the cell is resized below minimum width i.e 50px, else we set the width based on indentation at different levels
70
73
  var isFirstCell = instance.columns.findIndex(function (c) {
71
74
  return c.id === cell.column.id;
72
75
  }) === 0;
73
76
  return [props, {
74
77
  style: {
75
- marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "".concat(-32 * cell.row.depth - 18, "px") : '')
78
+ marginRight: isFirstCell && cell.row.depth > 0 && parseInt(props.style.width, 10) <= getIndentation(cell.row.depth) + 50 // indentation padding + expander cell or empty cell width
79
+ ? "".concat(parseInt(props.style.width, 10) - (getIndentation(cell.row.depth) + 50), "px") : '',
80
+ width: isFirstCell && cell.row.depth > 0 ? parseInt(props.style.width, 10) - getIndentation(cell.row.depth) : props.style.width
76
81
  }
77
82
  }];
78
83
  };
@@ -1 +1,8 @@
1
- export function getAutoSizedColumnWidth(rows: Array<object>, accessor: string, headerText: string): number;
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Row } from 'react-table';
8
+ export declare const getAutoSizedColumnWidth: (rows: Array<Row<object>>, accessor: string, headerText: string) => number;
@@ -14,13 +14,6 @@ import { toConsumableArray as _toConsumableArray } from '../../../_virtual/_roll
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  */
16
16
 
17
- /**
18
- * Calculates the auto sized width of a column
19
- * @param {Array<object>} rows - The datagrid rows
20
- * @param {string} accessor - The accessor for the column
21
- * @param {string} headerText - The header text for the column
22
- */
23
-
24
17
  var getAutoSizedColumnWidth = function getAutoSizedColumnWidth(rows, accessor, headerText) {
25
18
  var maxWidth = 400;
26
19
  var minWidth = 58;
@@ -71,16 +71,21 @@ var useNestedRows = function useNestedRows(hooks) {
71
71
  }
72
72
  }];
73
73
  };
74
+ var getIndentation = function getIndentation(depth) {
75
+ return 32 * depth + 16;
76
+ }; // row indentation padding
74
77
  var getCellProps = function getCellProps(props, _ref3) {
75
78
  var cell = _ref3.cell,
76
79
  instance = _ref3.instance;
77
- // reduce the "first cell"s width to compensate added (left) margin
80
+ // we add a dynamic -ve margin right only if the cell is resized below minimum width i.e 50px, else we set the width based on indentation at different levels
78
81
  var isFirstCell = instance.columns.findIndex(function (c) {
79
82
  return c.id === cell.column.id;
80
83
  }) === 0;
81
84
  return [props, {
82
85
  style: {
83
- marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "".concat(-32 * cell.row.depth - 18, "px") : '')
86
+ marginRight: isFirstCell && cell.row.depth > 0 && parseInt(props.style.width, 10) <= getIndentation(cell.row.depth) + 50 // indentation padding + expander cell or empty cell width
87
+ ? "".concat(parseInt(props.style.width, 10) - (getIndentation(cell.row.depth) + 50), "px") : '',
88
+ width: isFirstCell && cell.row.depth > 0 ? parseInt(props.style.width, 10) - getIndentation(cell.row.depth) : props.style.width
84
89
  }
85
90
  }];
86
91
  };
@@ -1 +1,8 @@
1
- export function getAutoSizedColumnWidth(rows: Array<object>, accessor: string, headerText: string): number;
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Row } from 'react-table';
8
+ export declare const getAutoSizedColumnWidth: (rows: Array<Row<object>>, accessor: string, headerText: string) => number;
@@ -18,13 +18,6 @@ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHel
18
18
  * LICENSE file in the root directory of this source tree.
19
19
  */
20
20
 
21
- /**
22
- * Calculates the auto sized width of a column
23
- * @param {Array<object>} rows - The datagrid rows
24
- * @param {string} accessor - The accessor for the column
25
- * @param {string} headerText - The header text for the column
26
- */
27
-
28
21
  var getAutoSizedColumnWidth = function getAutoSizedColumnWidth(rows, accessor, headerText) {
29
22
  var maxWidth = 400;
30
23
  var minWidth = 58;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.42.1-canary.18+07b412455",
4
+ "version": "2.42.1-canary.21+608e9b187",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -121,5 +121,5 @@
121
121
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
122
122
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
123
123
  },
124
- "gitHead": "07b4124551093f8dc2f4db978201feecdace2e22"
124
+ "gitHead": "608e9b187c9de9f53094272bbefd0e2780b5cfeb"
125
125
  }