@dashadmin/dash-auto-admin 1.3.25 → 1.3.26

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 (176) hide show
  1. package/dist/DashAutoAdminComponentRegistry.js +64 -1
  2. package/dist/DashAutoAdminForm.js +137 -1
  3. package/dist/DashAutoAdminResizableDrawer.js +63 -1
  4. package/dist/DashAutoAdminSaveButton.js +57 -1
  5. package/dist/DashAutoCreate.js +102 -1
  6. package/dist/DashAutoDrawer.js +256 -1
  7. package/dist/DashAutoEdit.js +99 -1
  8. package/dist/DashAutoFiltersGenerator.js +193 -1
  9. package/dist/DashAutoFormGroups.js +118 -1
  10. package/dist/DashAutoFormLayout.js +68 -1
  11. package/dist/DashAutoFormMuiTabs.js +291 -1
  12. package/dist/DashAutoFormTabs.js +132 -1
  13. package/dist/DashAutoGroup.js +27 -1
  14. package/dist/DashAutoLayout.js +31 -1
  15. package/dist/DashAutoList.js +218 -1
  16. package/dist/DashAutoPostFilterForm.js +47 -1
  17. package/dist/DashAutoReferenceTab.js +10 -1
  18. package/dist/DashAutoResource.js +77 -1
  19. package/dist/DashAutoResourceLayout.js +16 -1
  20. package/dist/DashAutoShow.js +195 -1
  21. package/dist/DashAutoTabbedForm.js +244 -1
  22. package/dist/DashAutoTabbedForm.review.js +221 -1
  23. package/dist/DashAutoTabs.js +11 -1
  24. package/dist/DashFilterWrapper.js +62 -1
  25. package/dist/DashRedirect.js +56 -1
  26. package/dist/TabbedLayout.js +38 -1
  27. package/dist/common/DashAutoTitle.js +33 -1
  28. package/dist/common/components/FabButton.js +59 -1
  29. package/dist/common/components/TranslatedLabel.js +60 -1
  30. package/dist/common/settings/Settings.js +196 -1
  31. package/dist/common/settings/SettingsBarIcons.js +61 -1
  32. package/dist/context/DashAutoAdminFormContext.js +15 -1
  33. package/dist/hooks/useAutoAdminLoadingStateMediator.js +36 -1
  34. package/dist/hooks/useAutoAdminTranslate.js +61 -1
  35. package/dist/hooks/useHash.js +24 -1
  36. package/dist/hooks/useLogger.js +20 -1
  37. package/dist/hooks/useRoutePathPattern.js +20 -1
  38. package/dist/hooks/useVirtualHash.js +28 -1
  39. package/dist/index.js +77 -3406
  40. package/dist/list/DashAutoListActions.js +57 -1
  41. package/dist/list/DashAutoListDatagridWrapper.js +68 -1
  42. package/dist/list/DashAutoListDefaultActionsWrapper.js +14 -1
  43. package/dist/list/DashAutoListFilterFormWithButton.js +80 -1
  44. package/dist/list/DashAutoListTopToolbar.js +180 -1
  45. package/dist/mui/AttributeToField.js +576 -1
  46. package/dist/mui/AttributeToInput.js +630 -1
  47. package/dist/mui/AutoAdminResizableDrawer.js +63 -1
  48. package/dist/mui/AutoDataGrid.js +120 -1
  49. package/dist/mui/AutoReferenceFormTab.js +53 -1
  50. package/dist/mui/AutoReferenceTab.js +46 -1
  51. package/dist/mui/AutoTabs.js +19 -1
  52. package/dist/mui/components/ExtendedPagination.js +34 -1
  53. package/dist/mui/components/ListStringField.js +25 -1
  54. package/dist/providers/DashAuthProvider.js +215 -1
  55. package/dist/providers/DashDataProvider.js +310 -1
  56. package/dist/providers/index.js +10 -1
  57. package/dist/react-admin.d.js +0 -0
  58. package/dist/toolbar/buttons/BottomToolbarButtons.js +65 -1
  59. package/dist/toolbar/buttons/DashResourceButton.js +181 -1
  60. package/dist/toolbar/buttons/ListButtons.js +80 -1
  61. package/dist/toolbar/buttons/ToolbarButtons.js +135 -1
  62. package/dist/types/ActionCallback.d.js +0 -0
  63. package/dist/utils/SimpleLogger.js +52 -1
  64. package/dist/utils/enumToChoices.js +5 -1
  65. package/dist/utils/evalActionPermission.js +11 -1
  66. package/dist/utils/groupByTabs.js +21 -1
  67. package/dist/utils/hashedGroupByTabs.js +12 -1
  68. package/dist/utils/invertMap.js +12 -1
  69. package/dist/utils/isClassComponent.js +7 -1
  70. package/dist/utils/isComponent.js +29 -1
  71. package/dist/utils/isEnum.js +5 -1
  72. package/dist/utils/isFC.js +8 -1
  73. package/dist/utils/replaceParams.js +9 -1
  74. package/dist/utils/validate.js +19 -1
  75. package/dist/wrappers/UserAction.js +60 -1
  76. package/dist/wrappers/index.js +4 -1
  77. package/package.json +135 -120
  78. package/src/DashAutoAdminComponentRegistry.tsx +75 -0
  79. package/src/DashAutoAdminForm.tsx +155 -0
  80. package/src/DashAutoAdminResizableDrawer.tsx +69 -0
  81. package/src/DashAutoAdminSaveButton.tsx +116 -0
  82. package/src/DashAutoCreate.tsx +118 -0
  83. package/src/DashAutoDrawer.tsx +288 -0
  84. package/src/DashAutoEdit.tsx +109 -0
  85. package/src/DashAutoFiltersGenerator.tsx +208 -0
  86. package/src/DashAutoFormGroups.tsx +146 -0
  87. package/src/DashAutoFormLayout.tsx.review +113 -0
  88. package/src/DashAutoFormMuiTabs.tsx +368 -0
  89. package/src/DashAutoFormTabs.tsx +177 -0
  90. package/src/DashAutoGroup.tsx +42 -0
  91. package/src/DashAutoLayout.tsx +57 -0
  92. package/src/DashAutoList.tsx +237 -0
  93. package/src/DashAutoPostFilterForm.tsx +35 -0
  94. package/src/DashAutoReferenceTab.tsx +9 -0
  95. package/src/DashAutoResource.tsx +85 -0
  96. package/src/DashAutoResourceLayout.tsx +50 -0
  97. package/src/DashAutoShow.tsx +200 -0
  98. package/src/DashAutoTabbedForm.review.tsx +262 -0
  99. package/src/DashAutoTabbedForm.tsx +324 -0
  100. package/src/DashAutoTabs.tsx +19 -0
  101. package/src/DashFilterWrapper.tsx +43 -0
  102. package/src/DashRedirect.tsx +46 -0
  103. package/src/TabbedLayout.tsx +29 -0
  104. package/src/common/DashAutoTitle.tsx +24 -0
  105. package/src/common/components/FabButton.tsx +40 -0
  106. package/src/common/components/TranslatedLabel.tsx +81 -0
  107. package/src/common/settings/Settings.tsx +236 -0
  108. package/src/common/settings/SettingsBarIcons.tsx +72 -0
  109. package/src/context/DashAutoAdminFormContext.tsx +31 -0
  110. package/src/hooks/useAutoAdminLoadingStateMediator.tsx +42 -0
  111. package/src/hooks/useAutoAdminTranslate.tsx +106 -0
  112. package/src/hooks/useHash.tsx +27 -0
  113. package/src/hooks/useLogger.tsx +23 -0
  114. package/src/hooks/useRoutePathPattern.tsx +24 -0
  115. package/src/hooks/useVirtualHash.tsx +34 -0
  116. package/src/index.ts +85 -0
  117. package/src/interfaces/ICustomResourceSubComponent.ts +11 -0
  118. package/src/interfaces/IDashApplicationLayoutMainAction.ts +37 -0
  119. package/src/interfaces/IDashApplicationLayoutMenuItem.ts +24 -0
  120. package/src/interfaces/IDashAutoAdminAttribute.ts +104 -0
  121. package/src/interfaces/IDashAutoAdminCustomFieldComponent.ts +18 -0
  122. package/src/interfaces/IDashAutoAdminFormOptions.ts +22 -0
  123. package/src/interfaces/IDashAutoAdminListActions.ts +13 -0
  124. package/src/interfaces/IDashAutoAdminReference.ts +16 -0
  125. package/src/interfaces/IDashAutoAdminResourceConfig.ts +360 -0
  126. package/src/interfaces/IDashAutoForm.ts +24 -0
  127. package/src/interfaces/IDashAutoGridButton.ts +35 -0
  128. package/src/interfaces/IDashAutoShow.ts +12 -0
  129. package/src/interfaces/IGroupExtraData.ts +8 -0
  130. package/src/interfaces/IRecord.ts +7 -0
  131. package/src/interfaces/IReferenceFilter.ts +55 -0
  132. package/src/interfaces/IResourceComponent.ts +8 -0
  133. package/src/interfaces/IToolbarButton.ts +11 -0
  134. package/src/list/DashAutoListActions.tsx +88 -0
  135. package/src/list/DashAutoListDatagridWrapper.tsx +74 -0
  136. package/src/list/DashAutoListDefaultActionsWrapper.tsx +31 -0
  137. package/src/list/DashAutoListFilterFormWithButton.tsx +93 -0
  138. package/src/list/DashAutoListTopToolbar.tsx +240 -0
  139. package/src/mui/AttributeToField.tsx +657 -0
  140. package/src/mui/AttributeToInput.tsx +728 -0
  141. package/src/mui/AutoAdminResizableDrawer.tsx +69 -0
  142. package/src/mui/AutoDataGrid.tsx +127 -0
  143. package/src/mui/AutoReferenceFormTab.tsx +51 -0
  144. package/src/mui/AutoReferenceTab.tsx +45 -0
  145. package/src/mui/AutoTabs.tsx +32 -0
  146. package/src/mui/components/ExtendedPagination.tsx +23 -0
  147. package/src/mui/components/ListStringField.tsx +32 -0
  148. package/src/providers/DashAuthProvider.ts +341 -0
  149. package/src/providers/DashDataProvider.ts +466 -0
  150. package/src/providers/index.ts +17 -0
  151. package/src/toolbar/buttons/BottomToolbarButtons.tsx +59 -0
  152. package/src/toolbar/buttons/DashResourceButton.tsx +223 -0
  153. package/src/toolbar/buttons/ListButtons.tsx +137 -0
  154. package/src/toolbar/buttons/ToolbarButtons.tsx +186 -0
  155. package/src/utils/SimpleLogger.tsx +46 -0
  156. package/src/utils/enumToChoices.tsx +3 -0
  157. package/src/utils/evalActionPermission.tsx +14 -0
  158. package/src/utils/groupByTabs.tsx +23 -0
  159. package/src/utils/hashedGroupByTabs.tsx +16 -0
  160. package/src/utils/invertMap.tsx +10 -0
  161. package/src/utils/isClassComponent.tsx +9 -0
  162. package/src/utils/isComponent.tsx +45 -0
  163. package/src/utils/isEnum.tsx +3 -0
  164. package/src/utils/isFC.tsx +6 -0
  165. package/src/utils/replaceParams.tsx +6 -0
  166. package/src/utils/validate.tsx +24 -0
  167. package/src/wrappers/UserAction.tsx +67 -0
  168. package/src/wrappers/index.tsx +1 -0
  169. /package/{dist → src}/DashAutoAdminSaveButton.tsx.bkup +0 -0
  170. /package/{dist/DashAutoFormLayout.tsx.review → src/DashAutoFormLayout.tsx} +0 -0
  171. /package/{dist → src}/DashAutoFormTabs.review +0 -0
  172. /package/{dist → src}/DashAutoFormTabs.tsx.formcontext.wip +0 -0
  173. /package/{dist → src}/mui/AttributeToField.tsx.review +0 -0
  174. /package/{dist → src}/mui/AttributeToInput.tsx.review +0 -0
  175. /package/{dist → src}/react-admin.d.ts +0 -0
  176. /package/{dist → src}/types/ActionCallback.d.ts +0 -0
@@ -0,0 +1,360 @@
1
+ import IApplicationLayoutMainAction from './IDashApplicationLayoutMainAction';
2
+ import IApplicationLayoutMenuItem from './IDashApplicationLayoutMenuItem';
3
+ import IDashAutoAdminAttribute from './IDashAutoAdminAttribute';
4
+ import { IDashAutoAdminReference } from './IDashAutoAdminReference';
5
+ import IDashAutoAdminListActions from './IDashAutoAdminListActions';
6
+ import IAutoGridButton, { IDeleteAutoGridButton, IEditAutoGridButton, IViewAutoGridButton } from './IDashAutoGridButton';
7
+ import IGroupExtraData from './IGroupExtraData';
8
+ import IReferenceFilter from './IReferenceFilter';
9
+ import IDashAutoAdminCustomFieldComponent from './IDashAutoAdminCustomFieldComponent';
10
+ import { IDashAutoDrawerPublicProps } from '../DashAutoDrawer';
11
+ import React, { FC, JSX, ReactNode, ReactPortal } from 'react';
12
+
13
+ //import type { PaginationProps, ListProps, DatagridProps } from 'react-admin';
14
+ import { ListProps } from 'react-admin/src';
15
+ import { Datagrid } from 'react-admin';
16
+
17
+ import { IDashAutoLayoutRenderFunction } from '../DashAutoLayout';
18
+ import { IDashAutoListActionsWrapper } from '../list/DashAutoListDefaultActionsWrapper';
19
+ import { IDashAutoAdminDataGrid } from '../list/DashAutoListDatagridWrapper';
20
+ import { IToolbarFilters } from '../list/DashAutoListTopToolbar';
21
+ import { IToolbarFiltersHandler } from '../list/DashAutoListFilterFormWithButton';
22
+ import { OverridableComponent } from '@mui/material/OverridableComponent';
23
+ import { SvgIconTypeMap } from '@mui/material';
24
+ type ReactNodeWithoutPortal = Exclude<ReactNode, ReactPortal>;
25
+
26
+ /*
27
+ This interface defines the configuration options for an auto-admin resource in the React Auto Admin library. It includes properties for defining the model, label, icon, group, references, schema, search, custom components, buttons, toolbars, layouts, and various other options to customize the behavior of the resource.
28
+ The interface is used to configure the behavior of the auto-admin components, such as the list, edit, create, and show views, as well as the overall layout and functionality of the resource.
29
+ */
30
+
31
+ export default interface IDashAutoAdminResourceConfig {
32
+ locale?: string;
33
+ redirect?: string;
34
+ hidden?: boolean;
35
+ resourceMenuDisabled?: boolean;
36
+ /**
37
+ * When true, this resource is only used for menu navigation (redirect links).
38
+ * It will not register a react-admin resource or CRUD routes.
39
+ * Use `redirect` to specify the target URL, which can be:
40
+ * - An absolute path starting with "/" (e.g., "/plans")
41
+ * - A relative path (e.g., "create") which becomes "/{model}/create"
42
+ * - An external URL
43
+ */
44
+ menuOnly?: boolean;
45
+ /** if not path is provided, model will be used as default */
46
+ path?: string;
47
+ /** */
48
+ model: string;
49
+ /** */
50
+ label?: string;
51
+ //icon?: React.ReactElement | ComponentType<any>;
52
+ /** */
53
+ //icon?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | OverridableComponent<SvgIconTypeMap<{}, "svg">> & { muiName: string; };
54
+ /** */
55
+ icon?: React.ComponentType<any> | React.ReactElement | OverridableComponent<SvgIconTypeMap<{}, "svg">> & { muiName: string };
56
+ /** */
57
+ group?: string;
58
+ /** */
59
+ groupsData?: IGroupExtraData[];
60
+ /** */
61
+ references?: IDashAutoAdminReference[];
62
+ /** */
63
+ referenceFilters?: IReferenceFilter[];
64
+ /*
65
+ deprecated in favor of FilterFormComponent
66
+ customResourceFiltersComponent?: (
67
+ referenceFilters?: IReferenceFilter[],
68
+ ) => ReactNode;
69
+ */
70
+ /** */
71
+ schema: IDashAutoAdminAttribute[];
72
+ /** */
73
+ listSchema?: IDashAutoAdminAttribute[];
74
+ /** */
75
+ editSchema?: IDashAutoAdminAttribute[];
76
+ /** */
77
+ createSchema?: IDashAutoAdminAttribute[];
78
+ /** */
79
+ showSchema?: IDashAutoAdminAttribute[];
80
+ /** */
81
+ exporter?: any;
82
+ /** */
83
+ search?: boolean;
84
+ /**
85
+ * Custom component for rendering the resource.
86
+ * If not provided, defaults to ResourceTemplate from dash-admin.
87
+ */
88
+ component?: (
89
+ resourceConfig: IDashAutoAdminResourceConfig,
90
+ children?: any,
91
+ ) => ReactNode;
92
+ /** */
93
+ roles?: string[];
94
+ /** */
95
+ isFormData?: boolean;
96
+ /** */
97
+ listDeleteButton?: IDeleteAutoGridButton;
98
+ /** */
99
+ listEditButton?: IEditAutoGridButton;
100
+ /** */
101
+ listViewButton?: IViewAutoGridButton;
102
+ /** */
103
+ customListButtons?: IAutoGridButton[];
104
+ /** */
105
+ customToolbarElements?: (filters: ReactNode[]) => any;
106
+ /** */
107
+ customToolbarActions?: (filters: ReactNode[]) => any;
108
+ /** */
109
+ customListActions?: FC<IDashAutoAdminListActions>; //(resourceConfig:IDashAutoAdminResourceConfig,listProps:any,isLoading:boolean,data?:any) => React.ReactElement;
110
+ /** */
111
+ listActionsWrapper?: React.FC<IDashAutoListActionsWrapper>;
112
+ /** Enables soft deletes controller, to force delete records or reinstall them. */
113
+ trash?: boolean;
114
+ /** */
115
+ drawer?: boolean;
116
+ /** */
117
+ drawerOptions?: {
118
+ /* TODO! show or view? */
119
+ /** */
120
+ view?: boolean;
121
+ /** */
122
+ show?: boolean;
123
+ /** */
124
+ edit?: boolean;
125
+ /** */
126
+ create?: boolean;
127
+ }
128
+ /** */
129
+ drawerProps?: IDashAutoDrawerPublicProps;
130
+ /** */
131
+ formGroupMode?: 'tabs' | 'groups' | 'layout';
132
+ formGroupModes?: {
133
+ create?: 'tabs' | 'groups' | 'layout';
134
+ edit?: 'tabs' | 'groups' | 'layout';
135
+ }
136
+ /** */
137
+ saveButton?: boolean;
138
+ /** */
139
+ saveButtonAlwaysEnabled?: boolean;
140
+ /** */
141
+ closeDrawerAfterSave?: boolean;
142
+ /** Optional: hides id from List if true. */
143
+ hideSchemaId?: boolean;
144
+ /** Optional: reset filters on location change. */
145
+ resetFiltersOnLocationChange?: boolean;
146
+ /** Optional: hides default filter toolbar (useful together with customResourceFiltersComponent). */
147
+ hideDefaultFilters?: boolean;
148
+ /** Custom record id param name in url; it only works in custom routes related to auto-admin. Initially required to enable nested resources. */
149
+ idParamName?: string;
150
+ /** */
151
+ mutationMode?: 'pessimistic' | 'optimistic' | 'undoable';
152
+ /**
153
+ * FieldWrapper. Allows to specify a component to wrap around the field.
154
+ * Notice that you must implement a custom logic if you want to exclude the wrapper from certain conditions.$
155
+ * For example, you could apply the wrapper only on the show method:.
156
+ *
157
+ * @example
158
+ * FieldWrapper: ({ children, record, method, attribute }) => {
159
+ return method === "show" ?
160
+ <fieldset>
161
+ <legend>{attribute.label || attribute.attribute}</legend>
162
+ {children}
163
+ </fieldset>
164
+ :
165
+ children
166
+ }
167
+ */
168
+ /**
169
+ * FieldWrapper extends an FC<IDashAutoAdminCustomFieldComponent> including the record, method and attribute (attribute schema)
170
+ * its purpose is to add a custom wrapper to all the fields around the React Auto Admin field.
171
+ */
172
+ fieldWrapper?: ({
173
+ record,
174
+ method,
175
+ attribute,
176
+ children,
177
+ }: IDashAutoAdminCustomFieldComponent) => React.ReactElement;
178
+ /** DataGridProps extends Partial<DatagridProps> from React Admin. */
179
+ dataGridProps?: any;
180
+ /** DataGridComponent replaces the default <AutoDataGrid/> wrapped in a <List/>; use the listComponent to replace the complete list view. */
181
+ dataGridComponent?: React.FC<IDashAutoAdminDataGrid>;
182
+ /** DataGridRootComponent replaces the root React Admin GridComponent. */
183
+ dataGridRootComponent?: typeof Datagrid;
184
+ /**
185
+ * DataGridWrapper extends an FC<PropsWithChildren> component
186
+ * its purpose is to add a custom wrapper around the DataGrid in list views
187
+ * its props are not defined because they depend on the DataGrid being implemented
188
+ * they extends an FC<PropsWithChildren>
189
+ * by default is react-admin DataGrid, but it can be overwritten by the custom datagrid component.
190
+ */
191
+ dataGridWrapper?: (props: any) => React.ReactElement;
192
+ /** ListProps extends Partial<ListProps> from React Admin. */
193
+ listProps?: Partial<ListProps>;
194
+ /** Pagination is an optional component that aims to replace the default Pagination component that extends React Admin PaginationProps. */
195
+ Pagination?: FC<any>;
196
+ /** */
197
+ paginationProps?: any;
198
+ /** FilterFormComponent replaces entirely the default <FilterForm> React-admin component. */
199
+ //FilterFormComponent?: FC<{ resourceConfig: IDashAutoAdminResourceConfig }>;
200
+ FilterFormComponent?: React.ForwardRefExoticComponent<IToolbarFilters & React.RefAttributes<IToolbarFiltersHandler>>;
201
+ /** */
202
+ filterButtonPosition?: 'buttons-toolbar' | 'filters-container'
203
+ /** */
204
+ filterWithSubmit?: boolean;
205
+ /** Post Formatter */
206
+ postFormatter?: (
207
+ params: any,
208
+ method: 'getList' | 'update' | 'create' | 'import',
209
+ ) => { [x: string]: any };
210
+ /** Params Formatter */
211
+ paramsFormatter?: (params: any) => { [x: string]: any };
212
+ /** Form Post Formatter */
213
+ formPostFormatter?: (params: any, form: FormData) => FormData;
214
+ /** Before submit */
215
+ beforeSubmit?: (values: any) => any;
216
+
217
+ /** */
218
+ redirectAfterUpdate?: 'list' | 'view' | 'edit' | boolean;
219
+ /** */
220
+ redirectAfterCreate?: 'list' | 'view' | 'edit' | 'create' | boolean;
221
+ /** */
222
+ onError?: (mode:'list' | 'view' | 'edit' | 'create', error:any) => void | FC<{
223
+ /** */
224
+ mode:'list' | 'view' | 'edit' | 'create',
225
+ /** */
226
+ error:any }>;
227
+
228
+ /** */
229
+ resetFormAfterSubmit?: boolean;
230
+
231
+ /** */
232
+ showDialogAfterSubmit?: boolean;
233
+ /** */
234
+ showNotifyAfterSubmit?: boolean;
235
+
236
+ /** */
237
+ refreshAfter?: boolean;
238
+
239
+ /** */
240
+ mainAction?: IApplicationLayoutMainAction;
241
+ /** */
242
+ menu?:
243
+ | IApplicationLayoutMenuItem[]
244
+ | ((
245
+ resourceConfig?: IDashAutoAdminResourceConfig) => IApplicationLayoutMenuItem[]);
246
+
247
+ /** */
248
+ create?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
249
+ /** */
250
+ list?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
251
+ /** */
252
+ edit?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
253
+ /** */
254
+ delete?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
255
+ /** */
256
+ view?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
257
+
258
+ /** Disable/hide toolbar. */
259
+ toolbar?: boolean;
260
+ /** */
261
+ toolbarEditButton?: IAutoGridButton;
262
+ /** */
263
+ toolbarViewButton?: IAutoGridButton;
264
+ /** */
265
+ toolbarListButton?: IAutoGridButton;
266
+ /** */
267
+ toolbarDeleteButton?: IAutoGridButton;
268
+ /** */
269
+ toolbarSaveButton?: IAutoGridButton;
270
+ /** */
271
+ toolbarCreateButton?: IAutoGridButton;
272
+ /** */
273
+ toolbarExportButton?: IAutoGridButton;
274
+
275
+ /** Disable/hide bottom toolbar. */
276
+ bottomToolbar?: boolean;
277
+ /** */
278
+ bottomToolbarSaveButton?: IAutoGridButton;
279
+ /** */
280
+ bottomToolbarDeleteButton?: IAutoGridButton;
281
+
282
+
283
+ /** */
284
+ showSavedQueries?: boolean;
285
+
286
+ /** */
287
+ BulkActions?:
288
+ | React.ReactElement
289
+ | ReactNode
290
+ | (() => React.ReactElement | ReactNode);
291
+ /** */
292
+ RowActions?:
293
+ | React.ReactElement
294
+ | ReactNode
295
+ | (() => React.ReactElement | ReactNode);
296
+
297
+ //toolbarShow?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
298
+ //toolbarList?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
299
+ //toolbarDelete?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
300
+ //toolbarSave?: boolean | ((resourceConfig: IDashAutoAdminResourceConfig) => boolean);
301
+ bulkActionButtons?: (props: any) => JSX.Element;
302
+ /** */
303
+ customRoutes?: (resourceConfig: IDashAutoAdminResourceConfig) => React.ReactElement;
304
+ /** */
305
+ showComponent?: (resourceConfig: IDashAutoAdminResourceConfig) => React.ReactElement;
306
+ /** List Component replaces the complete list component only wrapped by the specified layout; e.g: reference filters will not be applied. */
307
+ listComponent?: (
308
+ resourceConfig: IDashAutoAdminResourceConfig,
309
+ onError?: (data: any) => void,
310
+ onSubmit?: (data: any) => void,
311
+ ) => React.ReactElement;
312
+
313
+
314
+ /** */
315
+ editComponent?: (resourceConfig: IDashAutoAdminResourceConfig) => React.ReactElement;
316
+ /** */
317
+ createComponent?: (resourceConfig: IDashAutoAdminResourceConfig) => React.ReactElement;
318
+
319
+ /** */
320
+ createLayout?: (render: IDashAutoLayoutRenderFunction) => React.ReactElement;
321
+ /** */
322
+ editLayout?: (render: IDashAutoLayoutRenderFunction) => React.ReactElement;
323
+ /** */
324
+ showLayout?: (render: IDashAutoLayoutRenderFunction) => React.ReactElement;
325
+ /** Generally the error handler is performed in the ResourceTemplate, in case no ResourceTemplate and defualt react-admin beheaviour is implemented, default value will be true. */
326
+ processErrors?: boolean;
327
+ errorParser?: (error: any) => string | React.ReactElement; /** */
328
+ resetSelectedIdsOnLoad?: boolean;
329
+
330
+ /** */
331
+ AutoEditTopToolbarElements?: (
332
+ resourceConfig: IDashAutoAdminResourceConfig,
333
+ ) => React.ReactElement;
334
+ /** */
335
+ AutoCreateTopToolbarElements?: (
336
+ resourceConfig: IDashAutoAdminResourceConfig,
337
+ ) => React.ReactElement;
338
+ /** */
339
+ AutoEditBottomToolbarElements?: (
340
+ resourceConfig: IDashAutoAdminResourceConfig
341
+ ) => React.ReactElement;
342
+ /** */
343
+ AutoCreateBottomToolbarElements?: (
344
+ resourceConfig: IDashAutoAdminResourceConfig,
345
+ ) => React.ReactElement;
346
+ topToolbarButtons?: boolean; // Uses the bottom toolbar button in the top toolbar.
347
+ // Extended Resource Props from reactAdmin:
348
+ recordRepresentation?: string;
349
+ syncTabsWithLocation?: boolean;
350
+
351
+ contextComponent?: ({resourceConfig,mode,children}:{resourceConfig:IDashAutoAdminResourceConfig,mode?:"create" | "edit" | "list" | "view",children?:ReactNode}) => JSX.Element | ReactNode;
352
+ editProps?: any; // TODO Map this with react admin Edit Props.
353
+
354
+ /**
355
+ * Custom configuration object for context components.
356
+ * Can be used to pass custom settings like API paths, storage keys, etc.
357
+ * The contextComponent receives this via resourceConfig.config
358
+ */
359
+ config?: Record<string, any>;
360
+ }
@@ -0,0 +1,24 @@
1
+ import IDashAutoAdminResourceConfig from './IDashAutoAdminResourceConfig';
2
+
3
+ export default interface IAutoForm {
4
+ /** */
5
+ id?: number;
6
+ /** */
7
+ resourceConfig: IDashAutoAdminResourceConfig;
8
+ /** */
9
+ onSubmit?: (values: any) => any;
10
+ /** */
11
+ onError?: (error: any) => any;
12
+ /** */
13
+ onCancel?: () => any;
14
+ /** */
15
+ beforeSubmit?: (values: any) => any;
16
+ /** */
17
+ toolbar?: React.ReactElement;
18
+ /** */
19
+ actions?: React.ReactElement;
20
+ /** */
21
+ isDrawer?: boolean;
22
+ /** */
23
+ locale?: string;
24
+ }
@@ -0,0 +1,35 @@
1
+ export default interface IAutoGridButton {
2
+ /** */
3
+ enabled?: boolean;
4
+ /** */
5
+ props?: any;
6
+ /** */
7
+ component?: any;
8
+ /** */
9
+ modes?: {
10
+ /** */
11
+ list?: boolean;
12
+ /** */
13
+ view?: boolean;
14
+ /** */
15
+ edit?: boolean;
16
+ /** */
17
+ show?: boolean;
18
+ };
19
+ size?: 'small' | 'medium' | 'large';
20
+
21
+ }
22
+
23
+
24
+ export interface IViewAutoGridButton extends IAutoGridButton {
25
+ /** */
26
+ confirm?: boolean
27
+ }
28
+ export interface IEditAutoGridButton extends IAutoGridButton {
29
+ /** */
30
+ confirm?: boolean
31
+ }
32
+ export interface IDeleteAutoGridButton extends IAutoGridButton {
33
+ /** */
34
+ confirm?: boolean
35
+ }
@@ -0,0 +1,12 @@
1
+ import IDashAutoAdminResourceConfig from './IDashAutoAdminResourceConfig';
2
+
3
+ export default interface IAutoShow {
4
+ /** */
5
+ resourceConfig: IDashAutoAdminResourceConfig;
6
+ /** */
7
+ id?: React.Key;
8
+ /** */
9
+ isDrawer?: boolean;
10
+ /** */
11
+ locale?: string;
12
+ }
@@ -0,0 +1,8 @@
1
+ import { JSX } from "react";
2
+
3
+ export default interface IGroupExtraData {
4
+ /** */
5
+ name: string;
6
+ /** */
7
+ icon?: JSX.Element;
8
+ }
@@ -0,0 +1,7 @@
1
+ import IDashAutoAdminAttribute from './IDashAutoAdminAttribute';
2
+
3
+ export default interface IRecord {
4
+ /** */
5
+ attribute?: IDashAutoAdminAttribute;
6
+ [key: string]: any;
7
+ }
@@ -0,0 +1,55 @@
1
+ import React, { FC } from 'react';
2
+ import {
3
+ SelectInputProps,
4
+ AutocompleteInputProps,
5
+ SelectArrayInputProps,
6
+ AutocompleteArrayInputProps,
7
+ } from 'react-admin';
8
+
9
+ /**
10
+ * IReferenceFilter.
11
+ *
12
+ * @description
13
+ *
14
+ * Implemented in AutoFiltersGenerator.tsx
15
+ * Used by the referenceFilter prop in IDashAutoAdminResourceConfig.
16
+ */
17
+ export default interface IReferenceFilter {
18
+ /** Id. */
19
+ id: React.Key;
20
+ /** Filter label. */
21
+ label: string;
22
+ /** Name of the field in the form. */
23
+ source: string;
24
+ /** Model that references or Array with option values. */
25
+ reference: string | Array<Partial<{ /** */
26
+ id: React.Key; /** */
27
+ name: string }>>; // model that references or Enum
28
+ /** */
29
+ optionText: string;
30
+ /** */
31
+ date?: boolean;
32
+ /** Always on feature from react-admin. */
33
+ alwaysOn?: boolean;
34
+ /** Allow to specify a reference component; by default <SelectInput> | <SelectArrayInput/>, any other react admin component literal or even custom FC<any>. */
35
+ referenceComponent?:
36
+ | FC<AutocompleteInputProps>
37
+ | FC<SelectInputProps>
38
+ | FC<SelectArrayInputProps>
39
+ | FC<AutocompleteArrayInputProps>
40
+ | FC<any>;
41
+ /**
42
+ * Props for the reference component, by default <SelectInput/> | <SelectArrayInput/> for single o multiple select filter.
43
+ * This includes props for custom components when using referenceComponent.
44
+ */
45
+ fieldProps?: any;
46
+ slotProps?: any;
47
+ /**
48
+ * TODO: rename to referenceInputProps
49
+ * props for the reference input component <ReferenceInput/>.
50
+ */
51
+ inputOptions?: any;
52
+ /** Specify if the selection is multiple or single. */
53
+ multiple?: boolean;
54
+
55
+ }
@@ -0,0 +1,8 @@
1
+ import IDashAutoAdminResourceConfig from './IDashAutoAdminResourceConfig';
2
+
3
+ export interface IResourceComponent {
4
+ /** */
5
+ resourceConfig: IDashAutoAdminResourceConfig;
6
+ /** */
7
+ children?: React.ReactNode;
8
+ }
@@ -0,0 +1,11 @@
1
+ import { IDashAutoAdminSaveButton } from '../DashAutoAdminSaveButton';
2
+ import IDashAutoAdminResourceConfig from './IDashAutoAdminResourceConfig';
3
+
4
+ export interface IToolbarButton extends IDashAutoAdminSaveButton {
5
+ /** */
6
+ //resourceConfig: IDashAutoAdminResourceConfig;
7
+ /** */
8
+ mode?: 'edit' | 'show' | 'list' | 'create'
9
+ }
10
+
11
+ export default IToolbarButton;
@@ -0,0 +1,88 @@
1
+ import { useRefresh, useUnselectAll, ListContext } from 'react-admin';
2
+ import IDashAutoAdminResourceConfig from '../interfaces/IDashAutoAdminResourceConfig';
3
+ import DashAutoListTopToolbar from './DashAutoListTopToolbar';
4
+ import { FC, useState, useEffect } from 'react';
5
+
6
+ /* TODO: currently restricted to vite env variables */
7
+ export const getEnv = (key: string, defaultValue?:any) => {
8
+ /* @ts-ignore Expected , access to process */
9
+ return process.env['VITE_' + key] || (defaultValue || null);
10
+ };
11
+
12
+ const FILTERS_COLLAPSE_COUNT = getEnv('FILTERS_COLLAPSE_COUNT');
13
+ const FILTERS_COLLAPSE_SIZE = getEnv('FILTERS_COLLAPSE_SIZE');
14
+
15
+ export interface IDashAutoListActions {
16
+ resourceConfig: IDashAutoAdminResourceConfig;
17
+ filters: any;
18
+ autoFilters: any;
19
+ listProps: any;
20
+ }
21
+
22
+ const DashAutoListActions: FC<IDashAutoListActions> = (props) => {
23
+ const { filters, resourceConfig, autoFilters, listProps } = props;
24
+
25
+ // Sanitize the resource model by replacing / with _ for localStorage compatibility
26
+ const sanitizedModel = resourceConfig.model.replace(/\//g, '_');
27
+ const storeKey = `filters.collapsed.${sanitizedModel}`;
28
+
29
+ // Use localStorage directly instead of useStore (for Redux compatibility)
30
+ const [expanded, setExpandedState] = useState<boolean>(() => {
31
+ const stored = localStorage.getItem(storeKey);
32
+ return stored !== null ? JSON.parse(stored) : false;
33
+ });
34
+
35
+ // Persist to localStorage whenever expanded changes
36
+ useEffect(() => {
37
+ localStorage.setItem(storeKey, JSON.stringify(expanded));
38
+ console.log('💾 Persisting filter state:', { storeKey, expanded });
39
+ }, [expanded, storeKey]);
40
+
41
+ const setExpanded = (value: boolean) => {
42
+ console.log('🔄 Setting expanded:', { storeKey, value });
43
+ setExpandedState(value);
44
+ };
45
+
46
+ const countFilters = resourceConfig.referenceFilters && resourceConfig.referenceFilters.length ? resourceConfig.referenceFilters.length : 0;
47
+
48
+ let hasToolbarItems: boolean =
49
+ filters ||
50
+ resourceConfig.create ||
51
+ resourceConfig.exporter ||
52
+ resourceConfig.customToolbarElements
53
+ ? true
54
+ : false;
55
+
56
+ if (resourceConfig?.toolbar === false) {
57
+ hasToolbarItems = false;
58
+ }
59
+
60
+ // Return null instead of empty JSX to avoid rendering empty elements
61
+ if (!hasToolbarItems) return null;
62
+
63
+ const toolbarComponent = (
64
+ <DashAutoListTopToolbar
65
+ resourceConfig={resourceConfig}
66
+ autoFilters={autoFilters}
67
+ filters={filters}
68
+ countFilters={countFilters}
69
+ expanded={expanded}
70
+ setExpanded={setExpanded}
71
+ filterCountToCollapse={FILTERS_COLLAPSE_COUNT}
72
+ collapsedSize={FILTERS_COLLAPSE_SIZE}
73
+ />
74
+ );
75
+
76
+ return resourceConfig.customListActions ? (
77
+ <resourceConfig.customListActions
78
+ resourceConfig={resourceConfig}
79
+ listProps={listProps}
80
+ >
81
+ {toolbarComponent}
82
+ </resourceConfig.customListActions>
83
+ ) : (
84
+ toolbarComponent
85
+ );
86
+ };
87
+
88
+ export default DashAutoListActions;
@@ -0,0 +1,74 @@
1
+ import { useLocation } from 'react-router';
2
+ import { useUnselectAll, ListContext } from 'react-admin';
3
+
4
+ import IDashAutoAdminResourceConfig from '../interfaces/IDashAutoAdminResourceConfig';
5
+ import useAutoAdminLoadingStateMediator from '../hooks/useAutoAdminLoadingStateMediator';
6
+ import { useContext, useEffect, useState } from 'react';
7
+ import AutoDataGrid from '../mui/AutoDataGrid';
8
+ import {
9
+ CircularProgress,
10
+ } from '@mui/material';
11
+ import { IDashAutoList } from '../DashAutoList';
12
+
13
+ // Safe hook that doesn't throw when context is missing
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const useSafeListContext = (): any => {
16
+ const context = useContext(ListContext);
17
+ return context ?? null;
18
+ };
19
+
20
+ export interface IDashAutoAdminDataGrid {
21
+ resourceConfig: IDashAutoAdminResourceConfig;
22
+ dataGridProps?: IDashAutoList['dataGridProps'];
23
+ locale?: string;
24
+ }
25
+
26
+ const DashAutoListDataGridWrapper: React.FC<IDashAutoAdminDataGrid> = ({
27
+ resourceConfig,
28
+ dataGridProps,
29
+ locale,
30
+ }) => {
31
+ const listContext = useSafeListContext();
32
+ const setFilters = listContext?.setFilters;
33
+ const location = useLocation();
34
+ const [currentLocation, setCurrentLocation] = useState(location.pathname);
35
+
36
+ // isLoafing from useListContext should have been enough, nevertheless it doesn't work as needed.
37
+ const [loading] = useAutoAdminLoadingStateMediator('getList');
38
+ const unselectAll = useUnselectAll((resourceConfig.listProps?.storeKey || resourceConfig.model));
39
+ const clearFilters = () => {
40
+
41
+ unselectAll();
42
+ if (setFilters) {
43
+ setFilters({}, []);
44
+ }
45
+ };
46
+
47
+ useEffect(() => {
48
+ if (currentLocation !== location.pathname) {
49
+ if (resourceConfig?.resetFiltersOnLocationChange === true) {
50
+ console.info('Resetting Filters on Location change');
51
+ clearFilters();
52
+ }
53
+ setCurrentLocation(location.pathname);
54
+ }
55
+ }, [location, currentLocation]);
56
+
57
+ return (
58
+ <div className={loading ? 'loading-overlay' : 'default-overlay'}>
59
+ {loading && <CircularProgress className={'datagrid-olverlay-loading'} />}
60
+ <AutoDataGrid resourceConfig={resourceConfig} {...dataGridProps} locale={locale} />
61
+ </div>
62
+ );
63
+
64
+ /*return (
65
+ <div className={ "loading-overlay"}>
66
+
67
+ <CircularProgress className={"datagrid-olverlay-loading"} />
68
+
69
+ <AutoDataGrid resourceConfig={resourceConfig} {...dataGridProps} />
70
+ </div>
71
+ );*/
72
+ };
73
+
74
+ export default DashAutoListDataGridWrapper;