mig-schema-table 2.0.0 → 2.0.2
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.
|
@@ -25,7 +25,7 @@ const Th = ({ columnFilters, config, isSortable, name, schema, setColumnFilters,
|
|
|
25
25
|
setSortAsc((sortAsc) => !sortAsc);
|
|
26
26
|
}, [config === null || config === void 0 ? void 0 : config.defaultSortDesc, name, setSortAsc, setSortColumn, sortAsc]);
|
|
27
27
|
if (name === SELECT_ALL_COLUMN_NAME) {
|
|
28
|
-
return (_jsx("div", Object.assign({}, thDivProps, { children: _jsx("div", Object.assign({ style: { marginTop: 12
|
|
28
|
+
return (_jsx("div", Object.assign({}, thDivProps, { children: _jsx("div", Object.assign({ style: { marginTop: 12 }, title: `${numberOfSelectedRows || 0} selected` }, { children: _jsx("input", { type: "checkbox", checked: isAllChecked, onChange: onSelectAllIndexesHandler }) })) })));
|
|
29
29
|
}
|
|
30
30
|
if (!schema) {
|
|
31
31
|
return _jsx("div", Object.assign({}, thDivProps));
|
|
@@ -37,6 +37,10 @@ export default function SchemaTable(props) {
|
|
|
37
37
|
if (orderB === undefined) {
|
|
38
38
|
orderB = Object.keys(properties).findIndex((propName) => propName === columnB);
|
|
39
39
|
}
|
|
40
|
+
if (columnB === SELECT_ALL_COLUMN_NAME ||
|
|
41
|
+
columnA === SELECT_ALL_COLUMN_NAME) {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
40
44
|
if (orderA === -1) {
|
|
41
45
|
return 1;
|
|
42
46
|
}
|
|
@@ -116,6 +120,9 @@ export default function SchemaTable(props) {
|
|
|
116
120
|
const dynamicColumnWidth = Math.floor((gridWidth - 16 - fixedWidthColumnsWidth) / dynamicWidthColumnCount);
|
|
117
121
|
const columnWidths = columnNames.map((propName) => {
|
|
118
122
|
const propConfig = config ? config[propName] : undefined;
|
|
123
|
+
if (propName === SELECT_ALL_COLUMN_NAME) {
|
|
124
|
+
return 50;
|
|
125
|
+
}
|
|
119
126
|
return (propConfig === null || propConfig === void 0 ? void 0 : propConfig.width) || dynamicColumnWidth;
|
|
120
127
|
});
|
|
121
128
|
return { columnWidths, dynamicWidthColumnCount, fixedWidthColumnsWidth };
|
|
@@ -249,7 +256,7 @@ export default function SchemaTable(props) {
|
|
|
249
256
|
}
|
|
250
257
|
onCheckedIndexesChange([rowIndex]);
|
|
251
258
|
};
|
|
252
|
-
return (_jsx("div", Object.assign({}, tdDivProps, { children: _jsx("div", Object.assign({ style: {
|
|
259
|
+
return (_jsx("div", Object.assign({}, tdDivProps, { children: _jsx("div", Object.assign({ style: { marginLeft: 8 } }, { children: _jsx("input", { type: "checkbox", onChange: onChecked, checked: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.includes(rowIndex) }) })) })));
|
|
253
260
|
}
|
|
254
261
|
if (!schema) {
|
|
255
262
|
return null;
|
|
@@ -291,5 +298,13 @@ export default function SchemaTable(props) {
|
|
|
291
298
|
const totalWidth = React.useMemo(() => columnWidths.reduce((a, b) => {
|
|
292
299
|
return a + b;
|
|
293
300
|
}, 0), [columnWidths]);
|
|
294
|
-
|
|
301
|
+
const tableBodyHeight = React.useMemo(() => {
|
|
302
|
+
const defaultHeight = props.height - (isSearchable ? 50 : 0);
|
|
303
|
+
if (!sortedRenderData) {
|
|
304
|
+
return defaultHeight;
|
|
305
|
+
}
|
|
306
|
+
const dynamicHeight = sortedRenderData.length * rowHeight;
|
|
307
|
+
return dynamicHeight < defaultHeight ? dynamicHeight : defaultHeight;
|
|
308
|
+
}, [isSearchable, props.height, rowHeight, sortedRenderData]);
|
|
309
|
+
return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: dynamicWidthColumnCount ? gridWidth : fixedWidthColumnsWidth }) }, { children: [_jsx("div", Object.assign({ className: "tableTitle" }, { children: tableTitle })), _jsxs("div", Object.assign({ className: "action-container" }, { children: [_jsx("div", Object.assign({ style: { flex: 1 } }, { children: isSearchable ? (_jsx("input", { id: "input-filter", type: "text", placeholder: searchPlaceholder || "Search...", value: searchQuery, onChange: onSearchChange, autoFocus: true })) : null })), customElement] })), _jsx(Heading, Object.assign({ height: 50, itemCount: columnCount, itemSize: getColumnWidth, layout: "horizontal", width: width, sortAsc: sortAsc, setSortAsc: setSortAsc, setSortColumn: setSortColumn, sortColumn: sortColumn, sortedRenderData: sortedRenderData, className: "schema-table__th-row" }, { children: SchemaTableTh }), `thead_${width}_${sortColumn}_${sortAsc}_${searchQuery}`), _jsx(VariableSizeGrid, Object.assign({ className: "schema-table__tbody", height: tableBodyHeight, width: totalWidth, columnWidth: getColumnWidth, rowHeight: getRowHeight, columnCount: columnCount, rowCount: sortedRenderData ? sortedRenderData.length : 0 }, { children: Td }), `tbody_${width}_${sortColumn}_${sortAsc}_${searchQuery}_${columnCount}`)] })));
|
|
295
310
|
}
|