mig-schema-table 3.0.42 → 3.0.43
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/SchemaColumnFilterPopover/FilterFormComponent/index.d.ts +5 -4
- package/dist/SchemaTable/SchemaColumnFilterPopover/FilterFormComponent/index.js +8 -8
- package/dist/SchemaTable/SchemaColumnFilterPopover/index.d.ts +2 -1
- package/dist/SchemaTable/SchemaColumnFilterPopover/index.js +2 -2
- package/dist/SchemaTable/index.d.ts +1 -1
- package/dist/SchemaTable/index.js +8 -5
- package/package.json +1 -1
|
@@ -3,11 +3,12 @@ import { oas31 } from "openapi3-ts";
|
|
|
3
3
|
import { TColumnFilterValue } from "../../index";
|
|
4
4
|
import { IColumnConfig } from "../../../types";
|
|
5
5
|
export interface IFilterFormComponentProps {
|
|
6
|
-
onChange: (newValue?: TColumnFilterValue) => void;
|
|
7
|
-
propSchema: oas31.SchemaObject;
|
|
8
|
-
propName: string;
|
|
9
6
|
columnFilterValue: TColumnFilterValue;
|
|
7
|
+
onChange: (newValue?: TColumnFilterValue) => void;
|
|
8
|
+
onInputKeyDown: (e: React.KeyboardEvent) => void;
|
|
10
9
|
propConfig?: IColumnConfig<any>;
|
|
10
|
+
propName: string;
|
|
11
|
+
propSchema: oas31.SchemaObject;
|
|
11
12
|
}
|
|
12
|
-
declare const _default: React.MemoExoticComponent<({
|
|
13
|
+
declare const _default: React.MemoExoticComponent<({ columnFilterValue, onChange, onInputKeyDown, propConfig, propName, propSchema, }: IFilterFormComponentProps) => import("react/jsx-runtime").JSX.Element>;
|
|
13
14
|
export default _default;
|
|
@@ -4,22 +4,22 @@ 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
|
-
const FilterFormComponent = ({
|
|
7
|
+
const FilterFormComponent = ({ columnFilterValue, onChange, onInputKeyDown, propConfig, propName, propSchema, }) => {
|
|
8
8
|
const { type, format, minimum, maximum } = propSchema;
|
|
9
9
|
const value = columnFilterValue;
|
|
10
10
|
switch (type) {
|
|
11
11
|
case "integer":
|
|
12
|
-
return (_jsx("div", Object.assign({ className: "input-group" }, { children: _jsx("input", { className: "form-control", type: "number", value: (value || ""), "data-prop-name": propName, onChange: (e) => {
|
|
12
|
+
return (_jsx("div", Object.assign({ className: "input-group" }, { children: _jsx("input", { autoFocus: true, className: "form-control", type: "number", value: (value || ""), "data-prop-name": propName, onChange: (e) => {
|
|
13
13
|
onChange(e.currentTarget.value === ""
|
|
14
14
|
? undefined
|
|
15
15
|
: parseInt(e.currentTarget.value));
|
|
16
|
-
}, placeholder: `Search ${propName}`, min: minimum, max: maximum }) })));
|
|
16
|
+
}, onKeyDown: onInputKeyDown, placeholder: `Search ${propName}`, min: minimum, max: maximum }) })));
|
|
17
17
|
case "boolean":
|
|
18
18
|
let selectValue = value ? "✓" : "✕";
|
|
19
19
|
if (value === undefined) {
|
|
20
20
|
selectValue = "";
|
|
21
21
|
}
|
|
22
|
-
return (_jsxs("select", Object.assign({ className: "form-select", value: selectValue, "data-prop-name": propName, onChange: (e) => {
|
|
22
|
+
return (_jsxs("select", Object.assign({ autoFocus: true, className: "form-select", value: selectValue, "data-prop-name": propName, onChange: (e) => {
|
|
23
23
|
switch (e.currentTarget.value) {
|
|
24
24
|
case "✓":
|
|
25
25
|
onChange(true);
|
|
@@ -34,7 +34,7 @@ const FilterFormComponent = ({ onChange, propSchema, propName, propConfig, colum
|
|
|
34
34
|
// @ts-ignore
|
|
35
35
|
case "string":
|
|
36
36
|
if (propSchema.enum) {
|
|
37
|
-
return (_jsxs("select", Object.assign({ className: "form-select", value: value, "data-prop-name": propName, onChange: (e) => {
|
|
37
|
+
return (_jsxs("select", Object.assign({ autoFocus: true, className: "form-select", value: value, "data-prop-name": propName, onChange: (e) => {
|
|
38
38
|
onChange(e.currentTarget.value || undefined);
|
|
39
39
|
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), propSchema.enum.map((name) => {
|
|
40
40
|
const rowName = !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.translation)
|
|
@@ -69,13 +69,13 @@ const FilterFormComponent = ({ onChange, propSchema, propName, propConfig, colum
|
|
|
69
69
|
}
|
|
70
70
|
onChange(Object.assign(Object.assign({}, columnFilterValue), { to: date || undefined }));
|
|
71
71
|
};
|
|
72
|
-
return (_jsxs("div", Object.assign({ className: "input-group d-flex" }, { children: [_jsxs("div", Object.assign({ className: "d-flex flex-column m-1" }, { children: [_jsx("label", { children: "Start date-time" }), _jsx(DatePicker, { dateFormat: dateFormat, "data-prop-name": propName, locale: nl, selected: dateRangeValue.from, onChange: startDateChangeHandler, placeholderText: dateFormat, isClearable: true, selectsStart: true, 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: dateRangeValue.to, onChange: endDateChangeHandler, placeholderText: dateFormat, isClearable: true, startDate: dateRangeValue.from, endDate: dateRangeValue.to, showTimeSelect: format === "date-time", timeIntervals: 15, shouldCloseOnSelect: format === "date" })] }))] })));
|
|
72
|
+
return (_jsxs("div", Object.assign({ className: "input-group d-flex" }, { children: [_jsxs("div", Object.assign({ className: "d-flex flex-column m-1" }, { children: [_jsx("label", { children: "Start date-time" }), _jsx(DatePicker, { autoFocus: true, dateFormat: dateFormat, "data-prop-name": propName, locale: nl, selected: dateRangeValue.from, onChange: startDateChangeHandler, placeholderText: dateFormat, isClearable: true, selectsStart: true, 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: dateRangeValue.to, onChange: endDateChangeHandler, placeholderText: dateFormat, isClearable: true, startDate: dateRangeValue.from, endDate: dateRangeValue.to, showTimeSelect: format === "date-time", timeIntervals: 15, shouldCloseOnSelect: format === "date" })] }))] })));
|
|
73
73
|
}
|
|
74
74
|
// falls through
|
|
75
75
|
default:
|
|
76
|
-
return (_jsx("div", Object.assign({ className: "input-group" }, { children: _jsx("input", { type: "text", className: "form-control", placeholder: `Search ${propName}`, "aria-label": `Search ${propName}`,
|
|
76
|
+
return (_jsx("div", Object.assign({ className: "input-group" }, { children: _jsx("input", { autoFocus: true, type: "text", className: "form-control", placeholder: `Search ${propName}`, "aria-label": `Search ${propName}`, value: (value || ""), "data-prop-name": propName, onChange: (e) => {
|
|
77
77
|
onChange(e.currentTarget.value || undefined);
|
|
78
|
-
} }) })));
|
|
78
|
+
}, onKeyDown: onInputKeyDown }) })));
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
export default React.memo(FilterFormComponent);
|
|
@@ -9,9 +9,10 @@ export interface ISchemaColumnFilterPopoverConfig {
|
|
|
9
9
|
}
|
|
10
10
|
type TSchemaColumnFilterPopoverProps = ISchemaColumnFilterPopoverConfig & {
|
|
11
11
|
onChange: (newValue?: TColumnFilterValue) => void;
|
|
12
|
+
onInputKeyDown: (e: React.KeyboardEvent) => void;
|
|
12
13
|
propSchema: oas31.SchemaObject;
|
|
13
14
|
value: TColumnFilterValue;
|
|
14
15
|
onClose: () => void;
|
|
15
16
|
};
|
|
16
|
-
declare const _default: React.MemoExoticComponent<({ onChange, onClose, propName, propSchema, referenceElement, value, propConfig, }: TSchemaColumnFilterPopoverProps) => import("react/jsx-runtime").JSX.Element>;
|
|
17
|
+
declare const _default: React.MemoExoticComponent<({ onChange, onClose, onInputKeyDown, propName, propSchema, referenceElement, value, propConfig, }: TSchemaColumnFilterPopoverProps) => import("react/jsx-runtime").JSX.Element>;
|
|
17
18
|
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 FilterFormComponent from "./FilterFormComponent";
|
|
4
4
|
import { usePopper } from "react-popper";
|
|
5
|
-
const SchemaColumnFilterPopover = ({ onChange, onClose, propName, propSchema, referenceElement, value, propConfig, }) => {
|
|
5
|
+
const SchemaColumnFilterPopover = ({ onChange, onClose, onInputKeyDown, propName, propSchema, referenceElement, value, propConfig, }) => {
|
|
6
6
|
const [popperElement, setPopperElement] = React.useState(null);
|
|
7
7
|
const [arrowElement, setArrowElement] = React.useState(null);
|
|
8
8
|
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
@@ -33,6 +33,6 @@ const SchemaColumnFilterPopover = ({ onChange, onClose, propName, propSchema, re
|
|
|
33
33
|
classNames.push(`bs-popover-${attributes.popper["data-popper-placement"]}`);
|
|
34
34
|
}
|
|
35
35
|
const FilterForm = (propConfig === null || propConfig === void 0 ? void 0 : propConfig.FilterForm) || FilterFormComponent;
|
|
36
|
-
return (_jsxs("div", Object.assign({ className: classNames.join(" "), role: "tooltip", ref: setPopperElement, style: styles.popper }, attributes.popper, { children: [_jsx("div", { className: "popover-arrow", ref: setArrowElement, style: styles.arrow }), _jsx("div", Object.assign({ className: "popover-body" }, { children: _jsx(FilterForm, { onChange: onChange, propSchema: propSchema, propName: propName, columnFilterValue: value, propConfig: propConfig }) }))] })));
|
|
36
|
+
return (_jsxs("div", Object.assign({ className: classNames.join(" "), role: "tooltip", ref: setPopperElement, style: styles.popper }, attributes.popper, { children: [_jsx("div", { className: "popover-arrow", ref: setArrowElement, style: styles.arrow }), _jsx("div", Object.assign({ className: "popover-body" }, { children: _jsx(FilterForm, { onChange: onChange, onInputKeyDown: onInputKeyDown, propSchema: propSchema, propName: propName, columnFilterValue: value, propConfig: propConfig }) }))] })));
|
|
37
37
|
};
|
|
38
38
|
export default React.memo(SchemaColumnFilterPopover);
|
|
@@ -385,9 +385,12 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
|
|
|
385
385
|
setIsDirty(false);
|
|
386
386
|
setSourceData(undefined);
|
|
387
387
|
}, []);
|
|
388
|
-
const
|
|
389
|
-
if (e.key === "Enter"
|
|
390
|
-
|
|
388
|
+
const onInputKeyDown = React.useCallback((e) => {
|
|
389
|
+
if (e.key === "Enter") {
|
|
390
|
+
setPopoverConfig(undefined);
|
|
391
|
+
if (isDirty) {
|
|
392
|
+
refreshData();
|
|
393
|
+
}
|
|
391
394
|
}
|
|
392
395
|
}, [isDirty, refreshData]);
|
|
393
396
|
const getRowHeight = React.useCallback(() => rowHeight, [rowHeight]);
|
|
@@ -416,7 +419,7 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
|
|
|
416
419
|
}
|
|
417
420
|
setColumnFilterMap((columnFilterMap) => (Object.assign(Object.assign({}, columnFilterMap), { [popoverConfig.propName]: newColumnFilterValue })));
|
|
418
421
|
}, [data, disableColumnFilter, popoverConfig]);
|
|
419
|
-
return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }), role: "table" }, { 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, onKeyDown:
|
|
422
|
+
return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }), role: "table" }, { 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, onKeyDown: onInputKeyDown, autoFocus: true })) : null })), customElement] })), _jsx(Heading, Object.assign({ height: 50, itemCount: columnCount, itemSize: getColumnWidth, layout: "horizontal", width: rowWidth, sortAsc: sortAsc, setSortAsc: onSetSortAsc, setSortColumn: onSetSortColumn, sortColumn: sortColumn, sortedRenderData: sortedRenderData, className: "schema-table__th-row" }, { children: SchemaTableTh }), `thead_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}`), sourceData && !isDirty ? (_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}`)) : (_jsx("div", Object.assign({ style: {
|
|
420
423
|
width: rowWidth,
|
|
421
424
|
height: Math.max(50, tableBodyHeight),
|
|
422
425
|
border: "1px solid #BBB",
|
|
@@ -425,6 +428,6 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
|
|
|
425
428
|
backgroundColor: "#CCC",
|
|
426
429
|
alignItems: "center",
|
|
427
430
|
justifyContent: "center",
|
|
428
|
-
} }, { children: isDirty ? (_jsx("button", Object.assign({ onClick: refreshData, className: "btn border" }, { children: "Refresh data" }))) : (_jsx("div", { children: "\u231B Loading..." })) }))), popoverConfig ? (_jsx(SchemaColumnFilterPopover, { referenceElement: popoverConfig.referenceElement, onClose: onPopoverClose, onChange: onSchemaColumnFilterChange, propName: popoverConfig.propName, propSchema: schema.properties[popoverConfig.propName], value: columnFilterMap[popoverConfig.propName], propConfig: popoverConfig.propConfig })) : null] })));
|
|
431
|
+
} }, { children: isDirty ? (_jsx("button", Object.assign({ onClick: refreshData, className: "btn border" }, { children: "Refresh data" }))) : (_jsx("div", { children: "\u231B Loading..." })) }))), popoverConfig ? (_jsx(SchemaColumnFilterPopover, { referenceElement: popoverConfig.referenceElement, onClose: onPopoverClose, onChange: onSchemaColumnFilterChange, onInputKeyDown: onInputKeyDown, propName: popoverConfig.propName, propSchema: schema.properties[popoverConfig.propName], value: columnFilterMap[popoverConfig.propName], propConfig: popoverConfig.propConfig })) : null] })));
|
|
429
432
|
}
|
|
430
433
|
export default React.memo(SchemaTable);
|