@dashadmin/dash-auto-admin 1.3.25 → 1.3.28

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 (177) hide show
  1. package/README.md +32 -6
  2. package/dist/DashAutoAdminComponentRegistry.js +64 -1
  3. package/dist/DashAutoAdminForm.js +137 -1
  4. package/dist/DashAutoAdminResizableDrawer.js +63 -1
  5. package/dist/DashAutoAdminSaveButton.js +57 -1
  6. package/dist/DashAutoCreate.js +102 -1
  7. package/dist/DashAutoDrawer.js +256 -1
  8. package/dist/DashAutoEdit.js +99 -1
  9. package/dist/DashAutoFiltersGenerator.js +193 -1
  10. package/dist/DashAutoFormGroups.js +118 -1
  11. package/dist/DashAutoFormLayout.js +68 -1
  12. package/dist/DashAutoFormMuiTabs.js +291 -1
  13. package/dist/DashAutoFormTabs.js +132 -1
  14. package/dist/DashAutoGroup.js +27 -1
  15. package/dist/DashAutoLayout.js +31 -1
  16. package/dist/DashAutoList.js +218 -1
  17. package/dist/DashAutoPostFilterForm.js +47 -1
  18. package/dist/DashAutoReferenceTab.js +10 -1
  19. package/dist/DashAutoResource.js +77 -1
  20. package/dist/DashAutoResourceLayout.js +16 -1
  21. package/dist/DashAutoShow.js +195 -1
  22. package/dist/DashAutoTabbedForm.js +244 -1
  23. package/dist/DashAutoTabbedForm.review.js +221 -1
  24. package/dist/DashAutoTabs.js +11 -1
  25. package/dist/DashFilterWrapper.js +62 -1
  26. package/dist/DashRedirect.js +56 -1
  27. package/dist/TabbedLayout.js +38 -1
  28. package/dist/common/DashAutoTitle.js +33 -1
  29. package/dist/common/components/FabButton.js +59 -1
  30. package/dist/common/components/TranslatedLabel.js +60 -1
  31. package/dist/common/settings/Settings.js +196 -1
  32. package/dist/common/settings/SettingsBarIcons.js +61 -1
  33. package/dist/context/DashAutoAdminFormContext.js +15 -1
  34. package/dist/hooks/useAutoAdminLoadingStateMediator.js +36 -1
  35. package/dist/hooks/useAutoAdminTranslate.js +61 -1
  36. package/dist/hooks/useHash.js +24 -1
  37. package/dist/hooks/useLogger.js +20 -1
  38. package/dist/hooks/useRoutePathPattern.js +20 -1
  39. package/dist/hooks/useVirtualHash.js +28 -1
  40. package/dist/index.js +77 -3406
  41. package/dist/list/DashAutoListActions.js +57 -1
  42. package/dist/list/DashAutoListDatagridWrapper.js +68 -1
  43. package/dist/list/DashAutoListDefaultActionsWrapper.js +14 -1
  44. package/dist/list/DashAutoListFilterFormWithButton.js +80 -1
  45. package/dist/list/DashAutoListTopToolbar.js +180 -1
  46. package/dist/mui/AttributeToField.js +576 -1
  47. package/dist/mui/AttributeToInput.js +630 -1
  48. package/dist/mui/AutoAdminResizableDrawer.js +63 -1
  49. package/dist/mui/AutoDataGrid.js +120 -1
  50. package/dist/mui/AutoReferenceFormTab.js +53 -1
  51. package/dist/mui/AutoReferenceTab.js +46 -1
  52. package/dist/mui/AutoTabs.js +19 -1
  53. package/dist/mui/components/ExtendedPagination.js +34 -1
  54. package/dist/mui/components/ListStringField.js +25 -1
  55. package/dist/providers/DashAuthProvider.js +215 -1
  56. package/dist/providers/DashDataProvider.js +310 -1
  57. package/dist/providers/index.js +10 -1
  58. package/dist/react-admin.d.js +0 -0
  59. package/dist/toolbar/buttons/BottomToolbarButtons.js +65 -1
  60. package/dist/toolbar/buttons/DashResourceButton.js +181 -1
  61. package/dist/toolbar/buttons/ListButtons.js +80 -1
  62. package/dist/toolbar/buttons/ToolbarButtons.js +135 -1
  63. package/dist/types/ActionCallback.d.js +0 -0
  64. package/dist/utils/SimpleLogger.js +52 -1
  65. package/dist/utils/enumToChoices.js +5 -1
  66. package/dist/utils/evalActionPermission.js +11 -1
  67. package/dist/utils/groupByTabs.js +21 -1
  68. package/dist/utils/hashedGroupByTabs.js +12 -1
  69. package/dist/utils/invertMap.js +12 -1
  70. package/dist/utils/isClassComponent.js +7 -1
  71. package/dist/utils/isComponent.js +29 -1
  72. package/dist/utils/isEnum.js +5 -1
  73. package/dist/utils/isFC.js +8 -1
  74. package/dist/utils/replaceParams.js +9 -1
  75. package/dist/utils/validate.js +19 -1
  76. package/dist/wrappers/UserAction.js +60 -1
  77. package/dist/wrappers/index.js +4 -1
  78. package/package.json +134 -120
  79. package/src/DashAutoAdminComponentRegistry.tsx +75 -0
  80. package/src/DashAutoAdminForm.tsx +155 -0
  81. package/src/DashAutoAdminResizableDrawer.tsx +69 -0
  82. package/src/DashAutoAdminSaveButton.tsx +116 -0
  83. package/src/DashAutoCreate.tsx +118 -0
  84. package/src/DashAutoDrawer.tsx +288 -0
  85. package/src/DashAutoEdit.tsx +109 -0
  86. package/src/DashAutoFiltersGenerator.tsx +208 -0
  87. package/src/DashAutoFormGroups.tsx +146 -0
  88. package/src/DashAutoFormLayout.tsx.review +113 -0
  89. package/src/DashAutoFormMuiTabs.tsx +368 -0
  90. package/src/DashAutoFormTabs.tsx +177 -0
  91. package/src/DashAutoGroup.tsx +42 -0
  92. package/src/DashAutoLayout.tsx +57 -0
  93. package/src/DashAutoList.tsx +237 -0
  94. package/src/DashAutoPostFilterForm.tsx +35 -0
  95. package/src/DashAutoReferenceTab.tsx +9 -0
  96. package/src/DashAutoResource.tsx +85 -0
  97. package/src/DashAutoResourceLayout.tsx +50 -0
  98. package/src/DashAutoShow.tsx +200 -0
  99. package/src/DashAutoTabbedForm.review.tsx +262 -0
  100. package/src/DashAutoTabbedForm.tsx +324 -0
  101. package/src/DashAutoTabs.tsx +19 -0
  102. package/src/DashFilterWrapper.tsx +43 -0
  103. package/src/DashRedirect.tsx +46 -0
  104. package/src/TabbedLayout.tsx +29 -0
  105. package/src/common/DashAutoTitle.tsx +24 -0
  106. package/src/common/components/FabButton.tsx +40 -0
  107. package/src/common/components/TranslatedLabel.tsx +81 -0
  108. package/src/common/settings/Settings.tsx +236 -0
  109. package/src/common/settings/SettingsBarIcons.tsx +72 -0
  110. package/src/context/DashAutoAdminFormContext.tsx +31 -0
  111. package/src/hooks/useAutoAdminLoadingStateMediator.tsx +42 -0
  112. package/src/hooks/useAutoAdminTranslate.tsx +106 -0
  113. package/src/hooks/useHash.tsx +27 -0
  114. package/src/hooks/useLogger.tsx +23 -0
  115. package/src/hooks/useRoutePathPattern.tsx +24 -0
  116. package/src/hooks/useVirtualHash.tsx +34 -0
  117. package/src/index.ts +85 -0
  118. package/src/interfaces/ICustomResourceSubComponent.ts +11 -0
  119. package/src/interfaces/IDashApplicationLayoutMainAction.ts +37 -0
  120. package/src/interfaces/IDashApplicationLayoutMenuItem.ts +24 -0
  121. package/src/interfaces/IDashAutoAdminAttribute.ts +104 -0
  122. package/src/interfaces/IDashAutoAdminCustomFieldComponent.ts +18 -0
  123. package/src/interfaces/IDashAutoAdminFormOptions.ts +22 -0
  124. package/src/interfaces/IDashAutoAdminListActions.ts +13 -0
  125. package/src/interfaces/IDashAutoAdminReference.ts +16 -0
  126. package/src/interfaces/IDashAutoAdminResourceConfig.ts +360 -0
  127. package/src/interfaces/IDashAutoForm.ts +24 -0
  128. package/src/interfaces/IDashAutoGridButton.ts +35 -0
  129. package/src/interfaces/IDashAutoShow.ts +12 -0
  130. package/src/interfaces/IGroupExtraData.ts +8 -0
  131. package/src/interfaces/IRecord.ts +7 -0
  132. package/src/interfaces/IReferenceFilter.ts +55 -0
  133. package/src/interfaces/IResourceComponent.ts +8 -0
  134. package/src/interfaces/IToolbarButton.ts +11 -0
  135. package/src/list/DashAutoListActions.tsx +88 -0
  136. package/src/list/DashAutoListDatagridWrapper.tsx +74 -0
  137. package/src/list/DashAutoListDefaultActionsWrapper.tsx +31 -0
  138. package/src/list/DashAutoListFilterFormWithButton.tsx +93 -0
  139. package/src/list/DashAutoListTopToolbar.tsx +240 -0
  140. package/src/mui/AttributeToField.tsx +657 -0
  141. package/src/mui/AttributeToInput.tsx +728 -0
  142. package/src/mui/AutoAdminResizableDrawer.tsx +69 -0
  143. package/src/mui/AutoDataGrid.tsx +127 -0
  144. package/src/mui/AutoReferenceFormTab.tsx +51 -0
  145. package/src/mui/AutoReferenceTab.tsx +45 -0
  146. package/src/mui/AutoTabs.tsx +32 -0
  147. package/src/mui/components/ExtendedPagination.tsx +23 -0
  148. package/src/mui/components/ListStringField.tsx +32 -0
  149. package/src/providers/DashAuthProvider.ts +341 -0
  150. package/src/providers/DashDataProvider.ts +466 -0
  151. package/src/providers/index.ts +17 -0
  152. package/src/toolbar/buttons/BottomToolbarButtons.tsx +59 -0
  153. package/src/toolbar/buttons/DashResourceButton.tsx +223 -0
  154. package/src/toolbar/buttons/ListButtons.tsx +137 -0
  155. package/src/toolbar/buttons/ToolbarButtons.tsx +186 -0
  156. package/src/utils/SimpleLogger.tsx +46 -0
  157. package/src/utils/enumToChoices.tsx +3 -0
  158. package/src/utils/evalActionPermission.tsx +14 -0
  159. package/src/utils/groupByTabs.tsx +23 -0
  160. package/src/utils/hashedGroupByTabs.tsx +16 -0
  161. package/src/utils/invertMap.tsx +10 -0
  162. package/src/utils/isClassComponent.tsx +9 -0
  163. package/src/utils/isComponent.tsx +45 -0
  164. package/src/utils/isEnum.tsx +3 -0
  165. package/src/utils/isFC.tsx +6 -0
  166. package/src/utils/replaceParams.tsx +6 -0
  167. package/src/utils/validate.tsx +24 -0
  168. package/src/wrappers/UserAction.tsx +67 -0
  169. package/src/wrappers/index.tsx +1 -0
  170. /package/{dist → src}/DashAutoAdminSaveButton.tsx.bkup +0 -0
  171. /package/{dist/DashAutoFormLayout.tsx.review → src/DashAutoFormLayout.tsx} +0 -0
  172. /package/{dist → src}/DashAutoFormTabs.review +0 -0
  173. /package/{dist → src}/DashAutoFormTabs.tsx.formcontext.wip +0 -0
  174. /package/{dist → src}/mui/AttributeToField.tsx.review +0 -0
  175. /package/{dist → src}/mui/AttributeToInput.tsx.review +0 -0
  176. /package/{dist → src}/react-admin.d.ts +0 -0
  177. /package/{dist → src}/types/ActionCallback.d.ts +0 -0
@@ -0,0 +1,69 @@
1
+ import { Drawer, DrawerProps } from '@mui/material';
2
+ import React from 'react';
3
+
4
+ export interface IResizableDrawer extends DrawerProps {
5
+ defaultWidth: number;
6
+ }
7
+
8
+ export const AutoAdminResizableDrawerContext = React.createContext(400);
9
+
10
+ /* TODO: W.I.P Resizable Drawer is a Work in Progress */
11
+ export const AutoAdminResizableDrawer: React.FC<IResizableDrawer> = ({
12
+ children,
13
+ defaultWidth,
14
+ ...props
15
+ }) => {
16
+ //const classes = useStyles();
17
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
18
+ const [drawerWidth, setDrawerWidth] = React.useState(defaultWidth);
19
+
20
+ /*
21
+
22
+ const handleMouseMove = useCallback((e) => {
23
+ console.log('Mouse move');
24
+ //const newWidth = e.clientX - (window.innerWidth - document.body.offsetLeft - document.body.offsetWidth );
25
+ //const newWidth = e.clientX + (window.innerWidth - document.body.offsetLeft - document.body.offsetWidth );
26
+ const newWidth = window.innerWidth - e.clientX;
27
+ //if (newWidth > minDrawerWidth && newWidth < maxDrawerWidth) {
28
+ setDrawerWidth(newWidth);
29
+ //}
30
+ if (e.stopPropagation) e.stopPropagation();
31
+ if (e.preventDefault) e.preventDefault();
32
+ e.cancelBubble = true;
33
+ e.returnValue = false;
34
+ }, []);
35
+
36
+ const handleMouseUp = () => {
37
+ console.log('Mouse up');
38
+ document.removeEventListener('mouseup', handleMouseUp, true);
39
+ document.removeEventListener('mousemove', handleMouseMove, true);
40
+ };
41
+
42
+ const handleMouseDown = (e) => {
43
+ console.log('Mouse down');
44
+ document.addEventListener('mouseup', handleMouseUp, true);
45
+ document.addEventListener('mousemove', handleMouseMove, true);
46
+ };
47
+ */
48
+
49
+ const Dragger = () => {
50
+ // TODO:
51
+ // <div onMouseDown={(e) => handleMouseDown(e) } />
52
+ return <></>;
53
+ };
54
+
55
+ return (
56
+ <Drawer
57
+ /*className={classes.drawer}*/
58
+ PaperProps={{ style: { width: drawerWidth } }}
59
+ //sx={{ zIndex: 100, width: drawerWidth }}
60
+ {...props}
61
+ >
62
+ <AutoAdminResizableDrawerContext.Provider value={drawerWidth}>
63
+ <Dragger />
64
+
65
+ {children}
66
+ </AutoAdminResizableDrawerContext.Provider>
67
+ </Drawer>
68
+ );
69
+ };
@@ -0,0 +1,127 @@
1
+ import React, { useMemo, memo, useEffect } from 'react';
2
+
3
+ import {
4
+ TextField,
5
+ Datagrid,
6
+ FunctionField,
7
+ } from 'react-admin';
8
+
9
+ import IDashAutoAdminAttribute from '../interfaces/IDashAutoAdminAttribute';
10
+ import IDashAutoAdminResourceConfig from '../interfaces/IDashAutoAdminResourceConfig';
11
+
12
+ import { AttributeToField } from './AttributeToField';
13
+ import { TableContainer } from '@mui/material';
14
+ import { ListDeleteButton, ListEditButton, ListViewButton } from '../toolbar/buttons/ListButtons';
15
+
16
+ interface AutoDataGridProps {
17
+ /** Schema,(optional) resolves from resourceConfig, but in some cases without schema could work, not tested. */
18
+ schema?: IDashAutoAdminAttribute[];
19
+ /** BulkActions,(optional) resolves from resourceConfig, but in some cases without schema could work, not tested. */
20
+ resourceConfig?: IDashAutoAdminResourceConfig;
21
+ className?: string;
22
+ bulkActions?: React.ReactNode;
23
+ locale?: string;
24
+ }
25
+
26
+ export type IAutoDataGrid = AutoDataGridProps;
27
+
28
+ // Memoize the buttons to prevent unnecessary re-renders
29
+ const MemoizedListViewButton = memo(ListViewButton);
30
+ const MemoizedListEditButton = memo(ListEditButton);
31
+ const MemoizedListDeleteButton = memo(ListDeleteButton);
32
+
33
+ const AutoDataGrid: React.FC<IAutoDataGrid> = ({
34
+ resourceConfig,
35
+ schema,
36
+ locale,
37
+ ...dataGridProps
38
+ }) => {
39
+ const _locale = locale || resourceConfig?.locale;
40
+ const _schema: IDashAutoAdminAttribute[] = resourceConfig?.schema || schema;
41
+
42
+ if (!_schema || !_schema.filter)
43
+ throw new Error(
44
+ 'Schema must be present as prop or as an attribute of resourceConfig object, and must be iterable',
45
+ );
46
+
47
+ // Memoize schema processing
48
+ const schemaIncludesId = useMemo(() =>
49
+ _schema.filter((attribute) => attribute.attribute === 'id').length !== 0
50
+ , [_schema]);
51
+
52
+ // Memoize processed dataGridProps
53
+ const processedDataGridProps = useMemo(() => ({
54
+ //...{selectedIds:[]},
55
+ ...resourceConfig.dataGridProps,
56
+ ...dataGridProps,
57
+ }), [resourceConfig.dataGridProps, dataGridProps]);
58
+
59
+ // Memoize the filtered schema for list display
60
+ const filteredSchema = useMemo(() =>
61
+ _schema.filter((attribute) => attribute.inList !== false)
62
+ , [_schema, _locale]);
63
+
64
+ // Default grid wrapper component
65
+ const DefaultGridWrapper = memo((props: { children: React.ReactNode, className?: string, gridWrapperProps?: any }) => {
66
+ const { children, className, gridWrapperProps } = props;
67
+ return (
68
+ <TableContainer
69
+ sx={{ mt: 1 }}
70
+ className={'dash-datagrid-wrapper '+(className || '')}
71
+ {...gridWrapperProps}
72
+ >
73
+ {children}
74
+ </TableContainer>
75
+ );
76
+ });
77
+
78
+ const DataGridWrapper = resourceConfig.dataGridWrapper || DefaultGridWrapper;
79
+ const DataGridRootComponent: typeof Datagrid =
80
+ resourceConfig.dataGridRootComponent || Datagrid;
81
+
82
+ // Memoize the custom list buttons
83
+ const customListButtons = useMemo(() => {
84
+ if (!resourceConfig?.customListButtons) return null;
85
+
86
+ return resourceConfig.customListButtons.map((customButtonConfig, idx) => (
87
+ <customButtonConfig.component
88
+ key={'list_custom_buttton' + idx}
89
+ {...customButtonConfig.props}
90
+ />
91
+ ));
92
+ }, [resourceConfig?.customListButtons]);
93
+
94
+
95
+
96
+ return <DataGridWrapper className={resourceConfig?.dataGridProps?.stickyHeader ? 'dash-sticky-header' : ''}>
97
+ <DataGridRootComponent {...processedDataGridProps}>
98
+ {!schemaIncludesId && !(resourceConfig.hideSchemaId === true) && (
99
+ <FunctionField
100
+ key={'default_id_field_0'}
101
+ source='id'
102
+ sortable={true}
103
+ render={(record: any) => {
104
+ const val = record?.id;
105
+ // If not numeric, slice last 6 chars
106
+ if (val && isNaN(Number(val))) {
107
+ return String(val).slice(-6);
108
+ }
109
+ return val;
110
+ }}
111
+ />
112
+ )}
113
+ {filteredSchema.map((attribute, idx) =>
114
+ AttributeToField('list', resourceConfig, attribute, idx)
115
+ )}
116
+ <MemoizedListViewButton key={'list_view_btn'} resourceConfig={resourceConfig} />
117
+ <MemoizedListEditButton key={'list_edit_btn'} resourceConfig={resourceConfig} />
118
+ <MemoizedListDeleteButton key={'list_delete_btn'} resourceConfig={resourceConfig} />
119
+ {customListButtons}
120
+ </DataGridRootComponent>
121
+ </DataGridWrapper>
122
+
123
+ };
124
+
125
+ // Export a memoized version of the component
126
+ //export default memo(AutoDataGrid);
127
+ export default AutoDataGrid
@@ -0,0 +1,51 @@
1
+ import { FormTab, ReferenceManyField, ReferenceArrayField } from 'react-admin';
2
+ import { IDashAutoAdminReference } from '../interfaces/IDashAutoAdminReference';
3
+
4
+ import AutoDataGrid from './AutoDataGrid';
5
+ import ExtendedPagination from './components/ExtendedPagination';
6
+
7
+ const AutoReferenceFormTab = (reference: IDashAutoAdminReference) => {
8
+ const type = reference.type ? reference.type : 'ReferenceManyField';
9
+
10
+ return (
11
+ <FormTab
12
+ key={reference.reference}
13
+ label={reference.tab || reference.reference}
14
+ >
15
+ {type === 'ReferenceManyField' && (
16
+ <ReferenceManyField
17
+ fullWidth
18
+ reference={reference.reference}
19
+ //target={[...reference.target]}
20
+ target={reference.target}
21
+ //addLabel={false}
22
+ pagination={<ExtendedPagination />}
23
+ >
24
+ {/* TODO: replace AutoDataGrid to DashAutoList */}
25
+ <AutoDataGrid
26
+ schema={reference.schema}
27
+ />
28
+ </ReferenceManyField>
29
+ )}
30
+
31
+ {type === 'ReferenceArrayField' && (
32
+ <ReferenceArrayField
33
+ fullWidth
34
+ reference={reference.reference}
35
+ //target={[...reference.target]}
36
+ source={reference.target}
37
+ //addLabel={false}
38
+ pagination={<ExtendedPagination />}
39
+ >
40
+ {' '}
41
+ {/* TODO replace AutoDataGrid to DashAutoList */}
42
+ <AutoDataGrid
43
+ schema={reference.schema} /*BulkActions={reference.BulkActions}*/
44
+ />
45
+ </ReferenceArrayField>
46
+ )}
47
+ </FormTab>
48
+ );
49
+ };
50
+
51
+ export default AutoReferenceFormTab;
@@ -0,0 +1,45 @@
1
+ import { Tab, ReferenceManyField, ReferenceArrayField } from 'react-admin';
2
+ import AutoDataGrid from './AutoDataGrid';
3
+ import ExtendedPagination from './components/ExtendedPagination';
4
+ import { IDashAutoAdminReference } from '../interfaces/IDashAutoAdminReference';
5
+
6
+ export const AutoReferenceTab = (reference: IDashAutoAdminReference) => {
7
+ const type = reference.type ? reference.type : 'ReferenceManyField';
8
+ return (
9
+ <Tab key={reference.reference} label={reference.tab || reference.reference}>
10
+ {type === 'ReferenceManyField' && (
11
+ <ReferenceManyField
12
+ fullWidth
13
+ reference={reference.reference}
14
+ //target={[...reference.target]}
15
+ target={reference.target}
16
+ //addLabel={false}
17
+ pagination={<ExtendedPagination />}
18
+ >
19
+ <AutoDataGrid
20
+ schema={reference?.schema}
21
+ bulkActions={reference?.BulkActions}
22
+ />
23
+ </ReferenceManyField>
24
+ )}
25
+
26
+ {type === 'ReferenceArrayField' && (
27
+ <ReferenceArrayField
28
+ fullWidth
29
+ reference={reference.reference}
30
+ //target={[...reference.target]}
31
+ source={reference.target}
32
+ //addLabel={false}
33
+ pagination={<ExtendedPagination />}
34
+ >
35
+ <AutoDataGrid
36
+ schema={reference.schema}
37
+ bulkActions={reference?.BulkActions}
38
+ />
39
+ </ReferenceArrayField>
40
+ )}
41
+ </Tab>
42
+ );
43
+ };
44
+
45
+ export default AutoReferenceTab;
@@ -0,0 +1,32 @@
1
+ import { Tab, useTranslate } from 'react-admin';
2
+ import { AttributeToField } from './AttributeToField';
3
+ import IDashAutoAdminAttribute from '../interfaces/IDashAutoAdminAttribute';
4
+ import IDashAutoAdminFormOptions from '../interfaces/IDashAutoAdminFormOptions';
5
+ import IDashAutoAdminResourceConfig from '../interfaces/IDashAutoAdminResourceConfig';
6
+ import groupByTabs from '../utils/groupByTabs';
7
+ //import { TabbedShowLayout } from 'react-admin';
8
+
9
+ export const AutoTabs = (
10
+ resourceConfig: IDashAutoAdminResourceConfig,
11
+ schema: IDashAutoAdminAttribute[],
12
+ options?: IDashAutoAdminFormOptions,
13
+ ) => {
14
+ const translate = useTranslate();
15
+ return groupByTabs(schema).map((groupOfAttributes) => {
16
+ const label = groupOfAttributes[0].tab || options?.label || '';
17
+ const translatedLabel = translate(`dash-auto-admin-tabs.${label}`, { _: label });
18
+ // console.log("TAB", label);
19
+ return (
20
+ <Tab key={'tab_' + label} label={translatedLabel}>
21
+
22
+ {groupOfAttributes
23
+ .filter((attribute) => attribute?.inShow !== false)
24
+ .map((attribute, idx) =>
25
+ AttributeToField('view', resourceConfig, attribute, idx, options),
26
+ )}
27
+ </Tab>
28
+ );
29
+ });
30
+ };
31
+
32
+ export default AutoTabs;
@@ -0,0 +1,23 @@
1
+ import React, { FC, useContext } from 'react';
2
+
3
+ import { Pagination, ListContext } from 'react-admin';
4
+ import { PaginationProps } from 'react-admin';
5
+
6
+ // Safe hook that doesn't throw when context is missing
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ const useSafeListContext = (): any => {
9
+ const context = useContext(ListContext);
10
+ return context ?? null;
11
+ };
12
+
13
+ const ExtendedPagination:FC<PaginationProps> = (props) => {
14
+ const list = useSafeListContext();
15
+ return list && list.total > list.perPage ? (
16
+ // @ts-ignore - pageSizeOptions prop compatibility
17
+ <Pagination pageSizeOptions={[25, 50, 100, 250, 500, 1000]} {...props} />
18
+ ) : (
19
+ <></>
20
+ );
21
+ };
22
+
23
+ export default ExtendedPagination;
@@ -0,0 +1,32 @@
1
+ import { Chip } from '@mui/material';
2
+
3
+ import React from 'react';
4
+ import invertMap from '../../utils/invertMap';
5
+
6
+ const ListStringsField = ({
7
+ record,
8
+ source,
9
+ map,
10
+ }: {
11
+ record?: any;
12
+ source: string;
13
+ label: string;
14
+ map?: any;
15
+ }) => {
16
+ const invertedMap = invertMap(map);
17
+ return (
18
+ <>
19
+ {record[source].map((item: string) => [
20
+ <Chip
21
+ key={item}
22
+ label={invertedMap && invertedMap[item] ? invertedMap[item] : item}
23
+ />,
24
+ <> </>,
25
+ ])}
26
+ </>
27
+ );
28
+ };
29
+
30
+ ListStringsField.defaultProps = { addLabel: true };
31
+
32
+ export default ListStringsField;