mig-schema-table 3.0.48 → 3.0.50
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.
|
@@ -92,6 +92,7 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
92
92
|
if (!propSchema) {
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
|
+
const propValue = row[propName];
|
|
95
96
|
switch (propSchema.type) {
|
|
96
97
|
case "boolean":
|
|
97
98
|
tdDivProps.className += ` text-${(propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) || "center"}`;
|
|
@@ -104,7 +105,12 @@ function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowC
|
|
|
104
105
|
if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) {
|
|
105
106
|
tdDivProps.className += ` text-${propConfig.align}`;
|
|
106
107
|
}
|
|
108
|
+
if (propSchema.format === "url" && propValue) {
|
|
109
|
+
return (
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
_jsx("a", Object.assign({ href: propValue, target: "_blank", rel: "noopener noreferrer" }, tdDivProps, { children: propValue })));
|
|
112
|
+
}
|
|
107
113
|
}
|
|
108
|
-
return _jsx("div", Object.assign({}, tdDivProps, { children:
|
|
114
|
+
return _jsx("div", Object.assign({}, tdDivProps, { children: propValue }));
|
|
109
115
|
}
|
|
110
116
|
export default React.memo(Td);
|
|
@@ -24,6 +24,7 @@ export interface ISchemaTableProps<T> {
|
|
|
24
24
|
getRowSelected?: (rowData: T, dataIndex: number) => boolean;
|
|
25
25
|
maxHeight?: number;
|
|
26
26
|
isSearchable?: boolean;
|
|
27
|
+
enableAutoFocus?: boolean;
|
|
27
28
|
isColumnFilterable?: boolean;
|
|
28
29
|
isSortable?: boolean;
|
|
29
30
|
onCheckedIndexesChange?: (dataIndex: number[]) => void;
|
|
@@ -39,6 +40,6 @@ export type TColumnFilterValue = string | number | boolean | {
|
|
|
39
40
|
from?: Date;
|
|
40
41
|
to?: Date;
|
|
41
42
|
};
|
|
42
|
-
declare function SchemaTable<T>({ Heading, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style, width, onRowDoubleClick, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
declare function SchemaTable<T>({ Heading, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style, width, onRowDoubleClick, enableAutoFocus, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
43
44
|
declare const _default: typeof SchemaTable;
|
|
44
45
|
export default _default;
|
|
@@ -9,7 +9,7 @@ import Td from "./Td";
|
|
|
9
9
|
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
|
|
10
10
|
import SchemaColumnFilterPopover from "./SchemaColumnFilterPopover";
|
|
11
11
|
const startOfTheWorldDate = new Date("1000-01-01 00:00:00Z");
|
|
12
|
-
function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, onRowDoubleClick, }) {
|
|
12
|
+
function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheckedIndexes, config, customElement, data, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, onRowDoubleClick, enableAutoFocus, }) {
|
|
13
13
|
const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
|
|
14
14
|
const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
|
|
15
15
|
const [searchQuery, setSearchQuery] = React.useState("");
|
|
@@ -435,7 +435,13 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, disabledCheck
|
|
|
435
435
|
}
|
|
436
436
|
setColumnFilterMap((columnFilterMap) => (Object.assign(Object.assign({}, columnFilterMap), { [popoverConfig.propName]: newColumnFilterValue })));
|
|
437
437
|
}, [disableColumnFilter, isDataFunction, popoverConfig]);
|
|
438
|
-
|
|
438
|
+
const searchInputAutoFocus = React.useMemo(() => {
|
|
439
|
+
if (enableAutoFocus === undefined) {
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
return enableAutoFocus;
|
|
443
|
+
}, [enableAutoFocus]);
|
|
444
|
+
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: searchInputAutoFocus })) : 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: {
|
|
439
445
|
width: rowWidth,
|
|
440
446
|
height: Math.max(50, tableBodyHeight),
|
|
441
447
|
border: "1px solid #BBB",
|