@insticc/react-datagrid-2 1.0.29 → 1.0.30

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.
@@ -202,13 +202,19 @@ var DataGrid = function DataGrid(_ref) {
202
202
  enableClickToCopy: (_column$enableClickTo = column.enableClickToCopy) !== null && _column$enableClickTo !== void 0 ? _column$enableClickTo : false,
203
203
  enableColumnActions: (_column$enableColumnA = column.enableColumnActions) !== null && _column$enableColumnA !== void 0 ? _column$enableColumnA : false,
204
204
  // sortingFn: --> basic default, datetime for date
205
- sortingFn: column.isDateColumn ? function (rowA, rowB, columnId) {
206
- var dateA = rowA.getValue(columnId) ? new Date(rowA.getValue(columnId)).getTime() : null;
207
- var dateB = rowB.getValue(columnId) ? new Date(rowB.getValue(columnId)).getTime() : null;
208
- if (dateA === null) return 1;
209
- if (dateB === null) return -1;
210
- return dateA - dateB; // Sort by timestamp
205
+ sortingFn: column.sortingFn ? column.sortingFn : column.isDateColumn // Use custom sorting for date columns
206
+ ? function (rowA, rowB, columnId) {
207
+ var valueA = rowA.getValue(columnId);
208
+ var valueB = rowB.getValue(columnId);
209
+ // Parse values as timestamps or handle invalid dates
210
+ var dateA = valueA && !isNaN(new Date(valueA).getTime()) ? new Date(valueA).getTime() : null;
211
+ var dateB = valueB && !isNaN(new Date(valueB).getTime()) ? new Date(valueB).getTime() : null;
212
+ if (dateA === null && dateB === null) return 0; // Both null, equal
213
+ if (dateA === null) return 1; // Null values go last
214
+ if (dateB === null) return -1; // Null values go last
215
+ return dateA - dateB; // Compare by timestamp
211
216
  } : 'basic',
217
+ // Use default sorting for non-date columns
212
218
  Cell: function Cell(props) {
213
219
  return column.cellClass ? /*#__PURE__*/_react["default"].createElement("div", {
214
220
  className: column.cellClass
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insticc/react-datagrid-2",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {