react-admin-crud-manager 1.0.7 → 1.0.9

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.
Files changed (2) hide show
  1. package/README.md +198 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -15,16 +15,6 @@ A reusable React CRUD admin template with modular components for rapid admin das
15
15
  npm install react-admin-crud-manager
16
16
  ```
17
17
 
18
- ## Build (for contributors/maintainers)
19
-
20
- To build the package for npm distribution:
21
-
22
- ```sh
23
- npm run build
24
- ```
25
-
26
- This will output the library files to the `dist/` folder in both CommonJS and ESModule formats.
27
-
28
18
  ## Usage
29
19
 
30
20
  ### 1. Import the built CSS for Tailwind styles
@@ -55,7 +45,204 @@ function App() {
55
45
  - `Table`, `Modal`, `Form`, etc.: Available for advanced use
56
46
 
57
47
  ## Props
58
- See the source or future documentation for full prop details.
48
+ Below is a complete reference of the public props accepted by this package (types, accepted values and defaults). The library exposes a single primary component (`Crud`) that receives a single `config` prop — most configuration lives inside that object.
49
+
50
+ ---
51
+
52
+ ### Crud (default export)
53
+ `<Crud config={config} />`
54
+ - `config` (object) — required. Top-level configuration object used by the CRUD page.
55
+
56
+ Key properties of `config` (types & accepted values):
57
+
58
+ - `title` — string (required)
59
+ - `description` — string (optional)
60
+ - `buttonText` — string (optional)
61
+ - `fetchData` — function (required)
62
+ - 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 } }>
63
+ - The component expects `resp.data` (array) and optional `resp.pagination` when server-side pagination is used.
64
+ - `isStaticData` — boolean (default: false)
65
+ - If true, add/edit/delete are applied client-side on local state instead of re-fetching.
66
+ - `tableConfig` — object (required) — see "Table / tableConfig" below.
67
+ - `modalConfig` — object — see "Modal / modalConfig" below.
68
+ - `filterConfig` — object — used by the filter drawer (see Form field schema below).
69
+
70
+ ---
71
+
72
+ ### Table / `tableConfig` (inside `config`)
73
+ Type: object
74
+
75
+ Common keys:
76
+ - `table_head` — array of column objects (required)
77
+ - `data` — array — rows shown in the table
78
+ - `loading` — boolean — show skeleton when true
79
+ - `search` — object: { enabled?: boolean, placeholder?: string, useServerSideSearch?: boolean, searchKeys?: string[] }
80
+ - `filter` — object: { enabled?: boolean, useServerSideFilters?: boolean }
81
+ - `pagination` — object: { enabled?: boolean, rows_per_page?: number, useServerSidePagination?: boolean, current_page?: number, total_pages?: number, total_records?: number }
82
+ - `emptyMessage` — string — message when no rows
83
+ - `onMenuAction` — function(actionType: string, item: object)
84
+ - `setServerSidePaginationData` — function — used to update server-side pagination/search state
85
+ - `onFilterApply` — function(filters: object)
86
+ - `filterConfig` — object (fields array) — rendered in the FilterDrawer
87
+
88
+ Table column object (`table_head[]`) — accepted keys:
89
+ - `key` — string (required) — property name in row objects
90
+ - `title` — string — column header
91
+ - `type` — string — accepted values: (plain default) | `index` | `group` | `chip` | `date` | `avatar` | `menu_actions`
92
+ - `imageKey`, `titleKey`, `subtitleKey` — string — used by `group`/`avatar` types
93
+ - `onClickDetails` — boolean — if true clicking the cell triggers a view action
94
+ - `variant` — string — used for chips (`contained` | `outline` | `soft`)
95
+ - `chipOptions` — array of { value: string|number|boolean, label: string, color?: string }
96
+ - `defaultColor` — string — default chip color key (e.g., `green`)
97
+ - `className` — string — custom class for cell
98
+ - `format` — string — date format (e.g. `DD MMM YYYY`)
99
+ - `menuList` — array of menu action objects: { title: string, type: string, variant?: string, icon?: ReactNode }
100
+ - `render` — function(row, rowIndex) — custom renderer; if present it overrides built-in renderers
101
+
102
+ ---
103
+
104
+ ### Modal / `modalConfig`
105
+ `modalConfig` groups modal definitions used by the CRUD page.
106
+
107
+ Common modal shapes:
108
+ - `addModal`, `editModal` (object)
109
+ - `title` — string (required)
110
+ - `size` — string (`sm` | `md` | `lg` | `xl` | `full`) (default `md`)
111
+ - `formClass` — string (optional)
112
+ - `formFields` — array of form-field objects (see Form schema)
113
+ - `handleSubmit` — function(formData) — required; should perform API call and return an object used by the parent (see notes)
114
+ - `actionButtons` — array of actionButton objects ({ type, label, color, variant, onClick, disabled, className })
115
+
116
+ - `deleteModal` (object)
117
+ - `title` — string
118
+ - `size` — string
119
+ - `confirmText` — string
120
+ - `referenceKey` — string — key of selectedItem to show as reference in delete dialog
121
+ - `action` — function(selectedItem) — function called to perform delete (should return a response used by the parent)
122
+ - `actionButtons` — array of actionButton objects
123
+
124
+ - `viewModal` (object)
125
+ - `title` — string (required)
126
+ - `size` — string
127
+ - `component` — React component (elementType) — optional, receives `data` prop when provided
128
+ - `fields` — array of view-field objects (see View fields below)
129
+ - `footer` — { cancelButton?: boolean, cancelText?: string }
130
+
131
+ Notes on modal handlers (expected response shapes):
132
+ - `addModal.handleSubmit` should return an object containing `newObject` (the created row) so Crud can insert it into the list when `isStaticData` is true or refresh server-side listing.
133
+ - `editModal.handleSubmit` should return `{ newObject, targetObject }` where `targetObject` identifies which row was updated.
134
+ - `deleteModal.action` should return an object containing `targetObject` (the deleted row) or an appropriate success response.
135
+
136
+ ---
137
+
138
+ ### Form / Form fields (used by `modalConfig.*.formFields` and `filterConfig.fields`)
139
+ Form fields follow the `formFieldType` shape used throughout the UI. Each field is an object with these keys:
140
+
141
+ Common field keys (all field types):
142
+ - `key` — string (required) — the property name for form data
143
+ - `label` — string — human-readable label
144
+ - `type` — string (required) — accepted values:
145
+ - `text` (default input), `number`, `email`, `password`, `select`, `checkbox`, `switch`, `phone`, `textarea`, `image`, `tinyEditor`
146
+ - `required` — boolean
147
+ - `minLength` — number
148
+ - `parentClass` — string — grid class (e.g. `col-span-6`)
149
+ - `placeholder` — string
150
+ - `disabled` — boolean
151
+
152
+ Type-specific keys:
153
+ - select
154
+ - `options` — array of { value: string|number|boolean, label: string }
155
+ - `multiple` — boolean — allow multiple selection
156
+ - `search` — boolean — show search inside dropdown
157
+ - `dropdownMaxHeight` — string (CSS height value)
158
+ - checkbox
159
+ - `options` — array of { value, label }
160
+ - `multiple` — boolean — when true allows selecting multiple values (component prop `multiSelect`)
161
+ - switch
162
+ - `options` — optional array of radio-like options [{ label, value }]
163
+ - `text` — optional description text shown next to the switch
164
+ - phone
165
+ - `countriesList` — boolean — show country selector
166
+ - `defaultCountry` — string (ISO country code like `US`)
167
+ - `search` — boolean — enable searching countries
168
+ - `placeholder` — string
169
+ - textarea
170
+ - `rows` — number
171
+ - image
172
+ - `accept` — string (default: `image/*`)
173
+ - `dragDrop` — boolean
174
+ - tinyEditor
175
+ - `editorKey` — string (TinyMCE api key)
176
+ - `fontFamily` — string
177
+ - `height` — number
178
+ - `imageUploadHandler` — function(blobInfo) => Promise<string> (returns URL)
179
+
180
+ Return values / onSubmit handlers
181
+ - `onSubmit(formData)` receives an object keyed by `field.key` values.
182
+
183
+ ---
184
+
185
+ ### Small/UI components (props summary)
186
+ - `Button` props
187
+ - `variant` — `contained` | `outlined` | `text` (default `contained`)
188
+ - `color` — `primary` | `success` | `error` | `default`
189
+ - `size` — `sm` | `md` | `lg` | `xl` | `default`
190
+ - `fullWidth` — boolean
191
+ - `className`, `onClick`, `type`, `disabled` (standard button props)
192
+
193
+ - `Chip` props
194
+ - `label` — string (required)
195
+ - `variant` — `contained` | `outline` | `soft` (default `contained`)
196
+ - `color` — `blue` | `teal` | `purple` | `yellow` | `green` | `red` | `gray`
197
+
198
+ - `Modal` props (when used directly)
199
+ - `isOpen` — boolean
200
+ - `onClose` — function
201
+ - `icon` — React node
202
+ - `title` — string
203
+ - `size` — `sm` | `md` | `lg` | `xl` | `full`
204
+ - `actionButtons` — array of { type, label, color, variant, onClick, disabled }
205
+ - `loadingBtn` — boolean
206
+
207
+ - `FilterDrawer` props
208
+ - `isOpen` — boolean
209
+ - `onClose` — function
210
+ - `config` — object (fields array — same `formFieldType`)
211
+ - `onApply` — function(filters: object)
212
+
213
+ ---
214
+
215
+ ### Examples
216
+ Minimal CRUD config (client-side):
217
+
218
+ ```js
219
+ const config = {
220
+ title: 'Users',
221
+ fetchData: async () => ({ data: users, pagination: null }),
222
+ isStaticData: true,
223
+ tableConfig: {
224
+ table_head: [ { key: 'id', title: 'ID', type: 'index' }, { key: 'name', title: 'Name' } ],
225
+ pagination: { enabled: true }
226
+ },
227
+ modalConfig: {
228
+ addModal: { title: 'Add user', handleSubmit: async (formData)=>({ newObject: formData }), formFields: [ { key: 'name', label: 'Name', type: 'text', required: true } ] }
229
+ }
230
+ };
231
+ ```
232
+
233
+ Server-side listing (fetchData must return { data, pagination }):
234
+
235
+ ```js
236
+ const fetchData = async ({ search, rows_per_page, current_page }) => {
237
+ const resp = await api.get('/users', { params: { q: search, limit: rows_per_page, page: current_page } });
238
+ return { data: resp.items, pagination: { current_page: resp.page, rows_per_page: resp.limit, total_pages: resp.totalPages, total_records: resp.total } };
239
+ };
240
+ ```
241
+
242
+ ---
243
+
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
+
59
246
 
60
247
  ## License
61
248
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-admin-crud-manager",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "A reusable React CRUD admin template with modular components.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",