antd-crud-table 0.0.10 โ 0.0.12
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 +130 -2
- package/dist/CrudTable-W5dD5mDc.js +74793 -0
- package/dist/CrudTable-ck226KHr.cjs +407 -0
- package/dist/CrudTable.cjs +1 -551
- package/dist/CrudTable.js +132 -81086
- package/dist/CrudTableExperimental.cjs +1 -0
- package/dist/CrudTableExperimental.d.ts +34 -0
- package/dist/CrudTableExperimental.js +373 -0
- package/dist/hooks/useCrudTable.d.ts +61 -0
- package/dist/index-DNXRWKhU.js +6314 -0
- package/dist/index-DygfPlBI.cjs +145 -0
- package/dist/useCrudTable.cjs +1 -0
- package/dist/useCrudTable.js +195 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,2 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# ๐งฉ `antd-crud-table` โ A Dynamic React Table Generator with Forms ๐
|
|
4
|
+
|
|
5
|
+
`CrudTable` is a highly flexible and powerful React component built using `antd` and `@ant-design/pro-components`. It provides a declarative way to render editable, paginated tables with form support, data fetching, sorting, filtering, and custom rendering. Perfect for building admin dashboards and data management UIs with minimal boilerplate.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ๐ฆ Installation
|
|
10
|
+
|
|
11
|
+
Install dependencies with:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install antd-crud-table
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## โ๏ธ Usage Example
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import CrudTable, { CrudTableConfig } from 'antd-crud-table';
|
|
23
|
+
|
|
24
|
+
const userService = {
|
|
25
|
+
getList: async () => ({ data: [], total: 0 }),
|
|
26
|
+
create: async (data) => data,
|
|
27
|
+
update: async (id, data) => data,
|
|
28
|
+
delete: async (id) => {},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const config: CrudTableConfig<any> = {
|
|
32
|
+
title: 'User Management',
|
|
33
|
+
rowKey: 'id',
|
|
34
|
+
service: userService,
|
|
35
|
+
columns: [
|
|
36
|
+
{
|
|
37
|
+
title: 'Name',
|
|
38
|
+
dataIndex: 'name',
|
|
39
|
+
fieldType: 'string',
|
|
40
|
+
fieldEditable: true,
|
|
41
|
+
formConfig: { required: true },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'Status',
|
|
45
|
+
dataIndex: 'status',
|
|
46
|
+
fieldType: 'enum',
|
|
47
|
+
enumOptions: {
|
|
48
|
+
active: { text: 'Active' },
|
|
49
|
+
inactive: { text: 'Inactive' },
|
|
50
|
+
},
|
|
51
|
+
formConfig: { required: true },
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default function Admin() {
|
|
57
|
+
return <CrudTable {...config} />;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## ๐ Features
|
|
64
|
+
|
|
65
|
+
- ๐จ **Customizable Column Types** (`string`, `number`, `boolean`, `date`, `enum`, `custom`)
|
|
66
|
+
- โ
**Integrated Create/Edit Modal Form**
|
|
67
|
+
- ๐ **ProTable-based Sorting, Pagination & Filtering**
|
|
68
|
+
- ๐ **Refetching and Action Toolbar**
|
|
69
|
+
- ๐ง **Custom Transform & Render Logic per Field**
|
|
70
|
+
- ๐ **Built-in Date/Time Formatting with `date-fns` + `dayjs`**
|
|
71
|
+
- ๐งฐ **Typesafe Configuration with TypeScript Support**
|
|
72
|
+
- ๐ **Editable Field Controls (per column)**
|
|
73
|
+
- ๐งผ **Clean, Formatted Layout with Row Differentiation Support**
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## ๐ ๏ธ Props
|
|
78
|
+
|
|
79
|
+
### `CrudTableConfig<T>`
|
|
80
|
+
| Prop | Type | Description |
|
|
81
|
+
|------|------|-------------|
|
|
82
|
+
| `columns` | `CrudColumn<T>[]` | Column definitions including types and rendering logic |
|
|
83
|
+
| `service` | `{ getList, create, update, delete }` | API service methods for data fetching and CRUD |
|
|
84
|
+
| `rowKey` | `keyof T` | Unique key for each row |
|
|
85
|
+
| `title` | `string` | Table header title |
|
|
86
|
+
| `defaultPageSize?` | `number` | Optional default page size (default is 5) |
|
|
87
|
+
|
|
88
|
+
### `CrudColumn<T>`
|
|
89
|
+
Extends `ProColumns<T>` with:
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Description |
|
|
92
|
+
|------|------|-------------|
|
|
93
|
+
| `fieldType` | `"string" \| "number" \| "boolean" \| "date" \| "enum" \| "custom"` | Field type |
|
|
94
|
+
| `enumOptions?` | `Record<string, { text: string }>` | Options for enum dropdown |
|
|
95
|
+
| `formConfig?` | `{ required?: boolean, component?: ReactNode, transform?: fn }` | Form field behavior |
|
|
96
|
+
| `fieldEditable?` | `boolean` | Whether the field is editable in form |
|
|
97
|
+
| `customRender?` | `(value, record) => ReactNode` | Custom render function for custom fields |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## ๐ Styling
|
|
102
|
+
|
|
103
|
+
Customize row striping using `.row-differentiator` in `CrudTable.css`:
|
|
104
|
+
|
|
105
|
+
```css
|
|
106
|
+
.row-differentiator {
|
|
107
|
+
background-color: #fafafa;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## ๐ Notes
|
|
114
|
+
|
|
115
|
+
- Date fields are handled via `dayjs` in the form and `date-fns` for display.
|
|
116
|
+
- All requests are async with error handling via `antd`'s `message` API.
|
|
117
|
+
- Add your own export logic or additional toolbar buttons as needed.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
๐ Build elegant CRUD interfaces faster than ever with `antd-crud-table`!
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## References
|
|
127
|
+
|
|
128
|
+
- NPM: https://www.npmjs.com/package/antd-crud-table/
|
|
129
|
+
- GitHub: https://github.com/maifeeulasad/antd-crud-table/
|
|
130
|
+
- GitHub page (Live Demo): https://maifeeulasad.github.io/antd-crud-table/
|