mig-schema-table 3.0.93 → 3.0.94
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,25 +11,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import React from "react";
|
|
14
|
-
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, } from "../../../inc/constant";
|
|
14
|
+
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, ENumberColumnFilterOperation, } from "../../../inc/constant";
|
|
15
15
|
import DatePicker from "react-datepicker";
|
|
16
16
|
import nl from "date-fns/locale/nl";
|
|
17
17
|
import { endOfDay } from "date-fns";
|
|
18
|
+
const numberColumnFilterOperationsLabelMap = {
|
|
19
|
+
[ENumberColumnFilterOperation.GT]: ">",
|
|
20
|
+
[ENumberColumnFilterOperation.LT]: "<",
|
|
21
|
+
[ENumberColumnFilterOperation.EQ]: "=",
|
|
22
|
+
};
|
|
18
23
|
const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown, propIsRequired, propName, propSchema, translate, }) => {
|
|
19
24
|
const { type, format, minimum, maximum } = propSchema || {};
|
|
20
25
|
const value = columnFilterValue;
|
|
21
26
|
const isDateTime = format === "date-time";
|
|
22
27
|
switch (type) {
|
|
28
|
+
case "number":
|
|
23
29
|
case "integer":
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const numberColumnFilterValue = (value || {});
|
|
31
|
+
const changeOperationValue = (operation, el, persistState) => {
|
|
32
|
+
const newValue = Object.assign(Object.assign({}, numberColumnFilterValue), { [operation]: el.value === "" ? undefined : parseInt(el.value) });
|
|
33
|
+
const hasValue = Object.values(newValue).find((opValue) => isFinite(opValue));
|
|
34
|
+
onChange(hasValue ? newValue : undefined, persistState);
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs("ol", Object.assign({ className: "schema-table-menu schema-table__th-menu__filter-menu-component" }, { children: [propIsRequired ? null : (_jsxs("li", Object.assign({ style: { padding: 8 } }, { children: [_jsxs("label", Object.assign({ className: "d-flex" }, { children: [_jsx("input", { type: "checkbox", style: { marginRight: 14 }, checked: !!numberColumnFilterValue.filterEmpty, onChange: () => {
|
|
37
|
+
const { filterEmpty } = numberColumnFilterValue, newNumberColumnFilterValue = __rest(numberColumnFilterValue, ["filterEmpty"]);
|
|
38
|
+
if (!filterEmpty) {
|
|
39
|
+
newNumberColumnFilterValue.filterEmpty = true;
|
|
40
|
+
}
|
|
41
|
+
onChange(Object.keys(newNumberColumnFilterValue).length
|
|
42
|
+
? newNumberColumnFilterValue
|
|
43
|
+
: undefined, true);
|
|
44
|
+
} }), "Hide empty values"] })), _jsx("hr", {})] }))), Object.keys(ENumberColumnFilterOperation).map((operation) => {
|
|
45
|
+
return (_jsxs("li", { children: [_jsx("label", Object.assign({ style: { width: 40, paddingLeft: 16 } }, { children: numberColumnFilterOperationsLabelMap[operation] })), _jsx("input", { className: "form-control", style: { width: 120 }, type: "number", value: numberColumnFilterValue[operation] || "", "data-prop-name": propName, onChange: (e) => {
|
|
46
|
+
changeOperationValue(operation, e.currentTarget, false);
|
|
47
|
+
}, onBlur: (e) => {
|
|
48
|
+
changeOperationValue(operation, e.currentTarget, true);
|
|
49
|
+
}, onKeyDown: onInputKeyDown, min: minimum, max: maximum })] }, operation));
|
|
50
|
+
})] })));
|
|
33
51
|
case "boolean":
|
|
34
52
|
let selectValue = value ? "✓" : "✕";
|
|
35
53
|
if (value === undefined) {
|
|
@@ -65,7 +83,7 @@ const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown, prop
|
|
|
65
83
|
to: undefined,
|
|
66
84
|
filterEmpty: undefined,
|
|
67
85
|
});
|
|
68
|
-
return (_jsxs("ol", Object.assign({ className: "schema-table-menu schema-table__th-menu__filter-menu-component" }, { children: [propIsRequired ? null : (_jsxs("li", Object.assign({ style: { padding: 8 } }, { children: [_jsxs("label", Object.assign({ className: "d-flex" }, { children: [_jsx("input", { type: "checkbox",
|
|
86
|
+
return (_jsxs("ol", Object.assign({ className: "schema-table-menu schema-table__th-menu__filter-menu-component" }, { children: [propIsRequired ? null : (_jsxs("li", Object.assign({ style: { padding: 8 } }, { children: [_jsxs("label", Object.assign({ className: "d-flex" }, { children: [_jsx("input", { type: "checkbox", checked: !!dateRangeValue.filterEmpty, onChange: () => {
|
|
69
87
|
const { filterEmpty } = dateRangeValue, newDateRangeValue = __rest(dateRangeValue, ["filterEmpty"]);
|
|
70
88
|
if (!filterEmpty) {
|
|
71
89
|
newDateRangeValue.filterEmpty = true;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { oas31 } from "openapi3-ts";
|
|
3
3
|
import { IColumnConfig, IRenderData } from "../types";
|
|
4
|
+
import { ENumberColumnFilterOperation } from "../inc/constant";
|
|
4
5
|
export interface IGetDataProps {
|
|
5
6
|
searchQuery: string;
|
|
6
7
|
columnFilterMap: {
|
|
@@ -50,7 +51,13 @@ export interface IDateColumnFilterValue {
|
|
|
50
51
|
to?: Date;
|
|
51
52
|
filterEmpty?: true;
|
|
52
53
|
}
|
|
53
|
-
export
|
|
54
|
+
export interface INumberColumnFilterValue {
|
|
55
|
+
[ENumberColumnFilterOperation.GT]: number;
|
|
56
|
+
[ENumberColumnFilterOperation.LT]: number;
|
|
57
|
+
[ENumberColumnFilterOperation.EQ]: number;
|
|
58
|
+
filterEmpty?: true;
|
|
59
|
+
}
|
|
60
|
+
export type TColumnFilterValue = string | boolean | IDateColumnFilterValue | INumberColumnFilterValue;
|
|
54
61
|
declare function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultColumnFilters, defaultSortAsc, defaultSortColumn, disabledCheckedIndexes, enableAutoFocus, enableRowCounter, getRowClassName, getRowSelected, isColumnFilterable, isExportable, isSearchable, isSortable, maxHeight, onCheckedIndexesChange, onRowClick, onRowDoubleClick, onSearchEnter, rowHeight, schema, searchPlaceholder, style, translate, useFilterStateHash, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
55
62
|
declare const _default: typeof SchemaTable;
|
|
56
63
|
export default _default;
|
|
@@ -16,7 +16,7 @@ import { localeFormat } from "../inc/date";
|
|
|
16
16
|
import { defaultTranslate } from "../inc/string";
|
|
17
17
|
import { SELECT_ALL_COLUMN_NAME, SELECT_ALL_COLUMN_WIDTH } from "./constants";
|
|
18
18
|
import Td from "./Td";
|
|
19
|
-
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
|
|
19
|
+
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, ENumberColumnFilterOperation, } from "../inc/constant";
|
|
20
20
|
import { parseLocationHash, serializeLocationHash } from "../inc/data";
|
|
21
21
|
import Th, { EColumnFilterStatus } from "./Th";
|
|
22
22
|
import ThMenu from "./ThMenu";
|
|
@@ -255,8 +255,38 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
255
255
|
const rawValue = sourceData[item._index][propName];
|
|
256
256
|
switch (propSchema === null || propSchema === void 0 ? void 0 : propSchema.type) {
|
|
257
257
|
case "boolean":
|
|
258
|
+
case "number":
|
|
258
259
|
case "integer":
|
|
259
|
-
|
|
260
|
+
if (typeof columnFilterValue === "object") {
|
|
261
|
+
if (columnFilterValue.filterEmpty && rawValue === undefined) {
|
|
262
|
+
result = false;
|
|
263
|
+
}
|
|
264
|
+
for (const operation of Object.keys(ENumberColumnFilterOperation)) {
|
|
265
|
+
const operationFilterValue = columnFilterValue[operation];
|
|
266
|
+
if (result && isFinite(operationFilterValue)) {
|
|
267
|
+
switch (operation) {
|
|
268
|
+
case ENumberColumnFilterOperation.EQ:
|
|
269
|
+
if (rawValue !== operationFilterValue) {
|
|
270
|
+
result = false;
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
case ENumberColumnFilterOperation.GT:
|
|
274
|
+
if (rawValue <= operationFilterValue) {
|
|
275
|
+
result = false;
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case ENumberColumnFilterOperation.LT:
|
|
279
|
+
if (rawValue >= operationFilterValue) {
|
|
280
|
+
result = false;
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
result = rawValue === columnFilterValue;
|
|
289
|
+
}
|
|
260
290
|
break;
|
|
261
291
|
// @ts-ignore
|
|
262
292
|
case "string":
|
package/dist/inc/constant.d.ts
CHANGED
package/dist/inc/constant.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export const DEFAULT_DATE_FORMAT = "dd MMM yyyy";
|
|
2
2
|
export const DEFAULT_DATE_TIME_FORMAT = "dd MMM yyyy HH:mm";
|
|
3
|
+
export var ENumberColumnFilterOperation;
|
|
4
|
+
(function (ENumberColumnFilterOperation) {
|
|
5
|
+
ENumberColumnFilterOperation["GT"] = "GT";
|
|
6
|
+
ENumberColumnFilterOperation["LT"] = "LT";
|
|
7
|
+
ENumberColumnFilterOperation["EQ"] = "EQ";
|
|
8
|
+
})(ENumberColumnFilterOperation || (ENumberColumnFilterOperation = {}));
|