mig-schema-table 3.0.16 → 3.0.18
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/ColumnFilterRow/index.d.ts +7 -3
- package/dist/SchemaTable/ColumnFilterRow/index.js +65 -15
- package/dist/SchemaTable/Th/index.d.ts +4 -1
- package/dist/SchemaTable/Th/index.js +12 -2
- package/dist/SchemaTable/index.d.ts +4 -0
- package/dist/SchemaTable/index.js +52 -30
- package/dist/inc/constant.d.ts +2 -2
- package/dist/inc/constant.js +2 -2
- package/dist/inc/date.d.ts +1 -0
- package/dist/inc/date.js +4 -0
- package/dist/index.css +1 -4
- package/package.json +1 -1
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from "react";
|
|
1
2
|
import { IColumnConfig } from "../../types";
|
|
2
3
|
import { oas31 } from "openapi3-ts";
|
|
3
4
|
import "react-datepicker/dist/react-datepicker.css";
|
|
5
|
+
import { tColumnSearchValue } from "../index";
|
|
4
6
|
interface IColumnFilterRowProps {
|
|
5
7
|
columnNames: string[];
|
|
6
8
|
getWidth: (index: number) => number;
|
|
7
9
|
config?: {
|
|
8
10
|
[propName: string]: IColumnConfig<any>;
|
|
9
11
|
};
|
|
10
|
-
columnSearchHandler: (propName: string, value:
|
|
12
|
+
columnSearchHandler: (propName: string, value: tColumnSearchValue) => void;
|
|
11
13
|
value: {
|
|
12
|
-
[propName: string]:
|
|
14
|
+
[propName: string]: tColumnSearchValue;
|
|
13
15
|
};
|
|
14
16
|
schema: oas31.SchemaObject;
|
|
17
|
+
columnFilterDropdown?: string;
|
|
18
|
+
setColumnFilterDropdown?: Dispatch<SetStateAction<string | undefined>>;
|
|
15
19
|
}
|
|
16
|
-
export default function ColumnFilterRow({ columnNames, getWidth, config, value, columnSearchHandler, schema, }: IColumnFilterRowProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default function ColumnFilterRow({ columnNames, getWidth, config, value, columnSearchHandler, schema, columnFilterDropdown, setColumnFilterDropdown, }: IColumnFilterRowProps): import("react/jsx-runtime").JSX.Element;
|
|
17
21
|
export {};
|
|
@@ -4,15 +4,15 @@ import { SELECT_ALL_COLUMN_NAME } from "../constants";
|
|
|
4
4
|
import DatePicker from "react-datepicker";
|
|
5
5
|
import nl from "date-fns/locale/nl";
|
|
6
6
|
import "react-datepicker/dist/react-datepicker.css";
|
|
7
|
-
import { localeFormat } from "../../inc/date";
|
|
8
7
|
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, } from "../../inc/constant";
|
|
9
|
-
|
|
8
|
+
import { getUnixTimeStamp } from "../../inc/date";
|
|
9
|
+
export default function ColumnFilterRow({ columnNames, getWidth, config, value, columnSearchHandler, schema, columnFilterDropdown, setColumnFilterDropdown, }) {
|
|
10
10
|
const { properties = {} } = schema;
|
|
11
11
|
const getSelectComponent = React.useCallback((propSchema, propName, value, inputChangeHandler) => {
|
|
12
|
-
const enumItems = propSchema.type === "boolean" ? ["
|
|
12
|
+
const enumItems = propSchema.type === "boolean" ? ["✓", "✕"] : propSchema.enum;
|
|
13
13
|
return (_jsxs("select", Object.assign({ value: value, "data-prop-name": propName, onChange: inputChangeHandler }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), enumItems.map((name) => (_jsx("option", Object.assign({ value: name }, { children: name }), `column-filter-select-${name}`)))] })));
|
|
14
14
|
}, []);
|
|
15
|
-
const field = React.useCallback((propSchema, propName, propValue
|
|
15
|
+
const field = React.useCallback((propSchema, propName, propValue) => {
|
|
16
16
|
const { type, format, minimum, maximum } = propSchema;
|
|
17
17
|
const inputChangeHandler = (event) => {
|
|
18
18
|
columnSearchHandler(propName, event.target.value);
|
|
@@ -24,24 +24,68 @@ export default function ColumnFilterRow({ columnNames, getWidth, config, value,
|
|
|
24
24
|
return getSelectComponent(propSchema, propName, strValue, inputChangeHandler);
|
|
25
25
|
}
|
|
26
26
|
if (format === "date-time" || format === "date") {
|
|
27
|
-
const dateFormat =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
27
|
+
const dateFormat = format === "date"
|
|
28
|
+
? DEFAULT_DATE_FORMAT
|
|
29
|
+
: DEFAULT_DATE_TIME_FORMAT;
|
|
30
|
+
const dateRangeValue = propValue;
|
|
31
|
+
const startDate = (dateRangeValue === null || dateRangeValue === void 0 ? void 0 : dateRangeValue.from)
|
|
32
|
+
? new Date(dateRangeValue.from)
|
|
33
|
+
: null;
|
|
34
|
+
const endDate = (dateRangeValue === null || dateRangeValue === void 0 ? void 0 : dateRangeValue.to)
|
|
35
|
+
? new Date(dateRangeValue.to)
|
|
36
|
+
: null;
|
|
37
|
+
const startDateChangeHandler = (date) => {
|
|
38
|
+
if (endDate && date && date > endDate) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
columnSearchHandler(propName, Object.assign(Object.assign({}, dateRangeValue), { from: `${date || ""}`, to: `${date && endDate ? dateRangeValue.to : ""}` }));
|
|
33
42
|
};
|
|
34
|
-
|
|
43
|
+
const endDateChangeHandler = (date) => {
|
|
44
|
+
if (startDate &&
|
|
45
|
+
date &&
|
|
46
|
+
getUnixTimeStamp(`${date}`) < getUnixTimeStamp(`${startDate}`)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
columnSearchHandler(propName, Object.assign(Object.assign({}, dateRangeValue), { to: `${date || ""}` }));
|
|
50
|
+
};
|
|
51
|
+
return (_jsx("div", Object.assign({ "data-bs-toggle": "dropdown-menu-item" }, { children: _jsxs("div", Object.assign({ className: "d-flex p-2" }, { children: [_jsxs("div", Object.assign({ className: "d-flex flex-column m-1" }, { children: [_jsx("label", { children: "Start date-time" }), _jsx(DatePicker, { id: "filter-date", dateFormat: dateFormat, "data-prop-name": propName, locale: nl, selected: startDate, onChange: startDateChangeHandler, placeholderText: dateFormat, isClearable: true, selectsStart: true, startDate: startDate, endDate: endDate, timeInputLabel: "Time:", showTimeInput: format === "date-time", shouldCloseOnSelect: format === "date" })] })), _jsxs("div", Object.assign({ className: "d-flex flex-column m-1" }, { children: [_jsx("label", { children: "End date-time" }), _jsx(DatePicker, { id: "filter-date", dateFormat: dateFormat, "data-prop-name": propName, locale: nl, selectsEnd: true, selected: endDate, onChange: endDateChangeHandler, placeholderText: dateFormat, isClearable: true, startDate: startDate, endDate: endDate, timeInputLabel: "Time:", showTimeInput: format === "date-time", shouldCloseOnSelect: format === "date" })] }))] })) })));
|
|
35
52
|
}
|
|
36
|
-
return (_jsx("input", { value: strValue, "data-prop-name": propName, onChange: inputChangeHandler, placeholder: `Search ${propName}` }));
|
|
53
|
+
return (_jsx("div", Object.assign({ className: "p-1" }, { children: _jsx("input", { value: strValue, "data-prop-name": propName, onChange: inputChangeHandler, placeholder: `Search ${propName}` }) })));
|
|
37
54
|
case "integer":
|
|
38
|
-
return (_jsx("input", { type: "number", value: strValue, "data-prop-name": propName, onChange: inputChangeHandler, placeholder: `Search ${propName}`, min: minimum, max: maximum }));
|
|
55
|
+
return (_jsx("div", Object.assign({ className: "d-flex p-1" }, { children: _jsx("input", { type: "number", value: strValue, "data-prop-name": propName, onChange: inputChangeHandler, placeholder: `Search ${propName}`, min: minimum, max: maximum }) })));
|
|
39
56
|
case "boolean":
|
|
40
57
|
return getSelectComponent(propSchema, propName, strValue, inputChangeHandler);
|
|
41
58
|
default:
|
|
42
59
|
return _jsx(_Fragment, {});
|
|
43
60
|
}
|
|
44
61
|
}, [columnSearchHandler, getSelectComponent]);
|
|
62
|
+
const removeDropdown = React.useCallback((e) => {
|
|
63
|
+
if (!columnFilterDropdown) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let columnFilterEl = null;
|
|
67
|
+
let parentNode = e.target;
|
|
68
|
+
while (parentNode && parentNode.nodeName !== "HTML") {
|
|
69
|
+
if (typeof parentNode.className === "string" &&
|
|
70
|
+
parentNode.className.includes("schema-table__column-filter")) {
|
|
71
|
+
columnFilterEl = parentNode;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
parentNode = parentNode.parentNode;
|
|
75
|
+
}
|
|
76
|
+
if (!columnFilterEl) {
|
|
77
|
+
setColumnFilterDropdown && setColumnFilterDropdown(undefined);
|
|
78
|
+
}
|
|
79
|
+
}, [columnFilterDropdown, setColumnFilterDropdown]);
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
if (!columnFilterDropdown) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
window.addEventListener("click", removeDropdown, { capture: true });
|
|
85
|
+
return () => {
|
|
86
|
+
window.removeEventListener("click", removeDropdown, { capture: true });
|
|
87
|
+
};
|
|
88
|
+
}, [columnFilterDropdown, removeDropdown]);
|
|
45
89
|
const SchemaColumnFilter = React.useCallback((index) => {
|
|
46
90
|
const propName = columnNames[index];
|
|
47
91
|
const propSchema = properties[propName];
|
|
@@ -50,8 +94,14 @@ export default function ColumnFilterRow({ columnNames, getWidth, config, value,
|
|
|
50
94
|
if (propName === SELECT_ALL_COLUMN_NAME || !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.isFilterable)) {
|
|
51
95
|
return _jsx("div", { className: "schema-table__th" });
|
|
52
96
|
}
|
|
53
|
-
return (_jsx("
|
|
54
|
-
|
|
97
|
+
return (_jsx("ul", Object.assign({ id: "test", className: `dropdown-menu dropdown-menu-lg-end ${columnFilterDropdown && columnFilterDropdown === propName
|
|
98
|
+
? "show"
|
|
99
|
+
: ""}`, style: {
|
|
100
|
+
position: "fixed",
|
|
101
|
+
marginTop: -10,
|
|
102
|
+
minHeight: 100,
|
|
103
|
+
} }, { children: _jsx("div", Object.assign({ id: "filter-dropdown-item", style: { margin: 10 } }, { children: field(propSchema, propName, propValue) })) })));
|
|
104
|
+
}, [columnFilterDropdown, columnNames, config, field, properties, value]);
|
|
55
105
|
return (_jsx("div", Object.assign({ className: "schema-table__th-row", style: { display: "flex", flex: "row" } }, { children: columnNames.map((columnName, index) => {
|
|
56
106
|
return (_jsx("div", Object.assign({ className: "schema-table__column-filter", style: {
|
|
57
107
|
width: getWidth(index),
|
|
@@ -13,6 +13,9 @@ interface IThProps {
|
|
|
13
13
|
onSelectAllIndexesHandler?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
14
14
|
isAllChecked?: boolean;
|
|
15
15
|
numberOfSelectedRows?: number;
|
|
16
|
+
columnFilterDropdown?: string;
|
|
17
|
+
setColumnFilterDropdown?: Dispatch<SetStateAction<string | undefined>>;
|
|
18
|
+
isColumnSearchable?: boolean;
|
|
16
19
|
}
|
|
17
|
-
declare const _default: ({ config, isSortable, name, schema, setSortAsc, setSortColumn, sortAsc, style, onSelectAllIndexesHandler, isAllChecked, numberOfSelectedRows, }: IThProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare const _default: ({ config, isSortable, name, schema, setSortAsc, setSortColumn, sortAsc, style, onSelectAllIndexesHandler, isAllChecked, numberOfSelectedRows, columnFilterDropdown, setColumnFilterDropdown, isColumnSearchable, }: IThProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
21
|
export default _default;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { uncamel } from "../../inc/string";
|
|
4
4
|
import { SELECT_ALL_COLUMN_NAME } from "../constants";
|
|
5
|
-
const Th = ({ config, isSortable, name, schema, setSortAsc, setSortColumn, sortAsc, style, onSelectAllIndexesHandler, isAllChecked, numberOfSelectedRows, }) => {
|
|
5
|
+
const Th = ({ config, isSortable, name, schema, setSortAsc, setSortColumn, sortAsc, style, onSelectAllIndexesHandler, isAllChecked, numberOfSelectedRows, columnFilterDropdown, setColumnFilterDropdown, isColumnSearchable, }) => {
|
|
6
6
|
const thDivProps = {
|
|
7
7
|
style,
|
|
8
8
|
className: `schema-table__th ${isSortable ? "schema-table__th--sortable" : "schema-table__th--unsortable"}`,
|
|
@@ -15,6 +15,16 @@ const Th = ({ config, isSortable, name, schema, setSortAsc, setSortColumn, sortA
|
|
|
15
15
|
}
|
|
16
16
|
setSortAsc((sortAsc) => !sortAsc);
|
|
17
17
|
}, [config === null || config === void 0 ? void 0 : config.defaultSortDesc, name, setSortAsc, setSortColumn, sortAsc]);
|
|
18
|
+
const onFilterButtonClick = React.useCallback(() => {
|
|
19
|
+
if (!setColumnFilterDropdown) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (columnFilterDropdown && columnFilterDropdown === name) {
|
|
23
|
+
setColumnFilterDropdown(undefined);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setColumnFilterDropdown(name);
|
|
27
|
+
}, [columnFilterDropdown, name, setColumnFilterDropdown]);
|
|
18
28
|
if (name === SELECT_ALL_COLUMN_NAME) {
|
|
19
29
|
return (_jsx("div", Object.assign({}, thDivProps, { children: _jsx("div", Object.assign({ style: {
|
|
20
30
|
width: "100%",
|
|
@@ -37,6 +47,6 @@ const Th = ({ config, isSortable, name, schema, setSortAsc, setSortColumn, sortA
|
|
|
37
47
|
thDivProps.className += ` text-${(config === null || config === void 0 ? void 0 : config.align) || "end"} justify-content-${(config === null || config === void 0 ? void 0 : config.align) || "end"}`;
|
|
38
48
|
}
|
|
39
49
|
}
|
|
40
|
-
return (
|
|
50
|
+
return (_jsxs("div", Object.assign({}, thDivProps, { children: [isSortable ? (_jsxs("button", Object.assign({ className: "px-0", disabled: (config === null || config === void 0 ? void 0 : config.sortable) === false, onClick: onSortButtonClick }, { children: [(config === null || config === void 0 ? void 0 : config.title) === undefined ? uncamel(name) : config === null || config === void 0 ? void 0 : config.title, sortAsc === undefined ? null : sortAsc ? "▲" : "▼"] }))) : (_jsx("div", Object.assign({ style: { lineHeight: "44px" } }, { children: (config === null || config === void 0 ? void 0 : config.title) === undefined ? uncamel(name) : config === null || config === void 0 ? void 0 : config.title }))), (config === null || config === void 0 ? void 0 : config.isFilterable) && isColumnSearchable ? (_jsx("button", Object.assign({ onClick: onFilterButtonClick, "data-bs-toggle": "dropdown" }, { children: _jsx("svg", Object.assign({ viewBox: "0 0 36 36", xmlns: "http://www.w3.org/2000/svg", height: 16, width: 16, style: { display: "block" } }, { children: _jsx("polygon", { "data-bs-toggle": "dropdown", fill: "#231F20", points: "14,30 22,25 22,17 35.999,0 17.988,0 0,0 14,17 " }) })) }))) : null] })));
|
|
41
51
|
};
|
|
42
52
|
export default React.memo(Th);
|
|
@@ -25,4 +25,8 @@ export interface ISchemaTableProps<T> {
|
|
|
25
25
|
style?: React.CSSProperties;
|
|
26
26
|
width: number;
|
|
27
27
|
}
|
|
28
|
+
export type tColumnSearchValue = string | number | boolean | {
|
|
29
|
+
from: string;
|
|
30
|
+
to: string;
|
|
31
|
+
};
|
|
28
32
|
export default function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnSearchable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { VariableSizeList, VariableSizeGrid } from "react-window";
|
|
4
|
-
import { localeFormat } from "../inc/date";
|
|
4
|
+
import { localeFormat, getUnixTimeStamp } from "../inc/date";
|
|
5
5
|
import { uncamel } from "../inc/string";
|
|
6
6
|
import Th from "./Th";
|
|
7
7
|
import { SELECT_ALL_COLUMN_NAME, SELECT_ALL_COLUMN_WIDTH } from "./constants";
|
|
@@ -13,6 +13,7 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
|
|
|
13
13
|
const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
|
|
14
14
|
const [searchQuery, setSearchQuery] = React.useState("");
|
|
15
15
|
const [columnSearchObj, setColumnSearchObj] = React.useState({});
|
|
16
|
+
const [columnFilterDropdown, setColumnFilterDropdown] = React.useState();
|
|
16
17
|
const { properties = {} } = schema;
|
|
17
18
|
const columnNames = React.useMemo(() => {
|
|
18
19
|
const columns = Object.keys(properties);
|
|
@@ -142,40 +143,59 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
|
|
|
142
143
|
]);
|
|
143
144
|
const getColumnWidth = React.useCallback((columnIndex) => (columnWidths ? columnWidths[columnIndex] : 1), [columnWidths]);
|
|
144
145
|
const filteredRenderData = React.useMemo(() => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return result;
|
|
146
|
+
if (!renderData || (!isColumnSearchable && !isSearchable)) {
|
|
147
|
+
return renderData;
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
149
|
+
return renderData.filter((item) => {
|
|
150
|
+
const globalSearchFilterResult = searchQuery
|
|
151
|
+
? !!columnNames.find((columnName) =>
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
`${item[columnName]}`
|
|
154
|
+
.toLowerCase()
|
|
155
|
+
.includes(searchQuery.toLowerCase()))
|
|
156
|
+
: true;
|
|
157
|
+
const rowColumnValidation = isColumnSearchable
|
|
158
|
+
? Object.keys(columnSearchObj).reduce((previousValue, propName) => {
|
|
159
|
+
const propSchema = properties[propName];
|
|
160
|
+
const columnSearchValue = columnSearchObj[propName];
|
|
161
|
+
const rawValue = `${item[propName]}`;
|
|
162
|
+
if (typeof columnSearchValue === "object" &&
|
|
163
|
+
(propSchema.format === "date" ||
|
|
164
|
+
propSchema.format === "date-time")) {
|
|
165
|
+
const dateFormat = propSchema.format === "date"
|
|
166
|
+
? DEFAULT_DATE_FORMAT
|
|
167
|
+
: DEFAULT_DATE_TIME_FORMAT;
|
|
168
|
+
const { from, to } = columnSearchValue;
|
|
169
|
+
if (!from) {
|
|
170
|
+
return previousValue;
|
|
171
|
+
}
|
|
172
|
+
const startDate = getUnixTimeStamp(from, dateFormat);
|
|
173
|
+
const endDate = to
|
|
174
|
+
? getUnixTimeStamp(to, dateFormat)
|
|
175
|
+
: undefined;
|
|
176
|
+
const currentDate = getUnixTimeStamp(rawValue, dateFormat);
|
|
177
|
+
if (!startDate) {
|
|
178
|
+
return previousValue;
|
|
179
|
+
}
|
|
180
|
+
previousValue.push(startDate && endDate
|
|
181
|
+
? currentDate >= startDate && currentDate <= endDate
|
|
182
|
+
: currentDate >= startDate);
|
|
168
183
|
return previousValue;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
184
|
+
}
|
|
185
|
+
previousValue.push(rawValue
|
|
186
|
+
.toLowerCase()
|
|
187
|
+
.includes(`${columnSearchValue}`.toLowerCase()));
|
|
188
|
+
return previousValue;
|
|
189
|
+
}, [])
|
|
190
|
+
: [true];
|
|
191
|
+
return globalSearchFilterResult && rowColumnValidation.every((el) => el);
|
|
192
|
+
});
|
|
174
193
|
}, [
|
|
175
194
|
columnNames,
|
|
176
195
|
columnSearchObj,
|
|
177
196
|
isColumnSearchable,
|
|
178
197
|
isSearchable,
|
|
198
|
+
properties,
|
|
179
199
|
renderData,
|
|
180
200
|
searchQuery,
|
|
181
201
|
]);
|
|
@@ -236,7 +256,7 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
|
|
|
236
256
|
}, [checkedIndexes, filteredRenderData]);
|
|
237
257
|
const SchemaTableTh = React.useCallback(({ style, index }) => {
|
|
238
258
|
const propName = columnNames[index];
|
|
239
|
-
return (_jsx(Th, { config: config ? config[propName] : undefined, isSortable: !!isSortable, name: propName, schema: properties[propName], setSortColumn: setSortColumn, setSortAsc: setSortAsc, sortAsc: sortColumn === propName ? sortAsc : undefined, style: style, onSelectAllIndexesHandler: onSelectAllIndexesHandler, isAllChecked: isAllRowsChecked, numberOfSelectedRows: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length }));
|
|
259
|
+
return (_jsx(Th, { config: config ? config[propName] : undefined, isSortable: !!isSortable, name: propName, schema: properties[propName], setSortColumn: setSortColumn, setSortAsc: setSortAsc, sortAsc: sortColumn === propName ? sortAsc : undefined, style: style, onSelectAllIndexesHandler: onSelectAllIndexesHandler, isAllChecked: isAllRowsChecked, numberOfSelectedRows: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length, columnFilterDropdown: columnFilterDropdown, setColumnFilterDropdown: setColumnFilterDropdown, isColumnSearchable: isColumnSearchable }));
|
|
240
260
|
}, [
|
|
241
261
|
columnNames,
|
|
242
262
|
config,
|
|
@@ -247,6 +267,8 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
|
|
|
247
267
|
onSelectAllIndexesHandler,
|
|
248
268
|
isAllRowsChecked,
|
|
249
269
|
checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length,
|
|
270
|
+
columnFilterDropdown,
|
|
271
|
+
isColumnSearchable,
|
|
250
272
|
]);
|
|
251
273
|
const SchemaTableTd = React.useCallback(({ columnIndex, rowIndex, style }) => {
|
|
252
274
|
const propName = columnNames[columnIndex];
|
|
@@ -280,5 +302,5 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
|
|
|
280
302
|
? rowsMaxHeight
|
|
281
303
|
: rowsHeight;
|
|
282
304
|
}, [maxHeight, isSearchable, rowCount, rowHeight]);
|
|
283
|
-
return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }) }, { children: [_jsxs("div", Object.assign({ className: "schema-table__action-container" }, { children: [_jsx("div", Object.assign({ style: { flex: 1 } }, { children: isSearchable ? (_jsx("input", { type: "text", placeholder: searchPlaceholder || "Search...", value: searchQuery, onChange: onSearchChange, autoFocus: true })) : null })), customElement] })), _jsx(Heading, Object.assign({ height: 50, itemCount: columnCount, itemSize: getColumnWidth, layout: "horizontal", width: rowWidth, sortAsc: sortAsc, setSortAsc: setSortAsc, setSortColumn: setSortColumn, sortColumn: sortColumn, sortedRenderData: sortedRenderData, className: "schema-table__th-row" }, { children: SchemaTableTh }), `thead_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}`), isColumnSearchable ? (_jsx(ColumnFilterRow, { schema: schema, columnNames: columnNames, config: config, value: columnSearchObj, columnSearchHandler: columnSearchHandler, getWidth: getColumnWidth })) : null, _jsx(VariableSizeGrid, Object.assign({ className: "schema-table__tbody", height: tableBodyHeight, width: rowWidth, columnWidth: getColumnWidth, rowHeight: getRowHeight, columnCount: columnCount, rowCount: rowCount }, { children: SchemaTableTd }), `tbody_${tableBodyHeight}_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}_${columnCount}`)] })));
|
|
305
|
+
return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }) }, { children: [_jsxs("div", Object.assign({ className: "schema-table__action-container" }, { children: [_jsx("div", Object.assign({ style: { flex: 1 } }, { children: isSearchable ? (_jsx("input", { type: "text", placeholder: searchPlaceholder || "Search...", value: searchQuery, onChange: onSearchChange, autoFocus: true })) : null })), customElement] })), _jsx(Heading, Object.assign({ height: 50, itemCount: columnCount, itemSize: getColumnWidth, layout: "horizontal", width: rowWidth, sortAsc: sortAsc, setSortAsc: setSortAsc, setSortColumn: setSortColumn, sortColumn: sortColumn, sortedRenderData: sortedRenderData, className: "schema-table__th-row" }, { children: SchemaTableTh }), `thead_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}`), isColumnSearchable ? (_jsx(ColumnFilterRow, { schema: schema, columnNames: columnNames, config: config, value: columnSearchObj, columnSearchHandler: columnSearchHandler, getWidth: getColumnWidth, columnFilterDropdown: columnFilterDropdown, setColumnFilterDropdown: setColumnFilterDropdown })) : null, _jsx(VariableSizeGrid, Object.assign({ className: "schema-table__tbody", height: tableBodyHeight, width: rowWidth, columnWidth: getColumnWidth, rowHeight: getRowHeight, columnCount: columnCount, rowCount: rowCount }, { children: SchemaTableTd }), `tbody_${tableBodyHeight}_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}_${columnCount}`)] })));
|
|
284
306
|
}
|
package/dist/inc/constant.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DEFAULT_DATE_FORMAT = "
|
|
2
|
-
export declare const DEFAULT_DATE_TIME_FORMAT = "dd
|
|
1
|
+
export declare const DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
|
|
2
|
+
export declare const DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
package/dist/inc/constant.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const DEFAULT_DATE_FORMAT = "
|
|
2
|
-
export const DEFAULT_DATE_TIME_FORMAT = "dd
|
|
1
|
+
export const DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
|
|
2
|
+
export const DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
package/dist/inc/date.d.ts
CHANGED
package/dist/inc/date.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { format } from "date-fns";
|
|
2
2
|
import nl from "date-fns/locale/nl";
|
|
3
3
|
export const localeFormat = (date, dateFormat) => format(date, dateFormat, { locale: nl });
|
|
4
|
+
export const getUnixTimeStamp = (date, dateFormat) => {
|
|
5
|
+
return Math.floor(new Date(format(new Date(date), dateFormat || "MM/dd/yyyy")).getTime() /
|
|
6
|
+
1000);
|
|
7
|
+
};
|
package/dist/index.css
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
.schema-table__column-filter input,
|
|
16
16
|
.schema-table__column-filter select {
|
|
17
|
-
width:
|
|
17
|
+
width: 100%;
|
|
18
18
|
padding: 3px;
|
|
19
19
|
margin-top: 3px;
|
|
20
20
|
border-radius: 5px;
|
|
@@ -24,9 +24,6 @@
|
|
|
24
24
|
margin-top: 10px;
|
|
25
25
|
margin-left: 30px;
|
|
26
26
|
}
|
|
27
|
-
.schema-table__column-filter .react-datepicker {
|
|
28
|
-
display: flex;
|
|
29
|
-
}
|
|
30
27
|
.schema-table__th {
|
|
31
28
|
background-color: #eee;
|
|
32
29
|
align-items: center;
|