ding-react-admin 1.0.4 → 2.0.4

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 (230) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +254 -201
  3. package/dist/index.css +2 -0
  4. package/dist/index.js +2073 -1202
  5. package/dist/src/components/NavMenuLabel.d.ts +8 -0
  6. package/dist/src/components/NavMenuLabel.d.ts.map +1 -0
  7. package/dist/src/components/NavMenuSearch.d.ts +9 -0
  8. package/dist/src/components/NavMenuSearch.d.ts.map +1 -0
  9. package/dist/src/components/ScrollableArea.d.ts +10 -0
  10. package/dist/src/components/ScrollableArea.d.ts.map +1 -0
  11. package/dist/src/components/index.d.ts +3 -0
  12. package/dist/src/components/index.d.ts.map +1 -1
  13. package/dist/src/context/AuthProvider.d.ts +2 -0
  14. package/dist/src/context/AuthProvider.d.ts.map +1 -1
  15. package/dist/src/crud/FormGlobalErrorsAlert.d.ts +5 -0
  16. package/dist/src/crud/FormGlobalErrorsAlert.d.ts.map +1 -0
  17. package/dist/src/crud/InlineFormSet.d.ts +2 -17
  18. package/dist/src/crud/InlineFormSet.d.ts.map +1 -1
  19. package/dist/src/crud/ResourceForm.d.ts +2 -10
  20. package/dist/src/crud/ResourceForm.d.ts.map +1 -1
  21. package/dist/src/crud/ResourceFormModal.d.ts +7 -1
  22. package/dist/src/crud/ResourceFormModal.d.ts.map +1 -1
  23. package/dist/src/crud/ResourceList.d.ts.map +1 -1
  24. package/dist/src/crud/ResourceRecordForm.d.ts +27 -0
  25. package/dist/src/crud/ResourceRecordForm.d.ts.map +1 -0
  26. package/dist/src/crud/columns/ImageColumn.d.ts +14 -0
  27. package/dist/src/crud/columns/ImageColumn.d.ts.map +1 -0
  28. package/dist/src/crud/context/InlineFieldsRegistry.d.ts +15 -0
  29. package/dist/src/crud/context/InlineFieldsRegistry.d.ts.map +1 -0
  30. package/dist/src/crud/context/PayloadFieldsContext.d.ts +18 -0
  31. package/dist/src/crud/context/PayloadFieldsContext.d.ts.map +1 -0
  32. package/dist/src/crud/fields/FileField.d.ts +12 -0
  33. package/dist/src/crud/fields/FileField.d.ts.map +1 -0
  34. package/dist/src/crud/fields/ImageField.d.ts +14 -0
  35. package/dist/src/crud/fields/ImageField.d.ts.map +1 -0
  36. package/dist/src/crud/fields/ReferenceField.d.ts +12 -2
  37. package/dist/src/crud/fields/ReferenceField.d.ts.map +1 -1
  38. package/dist/src/crud/fields/ReferenceInputActions.d.ts +16 -0
  39. package/dist/src/crud/fields/ReferenceInputActions.d.ts.map +1 -0
  40. package/dist/src/crud/fields/ReferenceManyField.d.ts +10 -1
  41. package/dist/src/crud/fields/ReferenceManyField.d.ts.map +1 -1
  42. package/dist/src/crud/fields/uploadFieldUtils.d.ts +5 -0
  43. package/dist/src/crud/fields/uploadFieldUtils.d.ts.map +1 -0
  44. package/dist/src/crud/fields/useUploadPreviewUrl.d.ts +4 -0
  45. package/dist/src/crud/fields/useUploadPreviewUrl.d.ts.map +1 -0
  46. package/dist/src/crud/filters/ReferenceFilter.d.ts +1 -1
  47. package/dist/src/crud/filters/ReferenceFilter.d.ts.map +1 -1
  48. package/dist/src/crud/index.d.ts +27 -9
  49. package/dist/src/crud/index.d.ts.map +1 -1
  50. package/dist/src/crud/types.d.ts +21 -7
  51. package/dist/src/crud/types.d.ts.map +1 -1
  52. package/dist/src/crud/utils/buildFormPayload.d.ts +6 -0
  53. package/dist/src/crud/utils/buildFormPayload.d.ts.map +1 -0
  54. package/dist/src/crud/utils/buildInlineRowsPayload.d.ts +6 -0
  55. package/dist/src/crud/utils/buildInlineRowsPayload.d.ts.map +1 -0
  56. package/dist/src/crud/utils/buildResourceFormSubmitBody.d.ts +5 -0
  57. package/dist/src/crud/utils/buildResourceFormSubmitBody.d.ts.map +1 -0
  58. package/dist/src/crud/utils/choiceSelectionUtils.d.ts +10 -0
  59. package/dist/src/crud/utils/choiceSelectionUtils.d.ts.map +1 -0
  60. package/dist/src/crud/utils/choiceSelectionUtils.test.d.ts +2 -0
  61. package/dist/src/crud/utils/choiceSelectionUtils.test.d.ts.map +1 -0
  62. package/dist/src/crud/utils/formErrors.d.ts +18 -7
  63. package/dist/src/crud/utils/formErrors.d.ts.map +1 -1
  64. package/dist/src/crud/utils/formErrors.test.d.ts +2 -0
  65. package/dist/src/crud/utils/formErrors.test.d.ts.map +1 -0
  66. package/dist/src/crud/utils/getFormValue.d.ts +3 -0
  67. package/dist/src/crud/utils/getFormValue.d.ts.map +1 -0
  68. package/dist/src/crud/utils/hasUploadValues.d.ts +3 -0
  69. package/dist/src/crud/utils/hasUploadValues.d.ts.map +1 -0
  70. package/dist/src/crud/utils/nestedFieldPath.d.ts +3 -0
  71. package/dist/src/crud/utils/nestedFieldPath.d.ts.map +1 -0
  72. package/dist/src/crud/utils/prepareFormSubmitBody.d.ts +8 -0
  73. package/dist/src/crud/utils/prepareFormSubmitBody.d.ts.map +1 -0
  74. package/dist/src/crud/utils/referenceSelectNotFoundContent.d.ts +4 -0
  75. package/dist/src/crud/utils/referenceSelectNotFoundContent.d.ts.map +1 -0
  76. package/dist/src/crud/utils/setFormValue.d.ts +3 -0
  77. package/dist/src/crud/utils/setFormValue.d.ts.map +1 -0
  78. package/dist/src/crud/utils/toFormData.d.ts +13 -0
  79. package/dist/src/crud/utils/toFormData.d.ts.map +1 -0
  80. package/dist/src/crud/utils/uploadReferenceUtils.d.ts +5 -0
  81. package/dist/src/crud/utils/uploadReferenceUtils.d.ts.map +1 -0
  82. package/dist/src/crud/utils/useChoices.d.ts +27 -1
  83. package/dist/src/crud/utils/useChoices.d.ts.map +1 -1
  84. package/dist/src/crud/utils/useFormRecord.d.ts +44 -0
  85. package/dist/src/crud/utils/useFormRecord.d.ts.map +1 -0
  86. package/dist/src/data/createRestResourceHandlers.d.ts +5 -5
  87. package/dist/src/data/createRestResourceHandlers.d.ts.map +1 -1
  88. package/dist/src/data/dataProviderTypes.d.ts +6 -5
  89. package/dist/src/data/dataProviderTypes.d.ts.map +1 -1
  90. package/dist/src/data/parseFormErrorHelpers.d.ts +23 -6
  91. package/dist/src/data/parseFormErrorHelpers.d.ts.map +1 -1
  92. package/dist/src/data/resourceHandlers.d.ts +1 -1
  93. package/dist/src/data/resourceHandlers.d.ts.map +1 -1
  94. package/dist/src/index.d.ts +4 -4
  95. package/dist/src/index.d.ts.map +1 -1
  96. package/dist/src/layouts/AdminLayout.d.ts +1 -1
  97. package/dist/src/layouts/AdminLayout.d.ts.map +1 -1
  98. package/dist/src/layouts/AuthPageLayout.d.ts.map +1 -1
  99. package/dist/src/layouts/navFilter.d.ts +5 -0
  100. package/dist/src/layouts/navFilter.d.ts.map +1 -0
  101. package/dist/src/layouts/navMenuItems.d.ts +6 -0
  102. package/dist/src/layouts/navMenuItems.d.ts.map +1 -0
  103. package/dist/src/types.d.ts +12 -0
  104. package/dist/src/types.d.ts.map +1 -1
  105. package/package.json +79 -59
  106. package/src/app/AdminApp.tsx +34 -34
  107. package/src/components/AuthAlternateLink.tsx +23 -23
  108. package/src/components/DensitySwitch.tsx +31 -31
  109. package/src/components/NavMenuLabel.tsx +26 -0
  110. package/src/components/NavMenuSearch.tsx +76 -0
  111. package/src/components/ScrollableArea.tsx +46 -0
  112. package/src/components/ThemeSwitch.tsx +28 -28
  113. package/src/components/ThemeToolbar.tsx +34 -34
  114. package/src/components/index.ts +7 -4
  115. package/src/components/navMenu.css +21 -0
  116. package/src/components/scrollable.css +28 -0
  117. package/src/context/AppThemeProvider.tsx +128 -128
  118. package/src/context/AuthProvider.tsx +89 -77
  119. package/src/context/DataProvider.tsx +30 -30
  120. package/src/context/PermissionsProvider.tsx +57 -57
  121. package/src/crud/FilterBar.tsx +36 -36
  122. package/src/crud/FormGlobalErrorsAlert.tsx +36 -0
  123. package/src/crud/FormSteps.tsx +135 -135
  124. package/src/crud/FormTabs.tsx +126 -126
  125. package/src/crud/InlineFormSet.tsx +162 -219
  126. package/src/crud/ListActionsBar.tsx +106 -106
  127. package/src/crud/ResourceForm.tsx +83 -166
  128. package/src/crud/ResourceFormModal.tsx +75 -133
  129. package/src/crud/ResourceList.tsx +1 -0
  130. package/src/crud/ResourceRecordForm.tsx +166 -0
  131. package/src/crud/columns/BooleanColumn.tsx +32 -32
  132. package/src/crud/columns/CustomColumn.tsx +33 -33
  133. package/src/crud/columns/DateColumn.tsx +28 -28
  134. package/src/crud/columns/ImageColumn.tsx +58 -0
  135. package/src/crud/columns/NumberColumn.tsx +31 -31
  136. package/src/crud/columns/ReferenceColumn.tsx +85 -85
  137. package/src/crud/columns/ReferenceManyColumn.tsx +67 -67
  138. package/src/crud/columns/TextColumn.tsx +38 -38
  139. package/src/crud/context/FilterContext.tsx +71 -71
  140. package/src/crud/context/FormContext.tsx +39 -39
  141. package/src/crud/context/FormSectionContext.tsx +22 -22
  142. package/src/crud/context/InlineFieldsRegistry.tsx +61 -0
  143. package/src/crud/context/ListContext.tsx +93 -93
  144. package/src/crud/context/PayloadFieldsContext.tsx +62 -0
  145. package/src/crud/fields/BooleanField.tsx +38 -38
  146. package/src/crud/fields/DateField.tsx +53 -53
  147. package/src/crud/fields/FieldWrapper.tsx +87 -87
  148. package/src/crud/fields/FileField.tsx +123 -0
  149. package/src/crud/fields/ImageField.tsx +120 -0
  150. package/src/crud/fields/NumberField.tsx +52 -52
  151. package/src/crud/fields/PasswordField.tsx +99 -99
  152. package/src/crud/fields/ReferenceField.tsx +237 -96
  153. package/src/crud/fields/ReferenceInputActions.tsx +106 -0
  154. package/src/crud/fields/ReferenceManyField.tsx +200 -76
  155. package/src/crud/fields/SelectField.tsx +48 -48
  156. package/src/crud/fields/TextField.tsx +46 -46
  157. package/src/crud/fields/uploadFieldUtils.ts +21 -0
  158. package/src/crud/fields/useUploadPreviewUrl.ts +20 -0
  159. package/src/crud/filters/BooleanFilter.tsx +38 -38
  160. package/src/crud/filters/DateFilter.tsx +35 -35
  161. package/src/crud/filters/NumberFilter.tsx +33 -33
  162. package/src/crud/filters/ReferenceFilter.tsx +192 -173
  163. package/src/crud/filters/SelectFilter.tsx +44 -44
  164. package/src/crud/filters/TextFilter.tsx +36 -36
  165. package/src/crud/index.ts +99 -90
  166. package/src/crud/types.ts +146 -132
  167. package/src/crud/utils/buildFormPayload.ts +24 -0
  168. package/src/crud/utils/buildInlineRowsPayload.ts +37 -0
  169. package/src/crud/utils/buildResourceFormSubmitBody.ts +29 -0
  170. package/src/crud/utils/choiceSelectionUtils.test.ts +45 -0
  171. package/src/crud/utils/choiceSelectionUtils.ts +116 -0
  172. package/src/crud/utils/formErrors.test.ts +168 -0
  173. package/src/crud/utils/formErrors.ts +138 -38
  174. package/src/crud/utils/formSectionErrors.ts +85 -85
  175. package/src/crud/utils/{getByPath.ts → getFormValue.ts} +13 -13
  176. package/src/crud/utils/hasUploadValues.ts +9 -0
  177. package/src/crud/utils/nestedFieldPath.ts +8 -0
  178. package/src/crud/utils/prepareFormSubmitBody.ts +22 -0
  179. package/src/crud/utils/referenceSelectNotFoundContent.tsx +7 -0
  180. package/src/crud/utils/{setByPath.ts → setFormValue.ts} +18 -18
  181. package/src/crud/utils/sortQueryParam.ts +37 -37
  182. package/src/crud/utils/toFormData.ts +79 -0
  183. package/src/crud/utils/uploadReferenceUtils.ts +44 -0
  184. package/src/crud/utils/useAbortableEffect.ts +17 -17
  185. package/src/crud/utils/useChoices.ts +330 -182
  186. package/src/crud/utils/useFormRecord.ts +179 -0
  187. package/src/crud/utils/useListQueryState.ts +191 -191
  188. package/src/data/abortError.test.ts +19 -19
  189. package/src/data/abortError.ts +10 -10
  190. package/src/data/createMemoryResourceHandlers.ts +78 -78
  191. package/src/data/createRestResourceHandlers.ts +63 -57
  192. package/src/data/dataProviderTypes.ts +7 -5
  193. package/src/data/dataUtils.test.ts +228 -108
  194. package/src/data/inMemoryList.ts +97 -97
  195. package/src/data/parseFormErrorHelpers.test.ts +201 -84
  196. package/src/data/parseFormErrorHelpers.ts +376 -224
  197. package/src/data/resourceHandlers.ts +1 -1
  198. package/src/data/sortHelpers.ts +48 -48
  199. package/src/index.ts +211 -195
  200. package/src/layouts/AdminLayout.tsx +530 -381
  201. package/src/layouts/AuthPageLayout.tsx +87 -81
  202. package/src/layouts/navFilter.ts +49 -0
  203. package/src/layouts/navMenuItems.tsx +44 -0
  204. package/src/pages/LoginPage.tsx +80 -80
  205. package/src/pages/PlaceholderPage.tsx +9 -9
  206. package/src/permissions/resourcePermissions.ts +47 -47
  207. package/src/router/createAdminRouter.tsx +64 -64
  208. package/src/router/guards.tsx +63 -63
  209. package/src/router/routeAccess.ts +89 -89
  210. package/src/types.ts +10 -0
  211. package/src/vite-env.d.ts +1 -1
  212. package/dist/src/crud/context/SubmitFieldsContext.d.ts +0 -18
  213. package/dist/src/crud/context/SubmitFieldsContext.d.ts.map +0 -1
  214. package/dist/src/crud/utils/getByPath.d.ts +0 -3
  215. package/dist/src/crud/utils/getByPath.d.ts.map +0 -1
  216. package/dist/src/crud/utils/inlineArrayName.d.ts +0 -3
  217. package/dist/src/crud/utils/inlineArrayName.d.ts.map +0 -1
  218. package/dist/src/crud/utils/inlineFieldName.d.ts +0 -3
  219. package/dist/src/crud/utils/inlineFieldName.d.ts.map +0 -1
  220. package/dist/src/crud/utils/pickBySources.d.ts +0 -6
  221. package/dist/src/crud/utils/pickBySources.d.ts.map +0 -1
  222. package/dist/src/crud/utils/setByPath.d.ts +0 -3
  223. package/dist/src/crud/utils/setByPath.d.ts.map +0 -1
  224. package/dist/src/crud/utils/useResourceFormData.d.ts +0 -47
  225. package/dist/src/crud/utils/useResourceFormData.d.ts.map +0 -1
  226. package/src/crud/context/SubmitFieldsContext.tsx +0 -62
  227. package/src/crud/utils/inlineArrayName.ts +0 -4
  228. package/src/crud/utils/inlineFieldName.ts +0 -8
  229. package/src/crud/utils/pickBySources.ts +0 -24
  230. package/src/crud/utils/useResourceFormData.ts +0 -231
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Muhammad Inaam Munir
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammad Inaam Munir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,201 +1,254 @@
1
- # ding-react-admin
2
-
3
- **npm:** [`ding-react-admin`](https://www.npmjs.com/package/ding-react-admin)
4
-
5
- ## Live demo:
6
- [playground on GitHub Pages](https://muhammadinaam.github.io/ding-react-admin/) (login: `admin` / `admin` or `user` / `user`)
7
-
8
- ## Tutorial:
9
- [Build an admin app and add a Users page](docs/tutorial-one-entity.md) — step-by-step from `yarn create vite` through CRUD and routes.
10
-
11
- ```bash
12
- yarn add ding-react-admin antd @ant-design/icons dayjs react-hook-form react-router-dom
13
- ```
14
-
15
- Install details and peer versions: [docs/install.md](docs/install.md).
16
-
17
- Composable admin shell for React apps: **Ant Design 6** layout, **CRUD field system** (lists, forms, filters, inlines, bulk actions), **theme/density** controls, **`AuthProvider`** + **`useAuth`**, **data / permissions providers** (react-admin–style naming, intentionally small), and **React Router** helpers.
18
-
19
- ## Screenshots
20
-
21
- From the [playground demo](https://muhammadinaam.github.io/ding-react-admin/):
22
-
23
- | List with filters | Tabbed form page |
24
- | --- | --- |
25
- | ![List page with filters](docs/assets/list-page-with-filters.png) | ![Non-modal tabbed form](docs/assets/non-modal-form-tabbed.png) |
26
-
27
- | Stepped modal form | Login |
28
- | --- | --- |
29
- | ![Modal form with steps](docs/assets/modal-form-stepped.png) | ![Login page](docs/assets/login.png) |
30
-
31
- ## Declarative CRUD
32
-
33
- Wire a [`DataProvider`](docs/data-permissions.md) (see [Providers](#providers-manual-composition) below), then describe list and form pages in JSX — field `source` names map to your API. Filters, modals, permissions, and validation plug in when you need them; start with the basics:
34
-
35
- ### List page
36
-
37
- ```tsx
38
- import { ResourceList, TextColumn, DateColumn } from "ding-react-admin";
39
-
40
- export function InvoiceListPage() {
41
- return (
42
- <ResourceList resource="invoices" title="Invoices" pathPrefix="/invoices">
43
- <TextColumn source="number" label="Number" />
44
- <TextColumn source="customer" label="Customer" />
45
- <DateColumn source="issuedAt" label="Issued" />
46
- </ResourceList>
47
- );
48
- }
49
- ```
50
-
51
- Add `<TextFilter />`, `<ReferenceFilter />`, bulk actions, and row permissions inside the same component — [list pages guide](docs/crud/list-pages.md).
52
-
53
- ### Form page
54
-
55
- ```tsx
56
- import { ResourceForm, TextField, DateField } from "ding-react-admin";
57
-
58
- export function InvoiceFormPage() {
59
- return (
60
- <ResourceForm resource="invoices" title="Invoice" listPath="/invoices">
61
- <TextField source="number" label="Number" required />
62
- <TextField source="customer" label="Customer" required />
63
- <DateField source="issuedAt" label="Issued" required />
64
- </ResourceForm>
65
- );
66
- }
67
- ```
68
-
69
- Tabbed forms, stepped modals, and API error mapping — [forms guide](docs/crud/forms.md).
70
-
71
- ### Inline nested rows
72
-
73
- Django-style tabular inlines: related rows edit in a table inside the parent form.
74
-
75
- ![Form with inline rows](docs/assets/form-with-inline.png)
76
-
77
- ```tsx
78
- import {
79
- InlineFormSet,
80
- NumberField,
81
- ResourceForm,
82
- TextField,
83
- } from "ding-react-admin";
84
-
85
- <ResourceForm
86
- resource="invoices"
87
- title="Invoice"
88
- listPath="/invoices"
89
- inlines={[{ resource: "invoice-lines", foreignKey: "invoiceId" }]}
90
- >
91
- <TextField source="number" label="Number" required />
92
- <TextField source="customer" label="Customer" required />
93
- <InlineFormSet
94
- resource="invoice-lines"
95
- foreignKey="invoiceId"
96
- label="Lines"
97
- columns={[
98
- {
99
- source: "label",
100
- label: "Label",
101
- cell: ({ name }) => (
102
- <TextField source="label" name={name} hideLabel required />
103
- ),
104
- },
105
- {
106
- source: "quantity",
107
- label: "Qty",
108
- width: 120,
109
- cell: ({ name }) => (
110
- <NumberField source="quantity" name={name} hideLabel required min={0} />
111
- ),
112
- },
113
- {
114
- source: "unitPrice",
115
- label: "Unit price",
116
- cell: ({ name }) => (
117
- <NumberField
118
- source="unitPrice"
119
- name={name}
120
- hideLabel
121
- required
122
- min={0}
123
- step={0.01}
124
- />
125
- ),
126
- },
127
- ]}
128
- />
129
- </ResourceForm>
130
- ```
131
-
132
- Stacked layout, dependent fields, and validation [inlines guide](docs/crud/inlines.md).
133
-
134
- ## Providers (manual composition)
135
-
136
- Nothing is wired automatically except theme inside `<AdminApp />`. Wrap providers yourself:
137
-
138
- | Provider | Required for |
139
- |----------|----------------|
140
- | **`AuthProvider`** | Login, logout, route guards (`Protected`, `GuestOnly`), `useAuth` |
141
- | **`DataProvider`** | CRUD components (`ResourceList`, `ResourceForm`, …) |
142
- | **`PermissionsProvider`** | Permission gating in CRUD (`usePermissions`, `useCan`) |
143
-
144
- **Auth only** (custom pages, no CRUD yet):
145
-
146
- ```tsx
147
- <AuthProvider adapter={createSessionStorageAuthAdapter()}>
148
- <AdminApp navItems={nav} routes={routes} />
149
- </AuthProvider>
150
- ```
151
-
152
- **Full stack** (CRUD + permissions) — see [docs/data-permissions.md](docs/data-permissions.md) and [`examples/playground/src/main.tsx`](examples/playground/src/main.tsx):
153
-
154
- ```tsx
155
- <AuthProvider adapter={authAdapter}>
156
- <DataProvider value={dataProvider}>
157
- <PermissionsProvider can={permissions}>
158
- <AdminApp navItems={nav} routes={routes} />
159
- </PermissionsProvider>
160
- </DataProvider>
161
- </AuthProvider>
162
- ```
163
-
164
- Use **`createSessionStorageAuthAdapter`** for demos; replace with an adapter that calls your API in production. Implement **`AuthAdapter.login`** with a **`LoginCredentials`** object (`username`, `password`, plus any extra fields your login form needs, e.g. `businessId`).
165
-
166
- ## Getting started
167
-
168
- **New to CRUD:** [docs/tutorial-one-entity.md](docs/tutorial-one-entity.md) — full walkthrough from `yarn create vite` through Users list/form, `data-provider.ts`, and routes.
169
-
170
- **Quick path:** [docs/quick-start.md](docs/quick-start.md) — `<AuthProvider>` + `<AdminApp />` with declarative routes.
171
-
172
- **Full control:** [docs/composition.md](docs/composition.md) and the [playground](examples/playground/src/main.tsx) — your own `createBrowserRouter` with `AdminLayout`, `Protected`, `GuestOnly`, `DataProvider`, and `PermissionsProvider`.
173
-
174
- ## Documentation
175
-
176
- | Topic | Guide |
177
- |-------|--------|
178
- | Install & peer deps | [docs/install.md](docs/install.md) |
179
- | **Tutorial: add one CRUD entity** | [docs/tutorial-one-entity.md](docs/tutorial-one-entity.md) |
180
- | Example playground app | [docs/example-app.md](docs/example-app.md) |
181
- | Sidebar navigation | [docs/navigation.md](docs/navigation.md) |
182
- | CRUD overview | [docs/crud/overview.md](docs/crud/overview.md) |
183
- | List pages & filters | [docs/crud/list-pages.md](docs/crud/list-pages.md) |
184
- | **Bulk actions** (Django-style) | [docs/crud/bulk-actions.md](docs/crud/bulk-actions.md) |
185
- | Form pages | [docs/crud/forms.md](docs/crud/forms.md) |
186
- | Reference / lookup fields | [docs/crud/references.md](docs/crud/references.md) |
187
- | Inline nested forms | [docs/crud/inlines.md](docs/crud/inlines.md) |
188
- | Custom field types | [docs/crud/custom-fields.md](docs/crud/custom-fields.md) |
189
- | Data layer & permissions | [docs/data-permissions.md](docs/data-permissions.md) |
190
- | **Form validation errors** | [docs/form-validation-errors.md](docs/form-validation-errors.md) |
191
- | **Routing & auth guards** | [docs/routing.md](docs/routing.md) |
192
- | Login / register layout | [docs/auth-pages.md](docs/auth-pages.md) |
193
- | Quick start (`<AdminApp />`) | [docs/quick-start.md](docs/quick-start.md) |
194
- | Composition (your own router) | [docs/composition.md](docs/composition.md) |
195
- | Odoo-style app hub | [docs/app-hub.md](docs/app-hub.md) |
196
- | `createAdminRouter` shortcut | [docs/admin-router.md](docs/admin-router.md) |
197
- | Developing next to your app (Vite) | [docs/developing.md](docs/developing.md) |
198
-
199
- ## License
200
-
201
- MIT
1
+ # ding-react-admin
2
+
3
+ [![npm version](https://img.shields.io/npm/v/ding-react-admin.svg)](https://www.npmjs.com/package/ding-react-admin)
4
+ [![license](https://img.shields.io/npm/l/ding-react-admin.svg)](https://github.com/Muhammadinaam/ding-react-admin/blob/main/LICENSE)
5
+ [![build](https://img.shields.io/github/actions/workflow/status/Muhammadinaam/ding-react-admin/ci.yml?branch=main)](https://github.com/Muhammadinaam/ding-react-admin/actions/workflows/ci.yml)
6
+
7
+ Composable admin shell for React apps: **Ant Design 6** layout, **CRUD field system** (lists, forms, filters, inlines, bulk actions), **theme/density** controls, **`AuthProvider`** + **`useAuth`**, **data / permissions providers** (react-admin–style naming, intentionally small), and **React Router** helpers.
8
+
9
+ ## Live demo
10
+
11
+ [![Open playground](https://img.shields.io/badge/Try%20it-playground-1677ff?style=for-the-badge)](https://muhammadinaam.github.io/ding-react-admin/)
12
+
13
+ Interactive demo on GitHub Pages — sign in with **`admin` / `admin`** or **`user` / `user`**.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install ding-react-admin antd @ant-design/icons dayjs react-hook-form react-router-dom
19
+ ```
20
+
21
+ ```bash
22
+ yarn add ding-react-admin antd @ant-design/icons dayjs react-hook-form react-router-dom
23
+ ```
24
+
25
+ Peer dependency versions and setup notes: [docs/install.md](docs/install.md).
26
+
27
+ ## Quick start
28
+
29
+ Wrap your app with `AuthProvider`, then render `AdminApp` with navigation and routes:
30
+
31
+ ```tsx
32
+ import { AdminApp, AuthProvider, createSessionStorageAuthAdapter } from "ding-react-admin";
33
+
34
+ const navItems = [{ key: "home", label: "Home", path: "/" }];
35
+ const routes = [{ path: "/", element: <div>Welcome</div> }];
36
+
37
+ export function App() {
38
+ return (
39
+ <AuthProvider adapter={createSessionStorageAuthAdapter()}>
40
+ <AdminApp navItems={navItems} routes={routes} />
41
+ </AuthProvider>
42
+ );
43
+ }
44
+ ```
45
+
46
+ For CRUD pages, add `DataProvider` and `PermissionsProvider` — see [Getting started](#getting-started) and [docs/quick-start.md](docs/quick-start.md).
47
+
48
+ ## Tutorial
49
+
50
+ [Build an admin app and add a Users page](docs/tutorial-one-entity.md) — step-by-step from `yarn create vite` through CRUD and routes.
51
+
52
+ ## Features
53
+
54
+ - **Declarative CRUD** — describe list and form pages in JSX; field `source` names map to your API
55
+ - **List tables** with column sorting, pagination, and URL-synced query state
56
+ - **Filters** — text, number, boolean, date, select, and reference lookups on list pages
57
+ - **Page forms** and **modal forms** (`ResourceForm`, `ResourceFormModal`) with shared create/edit logic
58
+ - **Tabbed forms** (`FormTabs`) and **stepped forms** (`FormSteps`) for long or wizard-style records
59
+ - **Reference / lookup fields** with inline **create** and **edit** actions in a modal
60
+ - **Inline nested rows** — tabular (`InlineFormSet`) and stacked layouts for related records
61
+ - **Bulk actions** Django-style row selection and batch operations
62
+ - **Built-in fields** text, number, boolean, date, select, password, image, file, reference, reference-many
63
+ - **Permissions** gate list/form actions and nav items per resource (`useCan`, `usePermissions`)
64
+ - **Auth & routing** — `AuthProvider`, login page, `Protected` / `GuestOnly` route guards
65
+ - **Theme & density** — light/dark mode and compact/comfortable layout switches
66
+ - **Validation errors** — map API responses to field errors (Django REST, .NET, Node helpers included)
67
+ - **Data layer** — `DataProvider` contract plus REST and in-memory handler factories
68
+ - **Uploads** — image/file fields with `FormData` submit support
69
+
70
+ ## Screenshots
71
+
72
+ From the [playground demo](https://muhammadinaam.github.io/ding-react-admin/):
73
+
74
+ **List with filters**
75
+
76
+ ![List page with filters](docs/assets/list-page-with-filters.png)
77
+
78
+ **Tabbed form page**
79
+
80
+ ![Non-modal tabbed form](docs/assets/non-modal-form-tabbed.png)
81
+
82
+ **Stepped modal form**
83
+
84
+ ![Modal form with steps](docs/assets/modal-form-stepped.png)
85
+
86
+ **Login**
87
+
88
+ ![Login page](docs/assets/login.png)
89
+
90
+ ## Declarative CRUD
91
+
92
+ Wire a [`DataProvider`](docs/data-permissions.md) (see [Providers](#providers-manual-composition) below), then describe list and form pages in JSX — field `source` names map to your API. Filters, modals, permissions, and validation plug in when you need them; start with the basics:
93
+
94
+ ### List page
95
+
96
+ ```tsx
97
+ import { ResourceList, TextColumn, DateColumn } from "ding-react-admin";
98
+
99
+ export function InvoiceListPage() {
100
+ return (
101
+ <ResourceList resource="invoices" title="Invoices" pathPrefix="/invoices">
102
+ <TextColumn source="number" label="Number" />
103
+ <TextColumn source="customer" label="Customer" />
104
+ <DateColumn source="issuedAt" label="Issued" />
105
+ </ResourceList>
106
+ );
107
+ }
108
+ ```
109
+
110
+ Add `<TextFilter />`, `<ReferenceFilter />`, bulk actions, and row permissions inside the same component — [list pages guide](docs/crud/list-pages.md).
111
+
112
+ ### Form page
113
+
114
+ ```tsx
115
+ import { ResourceForm, TextField, DateField } from "ding-react-admin";
116
+
117
+ export function InvoiceFormPage() {
118
+ return (
119
+ <ResourceForm resource="invoices" title="Invoice" listPath="/invoices">
120
+ <TextField source="number" label="Number" required />
121
+ <TextField source="customer" label="Customer" required />
122
+ <DateField source="issuedAt" label="Issued" required />
123
+ </ResourceForm>
124
+ );
125
+ }
126
+ ```
127
+
128
+ Tabbed forms, stepped modals, and API validation errors under fields (fetch, axios, OpenAPI) — [forms guide](docs/crud/forms.md) · [validation errors](docs/form-validation-errors.md).
129
+
130
+ ### Inline nested rows
131
+
132
+ Django-style tabular inlines: related rows edit in a table inside the parent form.
133
+
134
+ ![Form with inline rows](docs/assets/form-with-inline.png)
135
+
136
+ ```tsx
137
+ import {
138
+ InlineFormSet,
139
+ NumberField,
140
+ ResourceForm,
141
+ TextField,
142
+ } from "ding-react-admin";
143
+
144
+ <ResourceForm resource="invoices" title="Invoice" listPath="/invoices">
145
+ <TextField source="number" label="Number" required />
146
+ <TextField source="customer" label="Customer" required />
147
+ <InlineFormSet
148
+ field="lines"
149
+ label="Lines"
150
+ columns={[
151
+ {
152
+ source: "label",
153
+ label: "Label",
154
+ cell: ({ name }) => (
155
+ <TextField source="label" name={name} hideLabel required />
156
+ ),
157
+ },
158
+ {
159
+ source: "quantity",
160
+ label: "Qty",
161
+ width: 120,
162
+ cell: ({ name }) => (
163
+ <NumberField source="quantity" name={name} hideLabel required min={0} />
164
+ ),
165
+ },
166
+ {
167
+ source: "unitPrice",
168
+ label: "Unit price",
169
+ cell: ({ name }) => (
170
+ <NumberField
171
+ source="unitPrice"
172
+ name={name}
173
+ hideLabel
174
+ required
175
+ min={0}
176
+ step={0.01}
177
+ />
178
+ ),
179
+ },
180
+ ]}
181
+ />
182
+ </ResourceForm>
183
+ ```
184
+
185
+ If you already use react-hook-form, you can pick this up in minutes — nested inlines are just `useFieldArray` on the same record. See [inlines guide](docs/crud/inlines.md).
186
+
187
+ ## Providers (manual composition)
188
+
189
+ Nothing is wired automatically except theme inside `<AdminApp />`. Wrap providers yourself:
190
+
191
+ | Provider | Required for |
192
+ |----------|----------------|
193
+ | **`AuthProvider`** | Login, logout, route guards (`Protected`, `GuestOnly`), `useAuth` |
194
+ | **`DataProvider`** | CRUD components (`ResourceList`, `ResourceForm`, …) |
195
+ | **`PermissionsProvider`** | Permission gating in CRUD (`usePermissions`, `useCan`) |
196
+
197
+ **Auth only** (custom pages, no CRUD yet):
198
+
199
+ ```tsx
200
+ <AuthProvider adapter={createSessionStorageAuthAdapter()}>
201
+ <AdminApp navItems={nav} routes={routes} />
202
+ </AuthProvider>
203
+ ```
204
+
205
+ **Full stack** (CRUD + permissions) — see [docs/data-permissions.md](docs/data-permissions.md) and [`examples/playground/src/main.tsx`](examples/playground/src/main.tsx):
206
+
207
+ ```tsx
208
+ <AuthProvider adapter={authAdapter}>
209
+ <DataProvider value={dataProvider}>
210
+ <PermissionsProvider can={permissions}>
211
+ <AdminApp navItems={nav} routes={routes} />
212
+ </PermissionsProvider>
213
+ </DataProvider>
214
+ </AuthProvider>
215
+ ```
216
+
217
+ Use **`createSessionStorageAuthAdapter`** for demos; replace with an adapter that calls your API in production. Implement **`AuthAdapter.login`** with a **`LoginCredentials`** object (`username`, `password`, plus any extra fields your login form needs, e.g. `businessId`). Optionally implement **`getUserLabel`** so the account menu shows the logged-in user — see [data-permissions.md](docs/data-permissions.md#account-menu-label).
218
+
219
+ ## Getting started
220
+
221
+ **New to CRUD:** [docs/tutorial-one-entity.md](docs/tutorial-one-entity.md) — full walkthrough from `yarn create vite` through Users list/form, `data-provider.ts`, and routes.
222
+
223
+ **Quick path:** [docs/quick-start.md](docs/quick-start.md) — `<AuthProvider>` + `<AdminApp />` with declarative routes.
224
+
225
+ **Full control:** [docs/composition.md](docs/composition.md) and the [playground](examples/playground/src/main.tsx) — your own `createBrowserRouter` with `AdminLayout`, `Protected`, `GuestOnly`, `DataProvider`, and `PermissionsProvider`.
226
+
227
+ ## Documentation
228
+
229
+ | Topic | Guide |
230
+ |-------|--------|
231
+ | Install & peer deps | [docs/install.md](docs/install.md) |
232
+ | **Tutorial: add one CRUD entity** | [docs/tutorial-one-entity.md](docs/tutorial-one-entity.md) |
233
+ | Example playground app | [docs/example-app.md](docs/example-app.md) |
234
+ | Sidebar navigation | [docs/navigation.md](docs/navigation.md) |
235
+ | CRUD overview | [docs/crud/overview.md](docs/crud/overview.md) |
236
+ | List pages & filters | [docs/crud/list-pages.md](docs/crud/list-pages.md) |
237
+ | **Bulk actions** (Django-style) | [docs/crud/bulk-actions.md](docs/crud/bulk-actions.md) |
238
+ | Form pages | [docs/crud/forms.md](docs/crud/forms.md) |
239
+ | Reference / lookup fields | [docs/crud/references.md](docs/crud/references.md) |
240
+ | Inline nested forms | [docs/crud/inlines.md](docs/crud/inlines.md) |
241
+ | Custom field types | [docs/crud/custom-fields.md](docs/crud/custom-fields.md) |
242
+ | Data layer & permissions | [docs/data-permissions.md](docs/data-permissions.md) |
243
+ | **Form validation errors** | [docs/form-validation-errors.md](docs/form-validation-errors.md) |
244
+ | **Routing & auth guards** | [docs/routing.md](docs/routing.md) |
245
+ | Login / register layout | [docs/auth-pages.md](docs/auth-pages.md) |
246
+ | Quick start (`<AdminApp />`) | [docs/quick-start.md](docs/quick-start.md) |
247
+ | Composition (your own router) | [docs/composition.md](docs/composition.md) |
248
+ | Odoo-style app hub | [docs/app-hub.md](docs/app-hub.md) |
249
+ | `createAdminRouter` shortcut | [docs/admin-router.md](docs/admin-router.md) |
250
+ | Developing next to your app (Vite) | [docs/developing.md](docs/developing.md) |
251
+
252
+ ## License
253
+
254
+ MIT
package/dist/index.css ADDED
@@ -0,0 +1,2 @@
1
+ .ding-admin-scroll{scrollbar-width:thin;scrollbar-color:var(--ding-scroll-thumb) transparent}.ding-admin-scroll::-webkit-scrollbar{width:6px;height:6px}.ding-admin-scroll::-webkit-scrollbar-track{background:0 0}.ding-admin-scroll::-webkit-scrollbar-thumb{background-color:var(--ding-scroll-thumb);background-clip:padding-box;border:1px solid #0000;border-radius:999px}.ding-admin-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--ding-scroll-thumb-hover)}.ding-admin-scroll::-webkit-scrollbar-corner{background:0 0}.ding-admin-nav-menu .ant-menu-title-content{min-width:0;overflow:hidden}.ding-admin-menu-label{text-overflow:ellipsis;white-space:nowrap;width:100%;min-width:0;max-width:100%;display:block;overflow:hidden}.ant-drawer .ding-admin-menu-label{white-space:normal;text-overflow:clip;overflow:visible}
2
+ /*$vite$:1*/