mig-schema-table 3.0.61 → 3.0.62
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.
|
@@ -9,7 +9,7 @@ export interface IFilterFormComponentProps {
|
|
|
9
9
|
propConfig?: IColumnConfig<any>;
|
|
10
10
|
propIsRequired: boolean;
|
|
11
11
|
propName: string;
|
|
12
|
-
propSchema
|
|
12
|
+
propSchema?: oas31.SchemaObject;
|
|
13
13
|
}
|
|
14
14
|
declare const _default: React.MemoExoticComponent<({ columnFilterValue, onChange, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, }: IFilterFormComponentProps) => import("react/jsx-runtime").JSX.Element>;
|
|
15
15
|
export default _default;
|
|
@@ -6,7 +6,7 @@ import DatePicker from "react-datepicker";
|
|
|
6
6
|
import nl from "date-fns/locale/nl";
|
|
7
7
|
import { endOfDay } from "date-fns";
|
|
8
8
|
const FilterFormComponent = ({ columnFilterValue, onChange, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, }) => {
|
|
9
|
-
const { type, format, minimum, maximum } = propSchema;
|
|
9
|
+
const { type, format, minimum, maximum } = propSchema || {};
|
|
10
10
|
const value = columnFilterValue;
|
|
11
11
|
switch (type) {
|
|
12
12
|
case "integer":
|
|
@@ -34,7 +34,7 @@ const FilterFormComponent = ({ columnFilterValue, onChange, onInputKeyDown, prop
|
|
|
34
34
|
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), ["✓", "✕"].map((optionValue) => (_jsx("option", Object.assign({ value: optionValue }, { children: optionValue }), `column-filter-select-${optionValue}`)))] })));
|
|
35
35
|
// @ts-ignore
|
|
36
36
|
case "string":
|
|
37
|
-
if (propSchema.enum) {
|
|
37
|
+
if (propSchema === null || propSchema === void 0 ? void 0 : propSchema.enum) {
|
|
38
38
|
return (_jsxs("select", Object.assign({ autoFocus: true, className: "form-select", value: value, "data-prop-name": propName, onChange: (e) => {
|
|
39
39
|
onChange(e.currentTarget.value || undefined);
|
|
40
40
|
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), propSchema.enum.map((name) => {
|
|
@@ -221,6 +221,11 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
221
221
|
if (!result || columnFilterValue === undefined) {
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
|
+
const propConfig = config ? config[propName] : undefined;
|
|
225
|
+
if (sourceData && (propConfig === null || propConfig === void 0 ? void 0 : propConfig.filter)) {
|
|
226
|
+
result = propConfig.filter(sourceData[item._index], item._index);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
224
229
|
const propSchema = properties[propName];
|
|
225
230
|
// @ts-ignore
|
|
226
231
|
const rawValue = sourceData[item._index][propName];
|
|
@@ -265,8 +270,9 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
265
270
|
searchQuery,
|
|
266
271
|
columnNames,
|
|
267
272
|
columnFilterMap,
|
|
268
|
-
|
|
273
|
+
config,
|
|
269
274
|
sourceData,
|
|
275
|
+
properties,
|
|
270
276
|
]);
|
|
271
277
|
// Sort the filtered data
|
|
272
278
|
const sortedRenderData = React.useMemo(() => {
|
|
@@ -367,7 +373,9 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
367
373
|
? { type: "boolean" }
|
|
368
374
|
: properties[propName]);
|
|
369
375
|
const propConfig = config ? config[propName] : undefined;
|
|
370
|
-
let columnFilterStatus = isColumnFilterable &&
|
|
376
|
+
let columnFilterStatus = isColumnFilterable &&
|
|
377
|
+
(propSchema || (propConfig === null || propConfig === void 0 ? void 0 : propConfig.FilterForm)) &&
|
|
378
|
+
(propConfig === null || propConfig === void 0 ? void 0 : propConfig.isFilterable) !== false
|
|
371
379
|
? EColumnFilterStatus.AVAILABLE
|
|
372
380
|
: EColumnFilterStatus.UNAVAILABLE;
|
|
373
381
|
if (columnFilterMap[propName] !== undefined) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { IFilterFormComponentProps } from "./SchemaTable/SchemaColumnFilterPopover/FilterFormComponent";
|
|
3
3
|
export interface IColumnConfig<T> {
|
|
4
|
+
FilterForm?: (props: IFilterFormComponentProps) => React.ReactElement | null;
|
|
4
5
|
align?: "start" | "center" | "end";
|
|
5
6
|
dateFormat?: string;
|
|
6
7
|
defaultSortDesc?: boolean;
|
|
7
|
-
|
|
8
|
+
filter?: (rowData: T, dataIndex: number) => boolean;
|
|
8
9
|
hidden?: boolean;
|
|
9
10
|
hoverTitle?: string;
|
|
10
11
|
isFilterable?: boolean;
|