mig-schema-table 3.0.4 → 3.0.6
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/index.d.ts +5 -6
- package/dist/SchemaTable/index.js +4 -4
- package/dist/inc/schema.d.ts +2 -2
- package/dist/index.css +3 -0
- package/dist/types.d.ts +2 -2
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { oas31 } from "openapi3-ts";
|
|
3
|
-
import { IColumnConfig
|
|
3
|
+
import { IColumnConfig } from "../types";
|
|
4
4
|
export interface ISchemaTableComponentProps<T> {
|
|
5
5
|
Heading?: any;
|
|
6
6
|
checkedIndexes?: number[];
|
|
@@ -11,18 +11,17 @@ export interface ISchemaTableComponentProps<T> {
|
|
|
11
11
|
data: T[];
|
|
12
12
|
defaultSortAsc?: boolean;
|
|
13
13
|
defaultSortColumn?: keyof T;
|
|
14
|
-
getRowClassName?: (rowData: T,
|
|
14
|
+
getRowClassName?: (rowData: T, dataIndex: number) => string;
|
|
15
15
|
getRowSelected?: (rowData: T) => boolean;
|
|
16
16
|
maxHeight?: number;
|
|
17
17
|
isSearchable?: boolean;
|
|
18
18
|
isSortable?: boolean;
|
|
19
|
-
onCheckedIndexesChange?: (
|
|
20
|
-
onRowClick?: (rowData: T,
|
|
19
|
+
onCheckedIndexesChange?: (dataIndex: number[]) => void;
|
|
20
|
+
onRowClick?: (rowData: T, dataIndex: number, event: React.MouseEvent) => void;
|
|
21
21
|
rowHeight?: number;
|
|
22
22
|
schema: oas31.SchemaObject;
|
|
23
23
|
searchPlaceholder?: string;
|
|
24
24
|
style?: React.CSSProperties;
|
|
25
|
-
tableTitle?: string;
|
|
26
25
|
width: number;
|
|
27
26
|
}
|
|
28
|
-
export default function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style,
|
|
27
|
+
export default function SchemaTable<T>({ Heading, checkedIndexes, config, customElement, data, defaultSortAsc, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight, schema, searchPlaceholder, style, width, }: ISchemaTableComponentProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { localeFormat } from "../inc/date";
|
|
|
5
5
|
import { uncamel } from "../inc/string";
|
|
6
6
|
import Th from "./Th";
|
|
7
7
|
import { SELECT_ALL_COLUMN_NAME, SELECT_ALL_COLUMN_WIDTH } from "./constants";
|
|
8
|
-
export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, customElement, data, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style,
|
|
8
|
+
export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, customElement, data, defaultSortAsc = false, defaultSortColumn, getRowClassName, getRowSelected, maxHeight, isSearchable, isSortable, onCheckedIndexesChange, onRowClick, rowHeight = 36, schema, searchPlaceholder, style, width, }) {
|
|
9
9
|
const [sortColumn, setSortColumn] = React.useState(defaultSortColumn);
|
|
10
10
|
const [sortAsc, setSortAsc] = React.useState(defaultSortAsc);
|
|
11
11
|
const [searchQuery, setSearchQuery] = React.useState("");
|
|
@@ -254,11 +254,11 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
|
|
|
254
254
|
className: `schema-table__td schema-table__td--${rowIndex % 2 ? "odd" : "even"}${row && getRowSelected && getRowSelected(data[row._index])
|
|
255
255
|
? " schema-table__td--selected"
|
|
256
256
|
: ""} ${row && getRowClassName
|
|
257
|
-
? getRowClassName(data[row._index],
|
|
257
|
+
? getRowClassName(data[row._index], row._index)
|
|
258
258
|
: ""}`,
|
|
259
259
|
};
|
|
260
260
|
if (propConfig === null || propConfig === void 0 ? void 0 : propConfig.renderCell) {
|
|
261
|
-
return (_jsx("div", Object.assign({}, tdDivProps, { children: propConfig.renderCell(data[row._index], rowIndex) })));
|
|
261
|
+
return (_jsx("div", Object.assign({}, tdDivProps, { children: propConfig.renderCell(data[row._index], row._index, rowIndex) })));
|
|
262
262
|
}
|
|
263
263
|
if (propName === SELECT_ALL_COLUMN_NAME) {
|
|
264
264
|
const onChecked = () => {
|
|
@@ -314,5 +314,5 @@ export default function SchemaTable({ Heading = VariableSizeList, checkedIndexes
|
|
|
314
314
|
? rowsMaxHeight
|
|
315
315
|
: rowsHeight;
|
|
316
316
|
}, [maxHeight, isSearchable, rowCount, rowHeight]);
|
|
317
|
-
return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }) }, { children: [
|
|
317
|
+
return (_jsxs("div", Object.assign({ className: `schema-table${onRowClick ? " schema-table--clickable-rows" : ""}`, style: Object.assign(Object.assign({}, style), { width: rowWidth }) }, { children: [_jsxs("div", Object.assign({ className: "action-container" }, { children: [_jsx("div", Object.assign({ style: { flex: 1 } }, { children: isSearchable ? (_jsx("input", { id: "input-filter", type: "text", placeholder: searchPlaceholder || "Search...", value: searchQuery, onChange: onSearchChange, autoFocus: true })) : null })), customElement] })), _jsx(Heading, Object.assign({ height: 50, itemCount: columnCount, itemSize: getColumnWidth, layout: "horizontal", width: rowWidth, sortAsc: sortAsc, setSortAsc: setSortAsc, setSortColumn: setSortColumn, sortColumn: sortColumn, sortedRenderData: sortedRenderData, className: "schema-table__th-row" }, { children: SchemaTableTh }), `thead_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}`), _jsx(VariableSizeGrid, Object.assign({ className: "schema-table__tbody", height: tableBodyHeight, width: rowWidth, columnWidth: getColumnWidth, rowHeight: getRowHeight, columnCount: columnCount, rowCount: rowCount }, { children: Td }), `tbody_${rowWidth}_${sortColumn}_${sortAsc}_${searchQuery}_${columnCount}`)] })));
|
|
318
318
|
}
|
package/dist/inc/schema.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getEmptyObject<T>(schema:
|
|
1
|
+
import { SchemaObject } from "openapi3-ts/oas31";
|
|
2
|
+
export declare function getEmptyObject<T>(schema: SchemaObject): T;
|
package/dist/index.css
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export interface IColumnConfig<T> {
|
|
|
5
5
|
hidden?: boolean;
|
|
6
6
|
hoverTitle?: string;
|
|
7
7
|
isFilterable?: boolean;
|
|
8
|
-
renderCell?: (rowData: T,
|
|
9
|
-
renderData?: (rowData: T,
|
|
8
|
+
renderCell?: (rowData: T, dataIndex: number, rowIndex: number) => React.ReactElement | null;
|
|
9
|
+
renderData?: (rowData: T, dataIndex: number) => string;
|
|
10
10
|
sort?: (a: T, b: T, sortAsc: boolean) => number;
|
|
11
11
|
sortByValue?: boolean;
|
|
12
12
|
sortable?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mig-schema-table",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/"
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"start": "react-scripts start",
|
|
25
|
-
"build": "tsc -p tsconfig.json; sass --no-source-map src/component/SchemaTable/index.scss dist/index.css"
|
|
25
|
+
"build": "tsc -p tsconfig.json; sass --no-source-map src/component/SchemaTable/index.scss dist/index.css",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
26
27
|
},
|
|
27
28
|
"eslintConfig": {
|
|
28
29
|
"extends": [
|