mig-schema-table 3.0.30 → 3.0.32
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/dist/SchemaTable/index.js +11 -15
- package/dist/index.css +2 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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/dist/index.css
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
background-color: #eee;
|
|
37
37
|
align-items: center;
|
|
38
38
|
padding-left: 8px;
|
|
39
|
+
padding-right: 8px;
|
|
39
40
|
}
|
|
40
41
|
.schema-table__th div {
|
|
41
42
|
overflow: hidden;
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
white-space: nowrap;
|
|
59
60
|
text-overflow: ellipsis;
|
|
60
61
|
padding-left: 8px;
|
|
62
|
+
padding-right: 8px;
|
|
61
63
|
align-items: center;
|
|
62
64
|
}
|
|
63
65
|
.schema-table__td--odd {
|