mig-schema-table 3.0.34 → 3.0.36
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 +16 -4
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ 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
|
+
const startOfTheWorldDate = new Date("1000-01-01 00:00:00Z");
|
|
11
12
|
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, }) {
|
|
12
13
|
const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
|
|
13
14
|
const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
|
|
@@ -232,22 +233,33 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
|
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
235
|
return filteredRenderData.sort((a, b) => {
|
|
236
|
+
var _a;
|
|
237
|
+
const isDate = sortSchema && ((_a = sortSchema.format) === null || _a === void 0 ? void 0 : _a.startsWith("date"));
|
|
235
238
|
const sortByValue = (propConfig === null || propConfig === void 0 ? void 0 : propConfig.sortByValue) === undefined
|
|
236
239
|
? !sortSchema ||
|
|
240
|
+
isDate ||
|
|
237
241
|
sortSchema.type === "boolean" ||
|
|
238
242
|
sortSchema.type === "integer" ||
|
|
239
|
-
sortSchema.format === "date" ||
|
|
240
|
-
sortSchema.format === "date-time" ||
|
|
241
243
|
(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell)
|
|
242
244
|
: propConfig.sortByValue;
|
|
243
|
-
|
|
245
|
+
let x = sortByValue && data[a._index]
|
|
244
246
|
? // @ts-ignore
|
|
245
247
|
data[a._index][sortColumn]
|
|
246
248
|
: a[sortColumn].toLowerCase();
|
|
247
|
-
|
|
249
|
+
let y = sortByValue && data[b._index]
|
|
248
250
|
? // @ts-ignore
|
|
249
251
|
data[b._index][sortColumn]
|
|
250
252
|
: b[sortColumn].toLowerCase();
|
|
253
|
+
if (sortByValue && isDate) {
|
|
254
|
+
x = new Date(x);
|
|
255
|
+
if (isNaN(x)) {
|
|
256
|
+
x = startOfTheWorldDate;
|
|
257
|
+
}
|
|
258
|
+
y = new Date(y);
|
|
259
|
+
if (isNaN(y)) {
|
|
260
|
+
y = startOfTheWorldDate;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
251
263
|
if (x === y) {
|
|
252
264
|
return 0;
|
|
253
265
|
}
|