mig-schema-table 3.0.17 → 3.0.19

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.
@@ -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: string | number | boolean) => void;
12
+ columnSearchHandler: (propName: string, value: tColumnSearchValue) => void;
11
13
  value: {
12
- [propName: string]: string | number | boolean;
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
- export default function ColumnFilterRow({ columnNames, getWidth, config, value, columnSearchHandler, schema, }) {
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" ? ["true", "false"] : propSchema.enum;
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, propConfig) => {
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 = (propConfig === null || propConfig === void 0 ? void 0 : propConfig.dateFormat) ||
28
- (format === "date"
29
- ? DEFAULT_DATE_FORMAT
30
- : DEFAULT_DATE_TIME_FORMAT);
31
- const dateChangeHandler = (date) => {
32
- columnSearchHandler(propName, date ? localeFormat(date, dateFormat) : "");
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
- return (_jsx(DatePicker, { id: "filter-date", dateFormat: dateFormat, "data-prop-name": propName, showTimeSelect: format === "date-time", locale: nl, selected: propValue ? new Date(propValue) : null, onChange: dateChangeHandler, value: propValue || undefined, placeholderText: dateFormat, isClearable: true }));
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, showTimeSelect: format === "date-time", timeIntervals: 15, 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, showTimeSelect: format === "date-time", timeIntervals: 15, 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("div", Object.assign({ className: "schema-table__th" }, { children: field(propSchema, propName, propValue, propConfig) }), `filter-col-${propName}`));
54
- }, [columnNames, config, field, properties, value]);
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 (_jsx("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 }))) })));
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);
@@ -155,14 +156,35 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
155
156
  : true;
156
157
  const rowColumnValidation = isColumnSearchable
157
158
  ? Object.keys(columnSearchObj).reduce((previousValue, propName) => {
158
- const columnSearchText = columnSearchObj[propName];
159
- const isBooleanValue = item[propName] === "✓" || item[propName] === "✕";
160
- const rawValue = isBooleanValue
161
- ? `${item[propName] === ""}`
162
- : `${item[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);
183
+ return previousValue;
184
+ }
163
185
  previousValue.push(rawValue
164
186
  .toLowerCase()
165
- .includes(`${columnSearchText}`.toLowerCase()));
187
+ .includes(`${columnSearchValue}`.toLowerCase()));
166
188
  return previousValue;
167
189
  }, [])
168
190
  : [true];
@@ -173,6 +195,7 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
173
195
  columnSearchObj,
174
196
  isColumnSearchable,
175
197
  isSearchable,
198
+ properties,
176
199
  renderData,
177
200
  searchQuery,
178
201
  ]);
@@ -233,7 +256,7 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
233
256
  }, [checkedIndexes, filteredRenderData]);
234
257
  const SchemaTableTh = React.useCallback(({ style, index }) => {
235
258
  const propName = columnNames[index];
236
- 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 }));
237
260
  }, [
238
261
  columnNames,
239
262
  config,
@@ -244,6 +267,8 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
244
267
  onSelectAllIndexesHandler,
245
268
  isAllRowsChecked,
246
269
  checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length,
270
+ columnFilterDropdown,
271
+ isColumnSearchable,
247
272
  ]);
248
273
  const SchemaTableTd = React.useCallback(({ columnIndex, rowIndex, style }) => {
249
274
  const propName = columnNames[columnIndex];
@@ -277,5 +302,5 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
277
302
  ? rowsMaxHeight
278
303
  : rowsHeight;
279
304
  }, [maxHeight, isSearchable, rowCount, rowHeight]);
280
- 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}`)] })));
281
306
  }
@@ -1,2 +1,2 @@
1
- export declare const DEFAULT_DATE_FORMAT = "dd-MM-yyyy";
1
+ export declare const DEFAULT_DATE_FORMAT = "dd MMM yyyy";
2
2
  export declare const DEFAULT_DATE_TIME_FORMAT = "dd MMM yyyy HH:mm";
@@ -1,2 +1,2 @@
1
- export const DEFAULT_DATE_FORMAT = "dd-MM-yyyy";
1
+ export const DEFAULT_DATE_FORMAT = "dd MMM yyyy";
2
2
  export const DEFAULT_DATE_TIME_FORMAT = "dd MMM yyyy HH:mm";
@@ -1 +1,2 @@
1
1
  export declare const localeFormat: (date: Date | number, dateFormat: string) => string;
2
+ export declare const getUnixTimeStamp: (date: string, dateFormat?: string) => number;
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: 90%;
17
+ width: 100%;
18
18
  padding: 3px;
19
19
  margin-top: 3px;
20
20
  border-radius: 5px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mig-schema-table",
3
- "version": "3.0.17",
3
+ "version": "3.0.19",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/"