cloudmr-ux 4.2.7 → 4.2.8
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.
|
@@ -11,6 +11,12 @@ export interface CmrTableProps extends Omit<DataGridProps, 'rows'> {
|
|
|
11
11
|
headerBgColor?: string;
|
|
12
12
|
headerTextColor?: string;
|
|
13
13
|
headerIconColor?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional function to customize how rows are filtered/sorted before display.
|
|
16
|
+
* Receives the mapped rows; return a new array in the desired order.
|
|
17
|
+
* When omitted, rows are sorted by most recently submitted (createdAt/created_at descending).
|
|
18
|
+
*/
|
|
19
|
+
processRows?: (rows: any[]) => any[];
|
|
14
20
|
}
|
|
15
21
|
declare const CmrTable: React.FC<CmrTableProps>;
|
|
16
22
|
export default CmrTable;
|
|
@@ -20,14 +20,38 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
+
if (ar || !(i in from)) {
|
|
26
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
+
ar[i] = from[i];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
+
};
|
|
23
32
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
33
|
import './CmrTable.css';
|
|
25
34
|
import { DataGrid } from '@mui/x-data-grid';
|
|
35
|
+
/** Extracts a comparable timestamp from a row for sorting. Supports createdAt, created_at, or similar date fields. */
|
|
36
|
+
function getSubmittedTimestamp(row) {
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
var val = (_c = (_b = (_a = row.createdAt) !== null && _a !== void 0 ? _a : row.created_at) !== null && _b !== void 0 ? _b : row.updatedAt) !== null && _c !== void 0 ? _c : row.updated_at;
|
|
39
|
+
if (val == null)
|
|
40
|
+
return 0;
|
|
41
|
+
var ts = typeof val === 'number' ? val : new Date(val).getTime();
|
|
42
|
+
return isNaN(ts) ? 0 : ts;
|
|
43
|
+
}
|
|
44
|
+
/** Default sort: most recently submitted first (by createdAt or created_at descending). */
|
|
45
|
+
function defaultSortByRecent(rows) {
|
|
46
|
+
return __spreadArray([], rows, true).sort(function (a, b) { return getSubmittedTimestamp(b) - getSubmittedTimestamp(a); });
|
|
47
|
+
}
|
|
26
48
|
var CmrTable = function (props) {
|
|
27
|
-
var dataSource = props.dataSource, columns = props.columns, idAlias = props.idAlias, className = props.className, onRowSelectionModelChange = props.onRowSelectionModelChange, style = props.style, _a = props.showCheckbox, showCheckbox = _a === void 0 ? true : _a, _b = props.headerBgColor, headerBgColor = _b === void 0 ? '#F3E5F5' : _b, _c = props.headerTextColor, headerTextColor = _c === void 0 ? '#333' : _c, _d = props.headerIconColor, headerIconColor = _d === void 0 ? '#580f8b' : _d, rest = __rest(props, ["dataSource", "columns", "idAlias", "className", "onRowSelectionModelChange", "style", "showCheckbox", "headerBgColor", "headerTextColor", "headerIconColor"]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
var dataSource = props.dataSource, columns = props.columns, idAlias = props.idAlias, className = props.className, onRowSelectionModelChange = props.onRowSelectionModelChange, style = props.style, _a = props.showCheckbox, showCheckbox = _a === void 0 ? true : _a, _b = props.headerBgColor, headerBgColor = _b === void 0 ? '#F3E5F5' : _b, _c = props.headerTextColor, headerTextColor = _c === void 0 ? '#333' : _c, _d = props.headerIconColor, headerIconColor = _d === void 0 ? '#580f8b' : _d, processRows = props.processRows, rest = __rest(props, ["dataSource", "columns", "idAlias", "className", "onRowSelectionModelChange", "style", "showCheckbox", "headerBgColor", "headerTextColor", "headerIconColor", "processRows"]);
|
|
50
|
+
var mappedRows = dataSource
|
|
51
|
+
? dataSource.map(function (row) { return (__assign({ id: idAlias ? row[idAlias] : row['id'] }, row)); })
|
|
52
|
+
: [];
|
|
53
|
+
var displayRows = processRows ? processRows(mappedRows) : defaultSortByRecent(mappedRows);
|
|
54
|
+
return (_jsx("div", __assign({ style: style !== null && style !== void 0 ? style : { height: '400px', width: '100%' }, className: className !== null && className !== void 0 ? className : '' }, { children: _jsx(DataGrid, __assign({ rows: displayRows, columns: columns, checkboxSelection: showCheckbox, onRowSelectionModelChange: onRowSelectionModelChange, initialState: {
|
|
31
55
|
pagination: {
|
|
32
56
|
paginationModel: { pageSize: 50, page: 0 }
|
|
33
57
|
}
|
|
@@ -214,8 +214,7 @@ var Upload = function () {
|
|
|
214
214
|
// return !name.endsWith(".zip") && !name.endsWith(".nii");
|
|
215
215
|
// TODO RJW: does this make sense? confusing if you upload a zip, it just disappears
|
|
216
216
|
return true; // Show all files for now
|
|
217
|
-
})
|
|
218
|
-
.reverse(), rowSelectionModel: selectedData, onRowSelectionModelChange: function (rowSelectionModel) {
|
|
217
|
+
}), rowSelectionModel: selectedData, onRowSelectionModelChange: function (rowSelectionModel) {
|
|
219
218
|
setSelectedData(rowSelectionModel);
|
|
220
219
|
}, columns: uploadedFilesColumns }), _jsxs("div", __assign({ className: "row mt-2" }, { children: [_jsx("div", __assign({ className: "col-4" }, { children: _jsxs(Button, __assign({ color: "error", style: { textTransform: "none" }, variant: "contained", fullWidth: true, onClick: function () {
|
|
221
220
|
setName("Deleting Data");
|