mig-schema-table 3.0.30 → 3.0.31

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.
@@ -8,7 +8,6 @@ import { SELECT_ALL_COLUMN_NAME, SELECT_ALL_COLUMN_WIDTH } from "./constants";
8
8
  import Td from "./Td";
9
9
  import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
10
10
  import SchemaColumnFilterPopover from "./SchemaColumnFilterPopover";
11
- import { sum } from "lodash";
12
11
  function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, }) {
13
12
  const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
14
13
  const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
@@ -129,25 +128,21 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
129
128
  }, [columnNames, config]);
130
129
  const columnWidths = React.useMemo(() => {
131
130
  const dynamicColumnWidth = Math.floor((width - fixedWidthColumnsWidth) / dynamicWidthColumnCount);
132
- const result = columnNames.map((propName) => {
131
+ let roundingDifference = (width - fixedWidthColumnsWidth) % dynamicWidthColumnCount;
132
+ return columnNames.map((propName) => {
133
133
  if (propName === SELECT_ALL_COLUMN_NAME) {
134
134
  return SELECT_ALL_COLUMN_WIDTH;
135
135
  }
136
136
  const propConfig = config ? config[propName] : undefined;
137
- return (propConfig === null || propConfig === void 0 ? void 0 : propConfig.width) || dynamicColumnWidth;
138
- });
139
- const totalWidth = sum(result);
140
- if (totalWidth < width && dynamicWidthColumnCount) {
141
- // find the last dynamic width column and adjust to overcome rounding differences
142
- const lastDynamicColumnName = [...columnNames]
143
- .reverse()
144
- .find((propName) => !config || !config[propName].width);
145
- if (lastDynamicColumnName) {
146
- const lastDynamicColumnIndex = columnNames.indexOf(lastDynamicColumnName);
147
- result[lastDynamicColumnIndex] += width - totalWidth;
137
+ if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.width) {
138
+ return propConfig === null || propConfig === void 0 ? void 0 : propConfig.width;
148
139
  }
149
- }
150
- return result;
140
+ if (roundingDifference) {
141
+ roundingDifference -= 1;
142
+ return dynamicColumnWidth + 1;
143
+ }
144
+ return dynamicColumnWidth;
145
+ });
151
146
  }, [
152
147
  columnNames,
153
148
  config,
@@ -309,6 +304,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
309
304
  columnNames,
310
305
  config,
311
306
  data,
307
+ disabledCheckedIndexes,
312
308
  getRowClassName,
313
309
  getRowSelected,
314
310
  onCheckedIndexesChange,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mig-schema-table",
3
- "version": "3.0.30",
3
+ "version": "3.0.31",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/"