mig-schema-table 3.0.29 → 3.0.31
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.js +6 -6
- package/dist/SchemaTable/SchemaColumnFilterPopover/index.js +1 -1
- package/dist/SchemaTable/Td/index.d.ts +2 -1
- package/dist/SchemaTable/Td/index.js +2 -2
- package/dist/SchemaTable/index.d.ts +2 -1
- package/dist/SchemaTable/index.js +25 -10
- package/package.json +2 -2
- package/dist/SchemaTable/ColumnFilterRow/index.d.ts +0 -21
- package/dist/SchemaTable/ColumnFilterRow/index.js +0 -111
- package/dist/SchemaTable/index.test.d.ts +0 -1
- package/dist/SchemaTable/index.test.js +0 -18
- package/dist/component/SchemaTable/SchemaColumnFilterPopover/FilterFormComponent/index.d.ts +0 -11
- package/dist/component/SchemaTable/SchemaColumnFilterPopover/FilterFormComponent/index.js +0 -76
- package/dist/component/SchemaTable/SchemaColumnFilterPopover/index.d.ts +0 -15
- package/dist/component/SchemaTable/SchemaColumnFilterPopover/index.js +0 -37
- package/dist/component/SchemaTable/Td/index.d.ts +0 -22
- package/dist/component/SchemaTable/Td/index.js +0 -78
- package/dist/component/SchemaTable/Th/index.d.ts +0 -27
- package/dist/component/SchemaTable/Th/index.js +0 -78
- package/dist/component/SchemaTable/constants.d.ts +0 -2
- package/dist/component/SchemaTable/constants.js +0 -2
- package/dist/component/SchemaTable/index.d.ts +0 -34
- package/dist/component/SchemaTable/index.js +0 -343
- package/dist/component/SchemaTable/index.test.d.ts +0 -1
- package/dist/component/SchemaTable/index.test.js +0 -17
- package/dist/component/inc/constant.d.ts +0 -2
- package/dist/component/inc/constant.js +0 -2
- package/dist/component/inc/date.d.ts +0 -1
- package/dist/component/inc/date.js +0 -3
- package/dist/component/inc/schema.d.ts +0 -2
- package/dist/component/inc/schema.js +0 -32
- package/dist/component/inc/string.d.ts +0 -1
- package/dist/component/inc/string.js +0 -17
- package/dist/component/index.d.ts +0 -4
- package/dist/component/index.js +0 -2
- package/dist/component/types.d.ts +0 -21
- package/dist/component/types.js +0 -1
- package/dist/exampleData.d.ts +0 -29
- package/dist/exampleData.js +0 -177
|
@@ -9,7 +9,7 @@ const FilterFormComponent = ({ onChange, propSchema, propName, columnFilterValue
|
|
|
9
9
|
const value = columnFilterValue;
|
|
10
10
|
switch (type) {
|
|
11
11
|
case "integer":
|
|
12
|
-
return (_jsx("div", Object.assign({ className: "
|
|
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) => {
|
|
13
13
|
onChange(e.currentTarget.value === ""
|
|
14
14
|
? undefined
|
|
15
15
|
: parseInt(e.currentTarget.value));
|
|
@@ -19,7 +19,7 @@ const FilterFormComponent = ({ onChange, propSchema, propName, columnFilterValue
|
|
|
19
19
|
if (value === undefined) {
|
|
20
20
|
selectValue = "";
|
|
21
21
|
}
|
|
22
|
-
return (_jsxs("select", Object.assign({ value: selectValue, "data-prop-name": propName, onChange: (e) => {
|
|
22
|
+
return (_jsxs("select", Object.assign({ 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, columnFilterValue
|
|
|
34
34
|
// @ts-ignore
|
|
35
35
|
case "string":
|
|
36
36
|
if (propSchema.enum) {
|
|
37
|
-
return (_jsxs("select", Object.assign({ value: value, "data-prop-name": propName, onChange: (e) => {
|
|
37
|
+
return (_jsxs("select", Object.assign({ 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) => (_jsx("option", Object.assign({ value: name }, { children: uncamel(name) }), `column-filter-select-${name}`)))] })));
|
|
40
40
|
}
|
|
@@ -64,13 +64,13 @@ const FilterFormComponent = ({ onChange, propSchema, propName, columnFilterValue
|
|
|
64
64
|
}
|
|
65
65
|
onChange(Object.assign(Object.assign({}, columnFilterValue), { to: date || undefined }));
|
|
66
66
|
};
|
|
67
|
-
return (
|
|
67
|
+
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" })] }))] })));
|
|
68
68
|
}
|
|
69
69
|
// falls through
|
|
70
70
|
default:
|
|
71
|
-
return (_jsx("div", Object.assign({ className: "
|
|
71
|
+
return (_jsx("div", Object.assign({ className: "input-group" }, { children: _jsx("input", { type: "text", className: "form-control", placeholder: `Search ${propName}`, "aria-label": `Search ${propName}`, autoFocus: true, value: (value || ""), "data-prop-name": propName, onChange: (e) => {
|
|
72
72
|
onChange(e.currentTarget.value || undefined);
|
|
73
|
-
}
|
|
73
|
+
} }) })));
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
export default React.memo(FilterFormComponent);
|
|
@@ -28,7 +28,7 @@ const SchemaColumnFilterPopover = ({ onChange, onClose, propName, propSchema, re
|
|
|
28
28
|
window.removeEventListener("click", onWindowClick, { capture: true });
|
|
29
29
|
};
|
|
30
30
|
}, [onClose, popperElement]);
|
|
31
|
-
const classNames = ["popover"];
|
|
31
|
+
const classNames = ["popover", "schema-column-filter-popover"];
|
|
32
32
|
if (attributes.popper) {
|
|
33
33
|
classNames.push(`bs-popover-${attributes.popper["data-popper-placement"]}`);
|
|
34
34
|
}
|
|
@@ -3,6 +3,7 @@ import { oas31 } from "openapi3-ts";
|
|
|
3
3
|
import { IColumnConfig, IRenderData } from "../../types";
|
|
4
4
|
interface ITdProps<T> {
|
|
5
5
|
checkedIndexes?: number[];
|
|
6
|
+
disabledCheckedIndexes?: number[];
|
|
6
7
|
columnIndex: number;
|
|
7
8
|
data: T[];
|
|
8
9
|
getRowClassName?: (rowData: T, dataIndex: number) => string;
|
|
@@ -17,6 +18,6 @@ interface ITdProps<T> {
|
|
|
17
18
|
sortedRenderData?: IRenderData[];
|
|
18
19
|
style: React.CSSProperties;
|
|
19
20
|
}
|
|
20
|
-
declare function Td<T>({ checkedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }: ITdProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
+
declare function Td<T>({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }: ITdProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
21
22
|
declare const _default: typeof Td;
|
|
22
23
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { SELECT_ALL_COLUMN_NAME } from "../constants";
|
|
4
|
-
function Td({ checkedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }) {
|
|
4
|
+
function Td({ checkedIndexes, disabledCheckedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }) {
|
|
5
5
|
const onTdClick = React.useCallback((e) => {
|
|
6
6
|
if (!sortedRenderData || !onRowClick) {
|
|
7
7
|
return;
|
|
@@ -55,7 +55,7 @@ function Td({ checkedIndexes, columnIndex, data, getRowClassName, getRowSelected
|
|
|
55
55
|
}
|
|
56
56
|
onCheckedIndexesChange([row._index]);
|
|
57
57
|
};
|
|
58
|
-
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) }) })) })));
|
|
58
|
+
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) }) })) })));
|
|
59
59
|
}
|
|
60
60
|
if (!propSchema) {
|
|
61
61
|
return null;
|
|
@@ -4,6 +4,7 @@ import { IColumnConfig } from "../types";
|
|
|
4
4
|
export interface ISchemaTableProps<T> {
|
|
5
5
|
Heading?: any;
|
|
6
6
|
checkedIndexes?: number[];
|
|
7
|
+
disabledCheckedIndexes?: number[];
|
|
7
8
|
config?: {
|
|
8
9
|
[propName: string]: IColumnConfig<T>;
|
|
9
10
|
};
|
|
@@ -29,6 +30,6 @@ export type TColumnFilterValue = string | number | boolean | {
|
|
|
29
30
|
from?: Date;
|
|
30
31
|
to?: Date;
|
|
31
32
|
};
|
|
32
|
-
declare function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style, width, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
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, }: ISchemaTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
33
34
|
declare const _default: typeof SchemaTable;
|
|
34
35
|
export default _default;
|
|
@@ -8,7 +8,7 @@ import { SELECT_ALL_COLUMN_NAME, SELECT_ALL_COLUMN_WIDTH } from "./constants";
|
|
|
8
8
|
import Td from "./Td";
|
|
9
9
|
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT } from "../inc/constant";
|
|
10
10
|
import SchemaColumnFilterPopover from "./SchemaColumnFilterPopover";
|
|
11
|
-
function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, customElement, data, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isColumnFilterable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, }) {
|
|
11
|
+
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, }) {
|
|
12
12
|
const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
|
|
13
13
|
const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
|
|
14
14
|
const [searchQuery, setSearchQuery] = React.useState("");
|
|
@@ -113,11 +113,12 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
113
113
|
let dynamicWidthColumnCount = 0;
|
|
114
114
|
columnNames.forEach((propName) => {
|
|
115
115
|
if (propName === SELECT_ALL_COLUMN_NAME) {
|
|
116
|
-
|
|
116
|
+
fixedWidthColumnsWidth += SELECT_ALL_COLUMN_WIDTH;
|
|
117
|
+
return;
|
|
117
118
|
}
|
|
118
119
|
const propConfig = config ? config[propName] : undefined;
|
|
119
120
|
if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.width) {
|
|
120
|
-
fixedWidthColumnsWidth += propConfig.width
|
|
121
|
+
fixedWidthColumnsWidth += propConfig.width;
|
|
121
122
|
}
|
|
122
123
|
else {
|
|
123
124
|
dynamicWidthColumnCount += 1;
|
|
@@ -127,12 +128,20 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
127
128
|
}, [columnNames, config]);
|
|
128
129
|
const columnWidths = React.useMemo(() => {
|
|
129
130
|
const dynamicColumnWidth = Math.floor((width - fixedWidthColumnsWidth) / dynamicWidthColumnCount);
|
|
131
|
+
let roundingDifference = (width - fixedWidthColumnsWidth) % dynamicWidthColumnCount;
|
|
130
132
|
return columnNames.map((propName) => {
|
|
131
133
|
if (propName === SELECT_ALL_COLUMN_NAME) {
|
|
132
134
|
return SELECT_ALL_COLUMN_WIDTH;
|
|
133
135
|
}
|
|
134
136
|
const propConfig = config ? config[propName] : undefined;
|
|
135
|
-
|
|
137
|
+
if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.width) {
|
|
138
|
+
return propConfig === null || propConfig === void 0 ? void 0 : propConfig.width;
|
|
139
|
+
}
|
|
140
|
+
if (roundingDifference) {
|
|
141
|
+
roundingDifference -= 1;
|
|
142
|
+
return dynamicColumnWidth + 1;
|
|
143
|
+
}
|
|
144
|
+
return dynamicColumnWidth;
|
|
136
145
|
});
|
|
137
146
|
}, [
|
|
138
147
|
columnNames,
|
|
@@ -246,13 +255,18 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
246
255
|
if (!onCheckedIndexesChange || !filteredRenderData) {
|
|
247
256
|
return;
|
|
248
257
|
}
|
|
249
|
-
onCheckedIndexesChange(filteredRenderData
|
|
250
|
-
|
|
258
|
+
onCheckedIndexesChange(filteredRenderData
|
|
259
|
+
.map((el) => el._index)
|
|
260
|
+
.filter((index) => !(disabledCheckedIndexes === null || disabledCheckedIndexes === void 0 ? void 0 : disabledCheckedIndexes.includes(index))));
|
|
261
|
+
}, [onCheckedIndexesChange, filteredRenderData, disabledCheckedIndexes]);
|
|
251
262
|
const isAllRowsChecked = React.useMemo(() => {
|
|
263
|
+
const tableData = [...(filteredRenderData || [])].filter((el) => (checkedIndexes ? checkedIndexes.includes(el._index) : true) ||
|
|
264
|
+
(disabledCheckedIndexes
|
|
265
|
+
? !disabledCheckedIndexes.includes(el._index)
|
|
266
|
+
: true));
|
|
252
267
|
return ((checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length) !== 0 &&
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}, [checkedIndexes, filteredRenderData]);
|
|
268
|
+
tableData.length === (checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length));
|
|
269
|
+
}, [checkedIndexes, disabledCheckedIndexes, filteredRenderData]);
|
|
256
270
|
const disableColumnFilter = React.useCallback((propName) => {
|
|
257
271
|
const newColumnFilterMap = Object.assign({}, columnFilterMap);
|
|
258
272
|
delete newColumnFilterMap[propName];
|
|
@@ -284,12 +298,13 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
284
298
|
]);
|
|
285
299
|
const SchemaTableTd = React.useCallback(({ columnIndex, rowIndex, style }) => {
|
|
286
300
|
const propName = columnNames[columnIndex];
|
|
287
|
-
return (_jsx(Td, { checkedIndexes: checkedIndexes, columnIndex: columnIndex, data: data, getRowClassName: getRowClassName, getRowSelected: getRowSelected, onCheckedIndexesChange: onCheckedIndexesChange, onRowClick: onRowClick, propConfig: config ? config[propName] : undefined, propName: propName, propSchema: properties[propName], rowHeight: rowHeight, rowIndex: rowIndex, sortedRenderData: sortedRenderData, style: style }));
|
|
301
|
+
return (_jsx(Td, { checkedIndexes: checkedIndexes, disabledCheckedIndexes: disabledCheckedIndexes, columnIndex: columnIndex, data: data, getRowClassName: getRowClassName, getRowSelected: getRowSelected, onCheckedIndexesChange: onCheckedIndexesChange, onRowClick: onRowClick, propConfig: config ? config[propName] : undefined, propName: propName, propSchema: properties[propName], rowHeight: rowHeight, rowIndex: rowIndex, sortedRenderData: sortedRenderData, style: style }));
|
|
288
302
|
}, [
|
|
289
303
|
checkedIndexes,
|
|
290
304
|
columnNames,
|
|
291
305
|
config,
|
|
292
306
|
data,
|
|
307
|
+
disabledCheckedIndexes,
|
|
293
308
|
getRowClassName,
|
|
294
309
|
getRowSelected,
|
|
295
310
|
onCheckedIndexesChange,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mig-schema-table",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.31",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"react-window": "^1.8.9"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc -p tsconfig.json; sass --no-source-map src/component/index.scss dist/index.css",
|
|
27
|
+
"build": "rm -rf dist; tsc -p tsconfig.json; sass --no-source-map src/component/index.scss dist/index.css",
|
|
28
28
|
"prepublishOnly": "npm run build",
|
|
29
29
|
"start": "react-scripts start",
|
|
30
30
|
"test": "react-scripts test"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import { IColumnConfig } from "../../types";
|
|
3
|
-
import { oas31 } from "openapi3-ts";
|
|
4
|
-
import "react-datepicker/dist/react-datepicker.css";
|
|
5
|
-
import { tColumnSearchValue } from "../index";
|
|
6
|
-
interface IColumnFilterRowProps {
|
|
7
|
-
columnNames: string[];
|
|
8
|
-
getWidth: (index: number) => number;
|
|
9
|
-
config?: {
|
|
10
|
-
[propName: string]: IColumnConfig<any>;
|
|
11
|
-
};
|
|
12
|
-
columnSearchHandler: (propName: string, value: tColumnSearchValue) => void;
|
|
13
|
-
value: {
|
|
14
|
-
[propName: string]: tColumnSearchValue;
|
|
15
|
-
};
|
|
16
|
-
schema: oas31.SchemaObject;
|
|
17
|
-
columnFilterDropdown?: string;
|
|
18
|
-
setColumnFilterDropdown?: Dispatch<SetStateAction<string | undefined>>;
|
|
19
|
-
}
|
|
20
|
-
export default function ColumnFilterRow({ columnNames, getWidth, config, value, columnSearchHandler, schema, columnFilterDropdown, setColumnFilterDropdown, }: IColumnFilterRowProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
export {};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { SELECT_ALL_COLUMN_NAME } from "../constants";
|
|
4
|
-
import DatePicker from "react-datepicker";
|
|
5
|
-
import nl from "date-fns/locale/nl";
|
|
6
|
-
import "react-datepicker/dist/react-datepicker.css";
|
|
7
|
-
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, } from "../../inc/constant";
|
|
8
|
-
import { getUnixTimeStamp } from "../../inc/date";
|
|
9
|
-
export default function ColumnFilterRow({ columnNames, getWidth, config, value, columnSearchHandler, schema, columnFilterDropdown, setColumnFilterDropdown, }) {
|
|
10
|
-
const { properties = {} } = schema;
|
|
11
|
-
const getSelectComponent = React.useCallback((propSchema, propName, value, inputChangeHandler) => {
|
|
12
|
-
const enumItems = propSchema.type === "boolean" ? ["✓", "✕"] : propSchema.enum;
|
|
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
|
-
}, []);
|
|
15
|
-
const field = React.useCallback((propSchema, propName, propValue) => {
|
|
16
|
-
const { type, format, minimum, maximum } = propSchema;
|
|
17
|
-
const inputChangeHandler = (event) => {
|
|
18
|
-
columnSearchHandler(propName, event.target.value);
|
|
19
|
-
};
|
|
20
|
-
const strValue = (propValue || "");
|
|
21
|
-
switch (type) {
|
|
22
|
-
case "string":
|
|
23
|
-
if (propSchema.enum) {
|
|
24
|
-
return getSelectComponent(propSchema, propName, strValue, inputChangeHandler);
|
|
25
|
-
}
|
|
26
|
-
if (format === "date-time" || format === "date") {
|
|
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 : ""}` }));
|
|
42
|
-
};
|
|
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" })] }))] })) })));
|
|
52
|
-
}
|
|
53
|
-
return (_jsx("div", Object.assign({ className: "p-1" }, { children: _jsx("input", { value: strValue, "data-prop-name": propName, onChange: inputChangeHandler, placeholder: `Search ${propName}` }) })));
|
|
54
|
-
case "integer":
|
|
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 }) })));
|
|
56
|
-
case "boolean":
|
|
57
|
-
return getSelectComponent(propSchema, propName, strValue, inputChangeHandler);
|
|
58
|
-
default:
|
|
59
|
-
return _jsx(_Fragment, {});
|
|
60
|
-
}
|
|
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]);
|
|
89
|
-
const SchemaColumnFilter = React.useCallback((index) => {
|
|
90
|
-
const propName = columnNames[index];
|
|
91
|
-
const propSchema = properties[propName];
|
|
92
|
-
const propConfig = config ? config[propName] : undefined;
|
|
93
|
-
const propValue = value === null || value === void 0 ? void 0 : value[propName];
|
|
94
|
-
if (propName === SELECT_ALL_COLUMN_NAME || !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.isFilterable)) {
|
|
95
|
-
return _jsx("div", { className: "schema-table__th" });
|
|
96
|
-
}
|
|
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]);
|
|
105
|
-
return (_jsx("div", Object.assign({ className: "schema-table__th-row", style: { display: "flex", flex: "row" } }, { children: columnNames.map((columnName, index) => {
|
|
106
|
-
return (_jsx("div", Object.assign({ className: "schema-table__column-filter", style: {
|
|
107
|
-
width: getWidth(index),
|
|
108
|
-
paddingBottom: 7,
|
|
109
|
-
} }, { children: SchemaColumnFilter(index) }), `filter-${index}`));
|
|
110
|
-
}) })));
|
|
111
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "@testing-library/jest-dom";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import "@testing-library/jest-dom";
|
|
12
|
-
import { render, screen } from "@testing-library/react";
|
|
13
|
-
import SchemaTable from "./index";
|
|
14
|
-
it("renders an empty table", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
render(_jsx(SchemaTable, { data: [], schema: {}, width: 1 }));
|
|
16
|
-
const table = yield screen.findByRole("table");
|
|
17
|
-
expect(table).toBeInTheDocument();
|
|
18
|
-
}));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { oas31 } from "openapi3-ts";
|
|
3
|
-
import { TColumnFilterValue } from "../../index";
|
|
4
|
-
interface IFilterFormComponentProps {
|
|
5
|
-
onChange: (newValue?: TColumnFilterValue) => void;
|
|
6
|
-
propSchema: oas31.SchemaObject;
|
|
7
|
-
propName: string;
|
|
8
|
-
columnFilterValue: TColumnFilterValue;
|
|
9
|
-
}
|
|
10
|
-
declare const _default: React.MemoExoticComponent<({ onChange, propSchema, propName, columnFilterValue, }: IFilterFormComponentProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
-
export default _default;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { uncamel } from "../../../inc/string";
|
|
4
|
-
import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, } from "../../../inc/constant";
|
|
5
|
-
import DatePicker from "react-datepicker";
|
|
6
|
-
import nl from "date-fns/locale/nl";
|
|
7
|
-
const FilterFormComponent = ({ onChange, propSchema, propName, columnFilterValue, }) => {
|
|
8
|
-
const { type, format, minimum, maximum } = propSchema;
|
|
9
|
-
const value = columnFilterValue;
|
|
10
|
-
switch (type) {
|
|
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) => {
|
|
13
|
-
onChange(e.currentTarget.value === ""
|
|
14
|
-
? undefined
|
|
15
|
-
: parseInt(e.currentTarget.value));
|
|
16
|
-
}, placeholder: `Search ${propName}`, min: minimum, max: maximum }) })));
|
|
17
|
-
case "boolean":
|
|
18
|
-
let selectValue = value ? "✓" : "✕";
|
|
19
|
-
if (value === undefined) {
|
|
20
|
-
selectValue = "";
|
|
21
|
-
}
|
|
22
|
-
return (_jsxs("select", Object.assign({ className: "form-select", value: selectValue, "data-prop-name": propName, onChange: (e) => {
|
|
23
|
-
switch (e.currentTarget.value) {
|
|
24
|
-
case "✓":
|
|
25
|
-
onChange(true);
|
|
26
|
-
break;
|
|
27
|
-
case "✕":
|
|
28
|
-
onChange(false);
|
|
29
|
-
break;
|
|
30
|
-
default:
|
|
31
|
-
onChange(undefined);
|
|
32
|
-
}
|
|
33
|
-
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), ["✓", "✕"].map((optionValue) => (_jsx("option", Object.assign({ value: optionValue }, { children: optionValue }), `column-filter-select-${optionValue}`)))] })));
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
case "string":
|
|
36
|
-
if (propSchema.enum) {
|
|
37
|
-
return (_jsxs("select", Object.assign({ className: "form-select", value: value, "data-prop-name": propName, onChange: (e) => {
|
|
38
|
-
onChange(e.currentTarget.value || undefined);
|
|
39
|
-
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "All" }), "all"), propSchema.enum.map((name) => (_jsx("option", Object.assign({ value: name }, { children: uncamel(name) }), `column-filter-select-${name}`)))] })));
|
|
40
|
-
}
|
|
41
|
-
if (format === "date-time" || format === "date") {
|
|
42
|
-
const dateFormat = format === "date" ? DEFAULT_DATE_FORMAT : DEFAULT_DATE_TIME_FORMAT;
|
|
43
|
-
const dateRangeValue = (columnFilterValue || {
|
|
44
|
-
from: undefined,
|
|
45
|
-
to: undefined,
|
|
46
|
-
});
|
|
47
|
-
const startDateChangeHandler = (date) => {
|
|
48
|
-
if (!date && !dateRangeValue.to) {
|
|
49
|
-
onChange(undefined);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (dateRangeValue.to && date && date > dateRangeValue.to) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
onChange(Object.assign(Object.assign({}, columnFilterValue), { from: date || undefined }));
|
|
56
|
-
};
|
|
57
|
-
const endDateChangeHandler = (date) => {
|
|
58
|
-
if (!date && !dateRangeValue.from) {
|
|
59
|
-
onChange(undefined);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (dateRangeValue.from && date && date < dateRangeValue.from) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
onChange(Object.assign(Object.assign({}, columnFilterValue), { to: date || undefined }));
|
|
66
|
-
};
|
|
67
|
-
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" })] }))] })));
|
|
68
|
-
}
|
|
69
|
-
// falls through
|
|
70
|
-
default:
|
|
71
|
-
return (_jsx("div", Object.assign({ className: "input-group" }, { children: _jsx("input", { type: "text", className: "form-control", placeholder: `Search ${propName}`, "aria-label": `Search ${propName}`, autoFocus: true, value: (value || ""), "data-prop-name": propName, onChange: (e) => {
|
|
72
|
-
onChange(e.currentTarget.value || undefined);
|
|
73
|
-
} }) })));
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
export default React.memo(FilterFormComponent);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { oas31 } from "openapi3-ts";
|
|
3
|
-
import { TColumnFilterValue } from "../index";
|
|
4
|
-
export interface ISchemaColumnFilterPopoverConfig {
|
|
5
|
-
referenceElement: HTMLElement;
|
|
6
|
-
propName: string;
|
|
7
|
-
}
|
|
8
|
-
type TSchemaColumnFilterPopoverProps = ISchemaColumnFilterPopoverConfig & {
|
|
9
|
-
onChange: (newValue?: TColumnFilterValue) => void;
|
|
10
|
-
propSchema: oas31.SchemaObject;
|
|
11
|
-
value: TColumnFilterValue;
|
|
12
|
-
onClose: () => void;
|
|
13
|
-
};
|
|
14
|
-
declare const _default: React.MemoExoticComponent<({ onChange, onClose, propName, propSchema, referenceElement, value, }: TSchemaColumnFilterPopoverProps) => import("react/jsx-runtime").JSX.Element>;
|
|
15
|
-
export default _default;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import FilterFormComponent from "./FilterFormComponent";
|
|
4
|
-
import { usePopper } from "react-popper";
|
|
5
|
-
const SchemaColumnFilterPopover = ({ onChange, onClose, propName, propSchema, referenceElement, value, }) => {
|
|
6
|
-
const [popperElement, setPopperElement] = React.useState(null);
|
|
7
|
-
const [arrowElement, setArrowElement] = React.useState(null);
|
|
8
|
-
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
9
|
-
modifiers: [{ name: "arrow", options: { element: arrowElement } }],
|
|
10
|
-
});
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
const onWindowClick = (e) => {
|
|
13
|
-
if (!popperElement) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
let parent = e.target;
|
|
17
|
-
while (parent && popperElement) {
|
|
18
|
-
if (parent === popperElement) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
parent =
|
|
22
|
-
parent.parentNode === window.document ? null : parent.parentNode;
|
|
23
|
-
}
|
|
24
|
-
onClose();
|
|
25
|
-
};
|
|
26
|
-
window.addEventListener("click", onWindowClick, { capture: true });
|
|
27
|
-
return () => {
|
|
28
|
-
window.removeEventListener("click", onWindowClick, { capture: true });
|
|
29
|
-
};
|
|
30
|
-
}, [onClose, popperElement]);
|
|
31
|
-
const classNames = ["popover", "schema-column-filter-popover"];
|
|
32
|
-
if (attributes.popper) {
|
|
33
|
-
classNames.push(`bs-popover-${attributes.popper["data-popper-placement"]}`);
|
|
34
|
-
}
|
|
35
|
-
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(FilterFormComponent, { onChange: onChange, propSchema: propSchema, propName: propName, columnFilterValue: value }) }))] })));
|
|
36
|
-
};
|
|
37
|
-
export default React.memo(SchemaColumnFilterPopover);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { oas31 } from "openapi3-ts";
|
|
3
|
-
import { IColumnConfig, IRenderData } from "../../types";
|
|
4
|
-
interface ITdProps<T> {
|
|
5
|
-
checkedIndexes?: number[];
|
|
6
|
-
columnIndex: number;
|
|
7
|
-
data: T[];
|
|
8
|
-
getRowClassName?: (rowData: T, dataIndex: number) => string;
|
|
9
|
-
getRowSelected?: (rowData: T) => boolean;
|
|
10
|
-
rowHeight: number;
|
|
11
|
-
rowIndex: number;
|
|
12
|
-
onCheckedIndexesChange?: (dataIndex: number[]) => void;
|
|
13
|
-
onRowClick?: (rowData: T, dataIndex: number, event: React.MouseEvent) => void;
|
|
14
|
-
propConfig?: IColumnConfig<any>;
|
|
15
|
-
propName: string;
|
|
16
|
-
propSchema: oas31.SchemaObject;
|
|
17
|
-
sortedRenderData?: IRenderData[];
|
|
18
|
-
style: React.CSSProperties;
|
|
19
|
-
}
|
|
20
|
-
declare function Td<T>({ checkedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }: ITdProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
21
|
-
declare const _default: typeof Td;
|
|
22
|
-
export default _default;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { SELECT_ALL_COLUMN_NAME } from "../constants";
|
|
4
|
-
function Td({ checkedIndexes, columnIndex, data, getRowClassName, getRowSelected, onCheckedIndexesChange, onRowClick, propConfig, propName, propSchema, rowHeight, rowIndex, sortedRenderData, style, }) {
|
|
5
|
-
const onTdClick = React.useCallback((e) => {
|
|
6
|
-
if (!sortedRenderData || !onRowClick) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const { rowIndex } = e.currentTarget.dataset;
|
|
10
|
-
if (!rowIndex) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const row = sortedRenderData[parseInt(rowIndex, 10)];
|
|
14
|
-
onRowClick(data[row._index], row._index, e);
|
|
15
|
-
}, [data, onRowClick, sortedRenderData]);
|
|
16
|
-
const row = sortedRenderData ? sortedRenderData[rowIndex] : undefined;
|
|
17
|
-
const tdDivProps = React.useMemo(() => {
|
|
18
|
-
if (!row) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
"data-row-index": rowIndex,
|
|
23
|
-
"data-column-index": columnIndex,
|
|
24
|
-
key: propName,
|
|
25
|
-
style: Object.assign(Object.assign({}, style), { lineHeight: `${rowHeight}px` }),
|
|
26
|
-
onClick: !(propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell) ? onTdClick : undefined,
|
|
27
|
-
className: `schema-table__td schema-table__td--${rowIndex % 2 ? "odd" : "even"}${getRowSelected && getRowSelected(data[row._index])
|
|
28
|
-
? " schema-table__td--selected"
|
|
29
|
-
: ""} ${getRowClassName ? getRowClassName(data[row._index], row._index) : ""}`,
|
|
30
|
-
title: row[propName],
|
|
31
|
-
};
|
|
32
|
-
}, [
|
|
33
|
-
columnIndex,
|
|
34
|
-
data,
|
|
35
|
-
getRowClassName,
|
|
36
|
-
getRowSelected,
|
|
37
|
-
onTdClick,
|
|
38
|
-
propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell,
|
|
39
|
-
propName,
|
|
40
|
-
row,
|
|
41
|
-
rowHeight,
|
|
42
|
-
rowIndex,
|
|
43
|
-
style,
|
|
44
|
-
]);
|
|
45
|
-
if (!row || !tdDivProps) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell) {
|
|
49
|
-
return (_jsx("div", Object.assign({}, tdDivProps, { children: propConfig.renderCell(data[row._index], row._index, rowIndex) })));
|
|
50
|
-
}
|
|
51
|
-
if (propName === SELECT_ALL_COLUMN_NAME) {
|
|
52
|
-
const onChecked = () => {
|
|
53
|
-
if (!onCheckedIndexesChange) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
onCheckedIndexesChange([row._index]);
|
|
57
|
-
};
|
|
58
|
-
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) }) })) })));
|
|
59
|
-
}
|
|
60
|
-
if (!propSchema) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
switch (propSchema.type) {
|
|
64
|
-
case "boolean":
|
|
65
|
-
tdDivProps.className += ` text-${(propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) || "center"}`;
|
|
66
|
-
break;
|
|
67
|
-
case "number":
|
|
68
|
-
case "integer":
|
|
69
|
-
tdDivProps.className += ` text-${(propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) || "end"}`;
|
|
70
|
-
break;
|
|
71
|
-
default:
|
|
72
|
-
if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.align) {
|
|
73
|
-
tdDivProps.className += ` text-${propConfig.align}`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return _jsx("div", Object.assign({}, tdDivProps, { children: row[propName] }));
|
|
77
|
-
}
|
|
78
|
-
export default React.memo(Td);
|