react-admin-crud-manager 1.0.10 → 1.0.11
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 +206 -146
- package/dist/index.cjs.js +25 -46
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1003 -1284
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tailwind.css +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,162 +53,225 @@ Below is a complete reference of the public props accepted by this package (type
|
|
|
53
53
|
`<Crud config={config} />`
|
|
54
54
|
- `config` (object) — required. Top-level configuration object used by the CRUD page.
|
|
55
55
|
|
|
56
|
-
Key properties of `config`
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- `filterConfig` — object — used by the filter drawer (see Form field schema below).
|
|
56
|
+
#### Key properties of `config`
|
|
57
|
+
|
|
58
|
+
| Property | Type | Required | Description |
|
|
59
|
+
|----------|------|----------|-------------|
|
|
60
|
+
| `title` | string | Yes | Title of the CRUD page |
|
|
61
|
+
| `description` | string | No | Optional description text |
|
|
62
|
+
| `buttonText` | string | No | Custom text for action buttons |
|
|
63
|
+
| `fetchData` | function | Yes | Async function to fetch data. Signature: `async ({ search, rows_per_page, current_page, ...filters }) => Promise<{ data: Array, pagination?: { current_page: number, rows_per_page: number, total_pages: number, total_records: number } }>`. Component expects `resp.data` (array) and optional `resp.pagination` for server-side pagination. |
|
|
64
|
+
| `isStaticData` | boolean | No | Default: `false`. If true, add/edit/delete apply client-side instead of re-fetching |
|
|
65
|
+
| `tableConfig` | object | Yes | Table configuration — [see tableConfig](#tableconfig-configuration) |
|
|
66
|
+
| `modalConfig` | object | No | Modal definitions — [see modalConfig](#modalconfig-definitions) |
|
|
67
|
+
| `filterConfig` | object | No | Filter drawer configuration — [see Form Field Schema](#form-field-schema) |
|
|
69
68
|
|
|
70
69
|
---
|
|
71
70
|
|
|
72
|
-
###
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
71
|
+
### tableConfig Configuration
|
|
72
|
+
|
|
73
|
+
#### Table Configuration Keys
|
|
74
|
+
|
|
75
|
+
| Key | Type | Required | Description |
|
|
76
|
+
|-----|------|----------|-------------|
|
|
77
|
+
| `table_head` | array of column objects | Yes | Column definitions — [see Table column object](#table-column-object-table_head) |
|
|
78
|
+
| `data` | array | No | Rows shown in the table |
|
|
79
|
+
| `loading` | boolean | No | Show skeleton loader when true |
|
|
80
|
+
| `search` | object | No | `{ enabled?: boolean, placeholder?: string, useServerSideSearch?: boolean, searchKeys?: string[] }` |
|
|
81
|
+
| `filter` | object | No | `{ enabled?: boolean, useServerSideFilters?: boolean }` |
|
|
82
|
+
| `pagination` | object | No | `{ enabled?: boolean, rows_per_page?: number, useServerSidePagination?: boolean, current_page?: number, total_pages?: number, total_records?: number }` |
|
|
83
|
+
| `emptyMessage` | string | No | Message shown when table has no rows |
|
|
84
|
+
| `onMenuAction` | function | No | Callback: `(actionType: string, item: object)` |
|
|
85
|
+
| `setServerSidePaginationData` | function | No | Used to update server-side pagination/search state |
|
|
86
|
+
| `onFilterApply` | function | No | Callback: `(filters: object)` |
|
|
87
|
+
| `filterConfig` | object | No | Fields array rendered in the FilterDrawer |
|
|
88
|
+
|
|
89
|
+
#### Table Column Object (`table_head[]`)
|
|
90
|
+
|
|
91
|
+
| Key | Type | Required | Description |
|
|
92
|
+
|-----|------|----------|-------------|
|
|
93
|
+
| `key` | string | Yes | Property name in row objects |
|
|
94
|
+
| `title` | string | No | Column header text |
|
|
95
|
+
| `type` | string | No | Column type: `plain` (default), `index`, `group`, `chip`, `date`, `avatar`, `menu_actions` |
|
|
96
|
+
| `imageKey` | string | No | Used with `group`/`avatar` types |
|
|
97
|
+
| `titleKey` | string | No | Used with `group`/`avatar` types |
|
|
98
|
+
| `subtitleKey` | string | No | Used with `group`/`avatar` types |
|
|
99
|
+
| `onClickDetails` | boolean | No | If true, clicking cell triggers view action |
|
|
100
|
+
| `variant` | string | No | For chips: `contained`, `outline`, `soft` |
|
|
101
|
+
| `chipOptions` | array | No | Array of `{ value: string|number|boolean, label: string, color?: string }` |
|
|
102
|
+
| `defaultColor` | string | No | Default chip color key (e.g., `green`) |
|
|
103
|
+
| `className` | string | No | Custom CSS class for cell |
|
|
104
|
+
| `format` | string | No | Date format (e.g., `DD MMM YYYY`) |
|
|
105
|
+
| `menuList` | array | No | Menu action objects: `{ title, type, variant?, icon? }` |
|
|
106
|
+
| `render` | function | No | Custom renderer: `(row, rowIndex) => ReactNode`. Overrides built-in renderers |
|
|
101
107
|
|
|
102
108
|
---
|
|
103
109
|
|
|
104
|
-
###
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
110
|
+
### modalConfig Definitions
|
|
111
|
+
|
|
112
|
+
#### Add & Edit Modal (`addModal`, `editModal`)
|
|
113
|
+
|
|
114
|
+
| Property | Type | Required | Description |
|
|
115
|
+
|----------|------|----------|-------------|
|
|
116
|
+
| `title` | string | Yes | Modal title |
|
|
117
|
+
| `size` | string | No | Modal size: `sm`, `md` (default), `lg`, `xl`, `full` |
|
|
118
|
+
| `formClass` | string | No | Custom CSS class for form |
|
|
119
|
+
| `formFields` | array | Yes | Form field objects — [see Form Field Schema](#form-field-schema) |
|
|
120
|
+
| `handleSubmit` | function | Yes | Async callback: `(formData) => Promise<{ newObject, targetObject? }>`. For add: return `{ newObject }`. For edit: return `{ newObject, targetObject }` |
|
|
121
|
+
| `actionButtons` | array | No | Action button objects: `[{ type, label, color, variant, onClick, disabled, className }]` |
|
|
122
|
+
|
|
123
|
+
#### Delete Modal (`deleteModal`)
|
|
124
|
+
|
|
125
|
+
| Property | Type | Required | Description |
|
|
126
|
+
|----------|------|----------|-------------|
|
|
127
|
+
| `title` | string | No | Modal title |
|
|
128
|
+
| `size` | string | No | Modal size: `sm`, `md` (default), `lg`, `xl`, `full` |
|
|
129
|
+
| `confirmText` | string | No | Confirmation message text |
|
|
130
|
+
| `referenceKey` | string | No | Property key of selectedItem to display as reference |
|
|
131
|
+
| `action` | function | Yes | Async callback: `(selectedItem) => Promise<{ targetObject }>`. Should return the deleted row |
|
|
132
|
+
| `actionButtons` | array | No | Action button objects: `[{ type, label, color, variant, onClick, disabled, className }]` |
|
|
133
|
+
|
|
134
|
+
#### View Modal (`viewModal`)
|
|
135
|
+
|
|
136
|
+
| Property | Type | Required | Description |
|
|
137
|
+
|----------|------|----------|-------------|
|
|
138
|
+
| `title` | string | Yes | Modal title |
|
|
139
|
+
| `size` | string | No | Modal size: `sm`, `md` (default), `lg`, `xl`, `full` |
|
|
140
|
+
| `component` | React component | No | Custom component to render. Receives `data` prop with row data |
|
|
141
|
+
| `fields` | array | No | View field objects for displaying data |
|
|
142
|
+
| `footer` | object | No | `{ cancelButton?: boolean, cancelText?: string }` |
|
|
135
143
|
|
|
136
144
|
---
|
|
137
145
|
|
|
138
|
-
### Form
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
146
|
+
### Form Field Schema
|
|
147
|
+
|
|
148
|
+
Used by `modalConfig.*.formFields` and `filterConfig.fields`. Form fields follow the `formFieldType` shape used throughout the UI.
|
|
149
|
+
|
|
150
|
+
#### Common Field Keys (All Types)
|
|
151
|
+
|
|
152
|
+
| Key | Type | Required | Description |
|
|
153
|
+
|-----|------|----------|-------------|
|
|
154
|
+
| `key` | string | Yes | Property name for form data |
|
|
155
|
+
| `label` | string | No | Human-readable label |
|
|
156
|
+
| `type` | string | Yes | Field type: `text`, `number`, `email`, `password`, `select`, `checkbox`, `switch`, `phone`, `textarea`, `image`, `tinyEditor` |
|
|
157
|
+
| `required` | boolean | No | Field is required for form submission |
|
|
158
|
+
| `minLength` | number | No | Minimum character length |
|
|
159
|
+
| `parentClass` | string | No | Tailwind grid class (e.g., `col-span-6`) |
|
|
160
|
+
| `placeholder` | string | No | Placeholder text |
|
|
161
|
+
| `disabled` | boolean | No | Field is disabled |
|
|
162
|
+
|
|
163
|
+
#### Type-Specific Keys
|
|
164
|
+
|
|
165
|
+
##### Select Field
|
|
166
|
+
|
|
167
|
+
| Key | Type | Description |
|
|
168
|
+
|-----|------|-------------|
|
|
169
|
+
| `options` | array | `{ value: string|number|boolean, label: string }[]` |
|
|
170
|
+
| `multiple` | boolean | Allow multiple selections |
|
|
171
|
+
| `search` | boolean | Show search input inside dropdown |
|
|
172
|
+
| `dropdownMaxHeight` | string | CSS height value (e.g., `300px`) |
|
|
173
|
+
|
|
174
|
+
##### Checkbox Field
|
|
175
|
+
|
|
176
|
+
| Key | Type | Description |
|
|
177
|
+
|-----|------|-------------|
|
|
178
|
+
| `options` | array | `{ value, label }[]` |
|
|
179
|
+
| `multiple` | boolean | Allow selecting multiple values (component prop: `multiSelect`) |
|
|
180
|
+
|
|
181
|
+
##### Switch Field
|
|
182
|
+
|
|
183
|
+
| Key | Type | Description |
|
|
184
|
+
|-----|------|-------------|
|
|
185
|
+
| `options` | array | Optional radio-like options: `[{ label, value }]` |
|
|
186
|
+
| `text` | string | Description text shown next to switch |
|
|
187
|
+
|
|
188
|
+
##### Phone Field
|
|
189
|
+
|
|
190
|
+
| Key | Type | Description |
|
|
191
|
+
|-----|------|-------------|
|
|
192
|
+
| `countriesList` | boolean | Show country selector |
|
|
193
|
+
| `defaultCountry` | string | ISO country code (e.g., `US`) |
|
|
194
|
+
| `search` | boolean | Enable searching countries |
|
|
195
|
+
| `placeholder` | string | Placeholder text |
|
|
196
|
+
|
|
197
|
+
##### Textarea Field
|
|
198
|
+
|
|
199
|
+
| Key | Type | Description |
|
|
200
|
+
|-----|------|-------------|
|
|
201
|
+
| `rows` | number | Number of visible rows |
|
|
202
|
+
|
|
203
|
+
##### Image Field
|
|
204
|
+
|
|
205
|
+
| Key | Type | Description |
|
|
206
|
+
|-----|------|-------------|
|
|
207
|
+
| `accept` | string | MIME type filter (default: `image/*`) |
|
|
208
|
+
| `dragDrop` | boolean | Enable drag-and-drop upload |
|
|
209
|
+
|
|
210
|
+
##### TinyEditor Field
|
|
211
|
+
|
|
212
|
+
| Key | Type | Description |
|
|
213
|
+
|-----|------|-------------|
|
|
214
|
+
| `editorKey` | string | TinyMCE API key |
|
|
215
|
+
| `fontFamily` | string | Default font family |
|
|
216
|
+
| `height` | number | Editor height in pixels |
|
|
217
|
+
| `imageUploadHandler` | function | `(blobInfo) => Promise<string>`. Returns image URL |
|
|
218
|
+
|
|
219
|
+
#### Return Values / onSubmit Handler
|
|
220
|
+
|
|
221
|
+
`onSubmit(formData)` receives an object keyed by `field.key` values.
|
|
182
222
|
|
|
183
223
|
---
|
|
184
224
|
|
|
185
225
|
### Small/UI components (props summary)
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
226
|
+
|
|
227
|
+
| Component | Key Props | Purpose |
|
|
228
|
+
|-----------|-----------|----------|
|
|
229
|
+
| **Button** | `variant`, `color`, `size`, `fullWidth`, `className`, `onClick`, `type`, `disabled` | Reusable button with multiple style variants (`contained`, `outlined`, `text`) and colors |
|
|
230
|
+
| **Chip** | `label`, `variant`, `color` | Display small labeled badges with `contained`, `outline`, or `soft` styles |
|
|
231
|
+
| **Modal** | `isOpen`, `onClose`, `icon`, `title`, `size`, `actionButtons`, `loadingBtn` | Modal dialog for forms, confirmations, and views with flexible sizing |
|
|
232
|
+
| **FilterDrawer** | `isOpen`, `onClose`, `config`, `onApply` | Side panel for applying filters with customizable form fields |
|
|
233
|
+
|
|
234
|
+
#### Button Props
|
|
235
|
+
|
|
236
|
+
| Prop | Type | Default | Description |
|
|
237
|
+
|------|------|---------|-------------|
|
|
238
|
+
| `variant` | string | `contained` | Style variant: `contained`, `outlined`, `text` |
|
|
239
|
+
| `color` | string | `primary` | Color: `primary`, `success`, `error`, `default` |
|
|
240
|
+
| `size` | string | `default` | Size: `sm`, `md`, `lg`, `xl`, `default` |
|
|
241
|
+
| `fullWidth` | boolean | `false` | Stretch button to full width |
|
|
242
|
+
| `className` | string | — | Custom CSS class |
|
|
243
|
+
| `onClick` | function | — | Click event handler |
|
|
244
|
+
| `type` | string | `button` | HTML button type: `button`, `submit`, `reset` |
|
|
245
|
+
| `disabled` | boolean | `false` | Disable button interaction |
|
|
246
|
+
|
|
247
|
+
#### Chip Props
|
|
248
|
+
|
|
249
|
+
| Prop | Type | Default | Description |
|
|
250
|
+
|------|------|---------|-------------|
|
|
251
|
+
| `label` | string | Required | Badge text |
|
|
252
|
+
| `variant` | string | `contained` | Style variant: `contained`, `outline`, `soft` |
|
|
253
|
+
| `color` | string | `blue` | Color: `blue`, `teal`, `purple`, `yellow`, `green`, `red`, `gray` |
|
|
254
|
+
|
|
255
|
+
#### Modal Props (Direct Usage)
|
|
256
|
+
|
|
257
|
+
| Prop | Type | Description |
|
|
258
|
+
|------|------|-------------|
|
|
259
|
+
| `isOpen` | boolean | Show/hide modal |
|
|
260
|
+
| `onClose` | function | Callback when modal closes |
|
|
261
|
+
| `icon` | React node | Icon element displayed in modal header |
|
|
262
|
+
| `title` | string | Modal title |
|
|
263
|
+
| `size` | string | Size: `sm`, `md`, `lg`, `xl`, `full` |
|
|
264
|
+
| `actionButtons` | array | `[{ type, label, color, variant, onClick, disabled }]` |
|
|
265
|
+
| `loadingBtn` | boolean | Show loading state on action button |
|
|
266
|
+
|
|
267
|
+
#### FilterDrawer Props
|
|
268
|
+
|
|
269
|
+
| Prop | Type | Description |
|
|
270
|
+
|------|------|-------------|
|
|
271
|
+
| `isOpen` | boolean | Show/hide filter drawer |
|
|
272
|
+
| `onClose` | function | Callback when drawer closes |
|
|
273
|
+
| `config` | object | Fields array using `formFieldType` schema |
|
|
274
|
+
| `onApply` | function | Callback: `(filters: object) => void` |
|
|
212
275
|
|
|
213
276
|
---
|
|
214
277
|
|
|
@@ -241,8 +304,5 @@ const fetchData = async ({ search, rows_per_page, current_page }) => {
|
|
|
241
304
|
|
|
242
305
|
---
|
|
243
306
|
|
|
244
|
-
If you want me to add a TypeScript declaration snippet or a props table per component (or to document `table_head` examples), tell me which parts to expand and I will add them. ✅
|
|
245
|
-
|
|
246
|
-
|
|
247
307
|
## License
|
|
248
308
|
MIT
|