mig-schema-table 3.0.25 → 3.0.27
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/README.md +64 -54
- package/dist/SchemaTable/index.js +3 -2
- package/dist/index.css +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,78 +3,88 @@
|
|
|
3
3
|
This component will render fields dynamically based on openApi schema JSON. Styling can be done using Bootstrap 5 compatible classes
|
|
4
4
|
|
|
5
5
|
# Install
|
|
6
|
+
|
|
6
7
|
```
|
|
7
8
|
npm install mig-schema-table
|
|
8
9
|
```
|
|
9
10
|
|
|
10
11
|
## Usage
|
|
12
|
+
|
|
11
13
|
#### Schema Example:
|
|
14
|
+
|
|
12
15
|
```ts
|
|
13
|
-
const userSchema ={
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const userSchema = {
|
|
17
|
+
properties: {
|
|
18
|
+
id: {
|
|
19
|
+
type: "string",
|
|
20
|
+
readOnly: true,
|
|
21
|
+
},
|
|
22
|
+
name: {
|
|
23
|
+
type: "string",
|
|
24
|
+
minLength: 3,
|
|
22
25
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
dob: {
|
|
27
|
+
type: "string",
|
|
28
|
+
format: "date",
|
|
29
|
+
},
|
|
30
|
+
address: {
|
|
31
|
+
type: "string",
|
|
32
|
+
maxLength: 250,
|
|
26
33
|
},
|
|
27
|
-
"address": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"maxLength": 250
|
|
30
|
-
}
|
|
31
34
|
},
|
|
32
|
-
|
|
33
|
-
}
|
|
35
|
+
required: ["name"],
|
|
36
|
+
};
|
|
34
37
|
```
|
|
38
|
+
|
|
35
39
|
```typescript jsx
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
import React from "react";
|
|
41
|
+
import { SchemaTable, IColumnConfig } from "mig-schema-table";
|
|
42
|
+
import "mig-schema-table/dist/index.css";
|
|
43
|
+
// Add this for default datepicker styling
|
|
44
|
+
import "react-datepicker/dist/react-datepicker.css";
|
|
45
|
+
|
|
46
|
+
const config: { [keyName: string]: IColumnConfig } = {
|
|
47
|
+
id: {
|
|
48
|
+
hidden: true,
|
|
49
|
+
},
|
|
50
|
+
dob: {
|
|
51
|
+
title: "Date of Birth",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
39
54
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
data={users || []}
|
|
54
|
-
schema={userSchema}
|
|
55
|
-
width={window.innerWidth}
|
|
56
|
-
height={window.innerHeight - 150}
|
|
57
|
-
config={config}
|
|
58
|
-
/>
|
|
59
|
-
}
|
|
55
|
+
const Table = () => {
|
|
56
|
+
const [users, setUsers] = useState();
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<SchemaTableComponent
|
|
60
|
+
data={users || []}
|
|
61
|
+
schema={userSchema}
|
|
62
|
+
width={window.innerWidth}
|
|
63
|
+
height={window.innerHeight - 150}
|
|
64
|
+
config={config}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
60
68
|
```
|
|
61
69
|
|
|
62
70
|
## Component Props
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Description |
|
|
73
|
+
| ------------ | ---------- | ----------------------------------------------------------------------- |
|
|
74
|
+
| schema | `object` | schemaObject to be rendered as a set of fields(example openapi schema). |
|
|
75
|
+
| config | `object` | custom UI config {[keyName: string]: IColumnConfig;}. |
|
|
76
|
+
| data | `array` | data props will be rendered from api |
|
|
77
|
+
| onRowClick | `function` | it will be navigate to detail of row data |
|
|
78
|
+
| width | `number` | this props will be calculated width of table |
|
|
79
|
+
| height | `number` | this props will be calculated height of table |
|
|
80
|
+
| tableTitle | `string` | custom title for table your own |
|
|
81
|
+
| isSearchable | `boolean` | if this props is `true` then the search filed will shown |
|
|
82
|
+
| isSortable | `boolean` | if this props is `true` then the table to be able to shorting the data |
|
|
74
83
|
|
|
75
84
|
## Config
|
|
85
|
+
|
|
76
86
|
#### you can import the type of config from the IFieldConfig.
|
|
87
|
+
|
|
77
88
|
```ts
|
|
78
|
-
|
|
89
|
+
const config: { [keyName: string]: IColumnConfig } = {};
|
|
79
90
|
```
|
|
80
|
-
|
|
@@ -260,13 +260,14 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
|
|
|
260
260
|
}, [columnFilterMap]);
|
|
261
261
|
const SchemaTableTh = React.useCallback(({ style, index }) => {
|
|
262
262
|
const propName = columnNames[index];
|
|
263
|
-
|
|
263
|
+
const propConfig = config ? config[propName] : undefined;
|
|
264
|
+
let columnFilterStatus = isColumnFilterable && (propConfig === null || propConfig === void 0 ? void 0 : propConfig.isFilterable) !== false
|
|
264
265
|
? EColumnFilterStatus.AVAILABLE
|
|
265
266
|
: EColumnFilterStatus.UNAVAILABLE;
|
|
266
267
|
if (columnFilterMap[propName] !== undefined) {
|
|
267
268
|
columnFilterStatus = EColumnFilterStatus.ACTIVE;
|
|
268
269
|
}
|
|
269
|
-
return (_jsx(Th, { isAllChecked: isAllRowsChecked, columnFilterStatus: columnFilterStatus, disableColumnFilter: disableColumnFilter, isSortable: !!isSortable, numberOfSelectedRows: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length, onSelectAllIndexesHandler: onSelectAllIndexesHandler, propConfig:
|
|
270
|
+
return (_jsx(Th, { isAllChecked: isAllRowsChecked, columnFilterStatus: columnFilterStatus, disableColumnFilter: disableColumnFilter, isSortable: !!isSortable, numberOfSelectedRows: checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length, onSelectAllIndexesHandler: onSelectAllIndexesHandler, propConfig: propConfig, propName: propName, schema: properties[propName], setPopoverConfig: setPopoverConfig, setSortAsc: setSortAsc, setSortColumn: setSortColumn, sortAsc: sortColumn === propName ? sortAsc : undefined, style: style }));
|
|
270
271
|
}, [
|
|
271
272
|
checkedIndexes === null || checkedIndexes === void 0 ? void 0 : checkedIndexes.length,
|
|
272
273
|
columnFilterMap,
|
package/dist/index.css
CHANGED