mig-schema-table 3.0.52 → 3.0.53
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.
|
@@ -15,7 +15,7 @@ interface ITdProps<T> {
|
|
|
15
15
|
onRowDoubleClick?: (rowData: T, dataIndex: number, event: React.MouseEvent) => void;
|
|
16
16
|
propConfig?: IColumnConfig<any>;
|
|
17
17
|
propName: string;
|
|
18
|
-
propSchema
|
|
18
|
+
propSchema?: oas31.SchemaObject;
|
|
19
19
|
sortedRenderData?: IRenderData[];
|
|
20
20
|
style: React.CSSProperties;
|
|
21
21
|
}
|
|
@@ -33,7 +33,7 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
33
33
|
return undefined;
|
|
34
34
|
}
|
|
35
35
|
let title = propName === SELECT_ALL_COLUMN_NAME ? null : row[propName];
|
|
36
|
-
if (propSchema.format &&
|
|
36
|
+
if ((propSchema === null || propSchema === void 0 ? void 0 : propSchema.format) &&
|
|
37
37
|
propSchema.format.startsWith("date") &&
|
|
38
38
|
(propConfig === null || propConfig === void 0 ? void 0 : propConfig.showTimezones) !== false) {
|
|
39
39
|
// @ts-ignore
|
|
@@ -70,7 +70,7 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
70
70
|
propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell,
|
|
71
71
|
propConfig === null || propConfig === void 0 ? void 0 : propConfig.showTimezones,
|
|
72
72
|
propName,
|
|
73
|
-
propSchema.format,
|
|
73
|
+
propSchema === null || propSchema === void 0 ? void 0 : propSchema.format,
|
|
74
74
|
row,
|
|
75
75
|
rowHeight,
|
|
76
76
|
rowIndex,
|
|
@@ -92,11 +92,11 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
92
92
|
};
|
|
93
93
|
return (_jsx("div", Object.assign({}, tdDivProps, { children: _jsx("div", Object.assign({ style: { textAlign: "center" } }, { children: _jsx("input", { "data-key": "row-checkbox", type: "checkbox", onChange: onChecked, checked: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.includes(row._index), disabled: disabledCheckedIndexes === null || disabledCheckedIndexes === void 0 ? void 0 : disabledCheckedIndexes.includes(row._index) }) })) })));
|
|
94
94
|
}
|
|
95
|
-
if (!propSchema) {
|
|
95
|
+
if (!propSchema && !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) && !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell)) {
|
|
96
96
|
return null;
|
|
97
97
|
}
|
|
98
98
|
const propValue = row[propName];
|
|
99
|
-
switch (propSchema.type) {
|
|
99
|
+
switch (propSchema === null || propSchema === void 0 ? void 0 : propSchema.type) {
|
|
100
100
|
case "boolean":
|
|
101
101
|
tdDivProps.className += ` text-${(propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) || "center"}`;
|
|
102
102
|
break;
|
|
@@ -108,7 +108,7 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
108
108
|
if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) {
|
|
109
109
|
tdDivProps.className += ` text-${propConfig.align}`;
|
|
110
110
|
}
|
|
111
|
-
if (propSchema.format === "url" && propValue) {
|
|
111
|
+
if ((propSchema === null || propSchema === void 0 ? void 0 : propSchema.format) === "url" && propValue) {
|
|
112
112
|
return (
|
|
113
113
|
// @ts-ignore
|
|
114
114
|
_jsx("a", Object.assign({ href: propValue, target: "_blank", rel: "noopener noreferrer" }, tdDivProps, { children: propValue })));
|
|
@@ -16,7 +16,7 @@ interface IThProps {
|
|
|
16
16
|
onSelectAllIndexesHandler?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
17
|
propConfig?: IColumnConfig<any>;
|
|
18
18
|
propName: string;
|
|
19
|
-
schema
|
|
19
|
+
schema?: oas31.SchemaObject;
|
|
20
20
|
setPopoverConfig?: Dispatch<SetStateAction<ISchemaColumnFilterPopoverConfig | undefined>>;
|
|
21
21
|
setSortAsc: Dispatch<SetStateAction<boolean>>;
|
|
22
22
|
setSortColumn: Dispatch<SetStateAction<string>>;
|
|
@@ -59,23 +59,23 @@ const Th = ({ isAllChecked, columnFilterStatus, disableColumnFilter, isSortable,
|
|
|
59
59
|
if ((propConfig === null || propConfig === void 0 ? void 0 : propConfig.title) !== undefined) {
|
|
60
60
|
return propConfig.title;
|
|
61
61
|
}
|
|
62
|
-
if (schema.format &&
|
|
62
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.format) &&
|
|
63
63
|
schema.format.startsWith("date") &&
|
|
64
64
|
(propConfig === null || propConfig === void 0 ? void 0 : propConfig.showTimezones) !== false) {
|
|
65
65
|
return `${uncamel(propName)} (${t(timeZone)})`;
|
|
66
66
|
}
|
|
67
67
|
return uncamel(propName);
|
|
68
|
-
}, [propConfig, propName, schema.format]);
|
|
68
|
+
}, [propConfig, propName, schema === null || schema === void 0 ? void 0 : schema.format]);
|
|
69
69
|
if (propName === SELECT_ALL_COLUMN_NAME) {
|
|
70
70
|
return (_jsx("div", Object.assign({}, thDivProps, { children: _jsx("div", Object.assign({ style: {
|
|
71
71
|
width: "100%",
|
|
72
72
|
textAlign: "center",
|
|
73
73
|
}, title: `${numberOfSelectedRows || 0} selected` }, { children: _jsx("input", { type: "checkbox", checked: isAllChecked, onChange: onSelectAllIndexesHandler }) })) })));
|
|
74
74
|
}
|
|
75
|
-
if (!schema) {
|
|
75
|
+
if (!schema && !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderData) && !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell)) {
|
|
76
76
|
return _jsx("div", Object.assign({}, thDivProps));
|
|
77
77
|
}
|
|
78
|
-
switch (schema.type) {
|
|
78
|
+
switch (schema === null || schema === void 0 ? void 0 : schema.type) {
|
|
79
79
|
case "boolean":
|
|
80
80
|
thDivProps.className += ` text-${(propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) || "center"} justify-content-${(propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) || "center"}`;
|
|
81
81
|
break;
|
|
@@ -52,6 +52,11 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
|
|
|
52
52
|
if (!config) {
|
|
53
53
|
return columns;
|
|
54
54
|
}
|
|
55
|
+
Object.keys(config).forEach((configKey) => {
|
|
56
|
+
if (!columns.includes(configKey)) {
|
|
57
|
+
columns.push(configKey);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
55
60
|
const invisibleColumns = Object.entries(config).reduce((prev, [propName, propConfig]) => {
|
|
56
61
|
if (propConfig.hidden) {
|
|
57
62
|
prev.push(propName);
|