mig-schema-table 3.0.58 → 3.0.60

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.
@@ -4,6 +4,7 @@ import { t } from "../../../inc/string";
4
4
  import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, } from "../../../inc/constant";
5
5
  import DatePicker from "react-datepicker";
6
6
  import nl from "date-fns/locale/nl";
7
+ import { endOfDay } from "date-fns";
7
8
  const FilterFormComponent = ({ columnFilterValue, onChange, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, }) => {
8
9
  const { type, format, minimum, maximum } = propSchema;
9
10
  const value = columnFilterValue;
@@ -66,12 +67,11 @@ const FilterFormComponent = ({ columnFilterValue, onChange, onInputKeyDown, prop
66
67
  onChange(undefined);
67
68
  return;
68
69
  }
69
- if (dateRangeValue.from &&
70
- date &&
71
- date < dateRangeValue.from) {
70
+ const to = date ? endOfDay(date) : undefined;
71
+ if (dateRangeValue.from && to && to < dateRangeValue.from) {
72
72
  return;
73
73
  }
74
- onChange(Object.assign(Object.assign({}, columnFilterValue), { to: date || undefined }));
74
+ onChange(Object.assign(Object.assign({}, columnFilterValue), { to }));
75
75
  }, placeholderText: dateFormat, isClearable: true, startDate: dateRangeValue.from, endDate: dateRangeValue.to, showTimeSelect: format === "date-time", timeIntervals: 15, shouldCloseOnSelect: format === "date" })] }))] }))] }));
76
76
  }
77
77
  // falls through
@@ -9,6 +9,20 @@ import Td from "./Td";
9
9
  import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
10
10
  import SchemaColumnFilterPopover from "./SchemaColumnFilterPopover";
11
11
  const startOfTheWorldDate = new Date("1000-01-01 00:00:00Z");
12
+ function getSortByValue(propSchema, propConfig) {
13
+ var _a;
14
+ if ((propConfig === null || propConfig === void 0 ? void 0 : propConfig.sortByValue) !== undefined) {
15
+ return propConfig === null || propConfig === void 0 ? void 0 : propConfig.sortByValue;
16
+ }
17
+ if (!propSchema) {
18
+ return false;
19
+ }
20
+ const isDate = propSchema && ((_a = propSchema.format) === null || _a === void 0 ? void 0 : _a.startsWith("date"));
21
+ return (isDate ||
22
+ propSchema.type === "boolean" ||
23
+ propSchema.type === "integer" ||
24
+ !!(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell));
25
+ }
12
26
  function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultColumnFilters = {}, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, onRowDoubleClick, enableAutoFocus, }) {
13
27
  const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
14
28
  const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
@@ -254,6 +268,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
254
268
  ]);
255
269
  // Sort the filtered data
256
270
  const sortedRenderData = React.useMemo(() => {
271
+ var _a;
257
272
  if (!sortColumn || !filteredRenderData || !sourceData || isDataFunction) {
258
273
  return filteredRenderData;
259
274
  }
@@ -273,16 +288,9 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
273
288
  return columnSort(aData, bData, sortAsc);
274
289
  });
275
290
  }
291
+ const isDate = sortSchema && ((_a = sortSchema.format) === null || _a === void 0 ? void 0 : _a.startsWith("date"));
292
+ const sortByValue = getSortByValue(sortSchema, propConfig);
276
293
  return filteredRenderData.sort((a, b) => {
277
- var _a;
278
- const isDate = sortSchema && ((_a = sortSchema.format) === null || _a === void 0 ? void 0 : _a.startsWith("date"));
279
- const sortByValue = (propConfig === null || propConfig === void 0 ? void 0 : propConfig.sortByValue) === undefined
280
- ? !sortSchema ||
281
- isDate ||
282
- sortSchema.type === "boolean" ||
283
- sortSchema.type === "integer" ||
284
- (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell)
285
- : propConfig.sortByValue;
286
294
  let x = sortByValue && sourceData[a._index]
287
295
  ? // @ts-ignore
288
296
  sourceData[a._index][sortColumn]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mig-schema-table",
3
- "version": "3.0.58",
3
+ "version": "3.0.60",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/"