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 CHANGED
@@ -1,2 +1,130 @@
1
- # antd-crud-table
2
- Easy CRUD table with AntD (Ant Design)
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/