@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.
- package/dist/DashAutoAdminComponentRegistry.js +64 -1
- package/dist/DashAutoAdminForm.js +137 -1
- package/dist/DashAutoAdminResizableDrawer.js +63 -1
- package/dist/DashAutoAdminSaveButton.js +57 -1
- package/dist/DashAutoCreate.js +102 -1
- package/dist/DashAutoDrawer.js +256 -1
- package/dist/DashAutoEdit.js +99 -1
- package/dist/DashAutoFiltersGenerator.js +193 -1
- package/dist/DashAutoFormGroups.js +118 -1
- package/dist/DashAutoFormLayout.js +68 -1
- package/dist/DashAutoFormMuiTabs.js +291 -1
- package/dist/DashAutoFormTabs.js +132 -1
- package/dist/DashAutoGroup.js +27 -1
- package/dist/DashAutoLayout.js +31 -1
- package/dist/DashAutoList.js +218 -1
- package/dist/DashAutoPostFilterForm.js +47 -1
- package/dist/DashAutoReferenceTab.js +10 -1
- package/dist/DashAutoResource.js +77 -1
- package/dist/DashAutoResourceLayout.js +16 -1
- package/dist/DashAutoShow.js +195 -1
- package/dist/DashAutoTabbedForm.js +244 -1
- package/dist/DashAutoTabbedForm.review.js +221 -1
- package/dist/DashAutoTabs.js +11 -1
- package/dist/DashFilterWrapper.js +62 -1
- package/dist/DashRedirect.js +56 -1
- package/dist/TabbedLayout.js +38 -1
- package/dist/common/DashAutoTitle.js +33 -1
- package/dist/common/components/FabButton.js +59 -1
- package/dist/common/components/TranslatedLabel.js +60 -1
- package/dist/common/settings/Settings.js +196 -1
- package/dist/common/settings/SettingsBarIcons.js +61 -1
- package/dist/context/DashAutoAdminFormContext.js +15 -1
- package/dist/hooks/useAutoAdminLoadingStateMediator.js +36 -1
- package/dist/hooks/useAutoAdminTranslate.js +61 -1
- package/dist/hooks/useHash.js +24 -1
- package/dist/hooks/useLogger.js +20 -1
- package/dist/hooks/useRoutePathPattern.js +20 -1
- package/dist/hooks/useVirtualHash.js +28 -1
- package/dist/index.js +77 -3406
- package/dist/list/DashAutoListActions.js +57 -1
- package/dist/list/DashAutoListDatagridWrapper.js +68 -1
- package/dist/list/DashAutoListDefaultActionsWrapper.js +14 -1
- package/dist/list/DashAutoListFilterFormWithButton.js +80 -1
- package/dist/list/DashAutoListTopToolbar.js +180 -1
- package/dist/mui/AttributeToField.js +576 -1
- package/dist/mui/AttributeToInput.js +630 -1
- package/dist/mui/AutoAdminResizableDrawer.js +63 -1
- package/dist/mui/AutoDataGrid.js +120 -1
- package/dist/mui/AutoReferenceFormTab.js +53 -1
- package/dist/mui/AutoReferenceTab.js +46 -1
- package/dist/mui/AutoTabs.js +19 -1
- package/dist/mui/components/ExtendedPagination.js +34 -1
- package/dist/mui/components/ListStringField.js +25 -1
- package/dist/providers/DashAuthProvider.js +215 -1
- package/dist/providers/DashDataProvider.js +310 -1
- package/dist/providers/index.js +10 -1
- package/dist/react-admin.d.js +0 -0
- package/dist/toolbar/buttons/BottomToolbarButtons.js +65 -1
- package/dist/toolbar/buttons/DashResourceButton.js +181 -1
- package/dist/toolbar/buttons/ListButtons.js +80 -1
- package/dist/toolbar/buttons/ToolbarButtons.js +135 -1
- package/dist/types/ActionCallback.d.js +0 -0
- package/dist/utils/SimpleLogger.js +52 -1
- package/dist/utils/enumToChoices.js +5 -1
- package/dist/utils/evalActionPermission.js +11 -1
- package/dist/utils/groupByTabs.js +21 -1
- package/dist/utils/hashedGroupByTabs.js +12 -1
- package/dist/utils/invertMap.js +12 -1
- package/dist/utils/isClassComponent.js +7 -1
- package/dist/utils/isComponent.js +29 -1
- package/dist/utils/isEnum.js +5 -1
- package/dist/utils/isFC.js +8 -1
- package/dist/utils/replaceParams.js +9 -1
- package/dist/utils/validate.js +19 -1
- package/dist/wrappers/UserAction.js +60 -1
- package/dist/wrappers/index.js +4 -1
- package/package.json +135 -120
- package/src/DashAutoAdminComponentRegistry.tsx +75 -0
- package/src/DashAutoAdminForm.tsx +155 -0
- package/src/DashAutoAdminResizableDrawer.tsx +69 -0
- package/src/DashAutoAdminSaveButton.tsx +116 -0
- package/src/DashAutoCreate.tsx +118 -0
- package/src/DashAutoDrawer.tsx +288 -0
- package/src/DashAutoEdit.tsx +109 -0
- package/src/DashAutoFiltersGenerator.tsx +208 -0
- package/src/DashAutoFormGroups.tsx +146 -0
- package/src/DashAutoFormLayout.tsx.review +113 -0
- package/src/DashAutoFormMuiTabs.tsx +368 -0
- package/src/DashAutoFormTabs.tsx +177 -0
- package/src/DashAutoGroup.tsx +42 -0
- package/src/DashAutoLayout.tsx +57 -0
- package/src/DashAutoList.tsx +237 -0
- package/src/DashAutoPostFilterForm.tsx +35 -0
- package/src/DashAutoReferenceTab.tsx +9 -0
- package/src/DashAutoResource.tsx +85 -0
- package/src/DashAutoResourceLayout.tsx +50 -0
- package/src/DashAutoShow.tsx +200 -0
- package/src/DashAutoTabbedForm.review.tsx +262 -0
- package/src/DashAutoTabbedForm.tsx +324 -0
- package/src/DashAutoTabs.tsx +19 -0
- package/src/DashFilterWrapper.tsx +43 -0
- package/src/DashRedirect.tsx +46 -0
- package/src/TabbedLayout.tsx +29 -0
- package/src/common/DashAutoTitle.tsx +24 -0
- package/src/common/components/FabButton.tsx +40 -0
- package/src/common/components/TranslatedLabel.tsx +81 -0
- package/src/common/settings/Settings.tsx +236 -0
- package/src/common/settings/SettingsBarIcons.tsx +72 -0
- package/src/context/DashAutoAdminFormContext.tsx +31 -0
- package/src/hooks/useAutoAdminLoadingStateMediator.tsx +42 -0
- package/src/hooks/useAutoAdminTranslate.tsx +106 -0
- package/src/hooks/useHash.tsx +27 -0
- package/src/hooks/useLogger.tsx +23 -0
- package/src/hooks/useRoutePathPattern.tsx +24 -0
- package/src/hooks/useVirtualHash.tsx +34 -0
- package/src/index.ts +85 -0
- package/src/interfaces/ICustomResourceSubComponent.ts +11 -0
- package/src/interfaces/IDashApplicationLayoutMainAction.ts +37 -0
- package/src/interfaces/IDashApplicationLayoutMenuItem.ts +24 -0
- package/src/interfaces/IDashAutoAdminAttribute.ts +104 -0
- package/src/interfaces/IDashAutoAdminCustomFieldComponent.ts +18 -0
- package/src/interfaces/IDashAutoAdminFormOptions.ts +22 -0
- package/src/interfaces/IDashAutoAdminListActions.ts +13 -0
- package/src/interfaces/IDashAutoAdminReference.ts +16 -0
- package/src/interfaces/IDashAutoAdminResourceConfig.ts +360 -0
- package/src/interfaces/IDashAutoForm.ts +24 -0
- package/src/interfaces/IDashAutoGridButton.ts +35 -0
- package/src/interfaces/IDashAutoShow.ts +12 -0
- package/src/interfaces/IGroupExtraData.ts +8 -0
- package/src/interfaces/IRecord.ts +7 -0
- package/src/interfaces/IReferenceFilter.ts +55 -0
- package/src/interfaces/IResourceComponent.ts +8 -0
- package/src/interfaces/IToolbarButton.ts +11 -0
- package/src/list/DashAutoListActions.tsx +88 -0
- package/src/list/DashAutoListDatagridWrapper.tsx +74 -0
- package/src/list/DashAutoListDefaultActionsWrapper.tsx +31 -0
- package/src/list/DashAutoListFilterFormWithButton.tsx +93 -0
- package/src/list/DashAutoListTopToolbar.tsx +240 -0
- package/src/mui/AttributeToField.tsx +657 -0
- package/src/mui/AttributeToInput.tsx +728 -0
- package/src/mui/AutoAdminResizableDrawer.tsx +69 -0
- package/src/mui/AutoDataGrid.tsx +127 -0
- package/src/mui/AutoReferenceFormTab.tsx +51 -0
- package/src/mui/AutoReferenceTab.tsx +45 -0
- package/src/mui/AutoTabs.tsx +32 -0
- package/src/mui/components/ExtendedPagination.tsx +23 -0
- package/src/mui/components/ListStringField.tsx +32 -0
- package/src/providers/DashAuthProvider.ts +341 -0
- package/src/providers/DashDataProvider.ts +466 -0
- package/src/providers/index.ts +17 -0
- package/src/toolbar/buttons/BottomToolbarButtons.tsx +59 -0
- package/src/toolbar/buttons/DashResourceButton.tsx +223 -0
- package/src/toolbar/buttons/ListButtons.tsx +137 -0
- package/src/toolbar/buttons/ToolbarButtons.tsx +186 -0
- package/src/utils/SimpleLogger.tsx +46 -0
- package/src/utils/enumToChoices.tsx +3 -0
- package/src/utils/evalActionPermission.tsx +14 -0
- package/src/utils/groupByTabs.tsx +23 -0
- package/src/utils/hashedGroupByTabs.tsx +16 -0
- package/src/utils/invertMap.tsx +10 -0
- package/src/utils/isClassComponent.tsx +9 -0
- package/src/utils/isComponent.tsx +45 -0
- package/src/utils/isEnum.tsx +3 -0
- package/src/utils/isFC.tsx +6 -0
- package/src/utils/replaceParams.tsx +6 -0
- package/src/utils/validate.tsx +24 -0
- package/src/wrappers/UserAction.tsx +67 -0
- package/src/wrappers/index.tsx +1 -0
- /package/{dist → src}/DashAutoAdminSaveButton.tsx.bkup +0 -0
- /package/{dist/DashAutoFormLayout.tsx.review → src/DashAutoFormLayout.tsx} +0 -0
- /package/{dist → src}/DashAutoFormTabs.review +0 -0
- /package/{dist → src}/DashAutoFormTabs.tsx.formcontext.wip +0 -0
- /package/{dist → src}/mui/AttributeToField.tsx.review +0 -0
- /package/{dist → src}/mui/AttributeToInput.tsx.review +0 -0
- /package/{dist → src}/react-admin.d.ts +0 -0
- /package/{dist → src}/types/ActionCallback.d.ts +0 -0
|
@@ -1 +1,68 @@
|
|
|
1
|
-
import{Fragment
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DashAutoFormTabs } from ".";
|
|
3
|
+
import { default as AttributeToInput } from "./mui/AttributeToInput";
|
|
4
|
+
import hashedGroupByTabs from "./utils/hashedGroupByTabs";
|
|
5
|
+
const DashAutoFormLayout = ({
|
|
6
|
+
schema,
|
|
7
|
+
resourceConfig,
|
|
8
|
+
options
|
|
9
|
+
}) => {
|
|
10
|
+
const groupedTabs = hashedGroupByTabs(schema || []);
|
|
11
|
+
const renderEdit = (tab) => {
|
|
12
|
+
const groupedAttributesByTab = groupedTabs[tab] ? groupedTabs[tab] : [];
|
|
13
|
+
return groupedAttributesByTab.filter((attribute) => (attribute == null ? void 0 : attribute.inEdit) !== false).map(
|
|
14
|
+
(attribute, idx) => AttributeToInput("edit", resourceConfig, attribute, idx, options)
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
const renderCreate = (tab) => {
|
|
18
|
+
const groupedAttributesByTab = groupedTabs[tab] ? groupedTabs[tab] : [];
|
|
19
|
+
return groupedAttributesByTab.filter((attribute) => (attribute == null ? void 0 : attribute.inCreate) !== false).map(
|
|
20
|
+
(attribute, idx) => AttributeToInput("create", resourceConfig, attribute, idx, options)
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
switch (options.mode) {
|
|
24
|
+
case "create":
|
|
25
|
+
if (!(resourceConfig == null ? void 0 : resourceConfig.createLayout) || typeof resourceConfig.createLayout !== "function") {
|
|
26
|
+
console.warn(
|
|
27
|
+
"\u26A0\uFE0F createLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs"
|
|
28
|
+
);
|
|
29
|
+
return DashAutoFormTabs({
|
|
30
|
+
schema,
|
|
31
|
+
resourceConfig,
|
|
32
|
+
options
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return resourceConfig.createLayout(renderCreate);
|
|
36
|
+
case "edit":
|
|
37
|
+
if (!(resourceConfig == null ? void 0 : resourceConfig.editLayout) || typeof resourceConfig.editLayout !== "function") {
|
|
38
|
+
console.warn(
|
|
39
|
+
"\u26A0\uFE0F createLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs"
|
|
40
|
+
);
|
|
41
|
+
return DashAutoFormTabs({
|
|
42
|
+
schema,
|
|
43
|
+
resourceConfig,
|
|
44
|
+
options
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return resourceConfig.editLayout(renderEdit);
|
|
48
|
+
/*case "view":
|
|
49
|
+
case "list":
|
|
50
|
+
if (!resource.showLayout || typeof resource.showLayout !== "function") {
|
|
51
|
+
console.error("showLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs");
|
|
52
|
+
return AutoFormTabs({
|
|
53
|
+
schema: schema,
|
|
54
|
+
resource: resource,
|
|
55
|
+
options: { mode: options.mode },
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return resource.createLayout(renderShow)
|
|
60
|
+
*/
|
|
61
|
+
default:
|
|
62
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "mode not allowed" });
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var DashAutoFormLayout_default = DashAutoFormLayout;
|
|
66
|
+
export {
|
|
67
|
+
DashAutoFormLayout_default as default
|
|
68
|
+
};
|
|
@@ -1 +1,291 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { FormTab } from "react-admin";
|
|
22
|
+
import { Tab, Tabs, Box } from "@mui/material";
|
|
23
|
+
import groupByTabs from "./utils/groupByTabs";
|
|
24
|
+
import AttributeToInput from "./mui/AttributeToInput";
|
|
25
|
+
import { useDispatch } from "react-redux";
|
|
26
|
+
import { useEffect, useState } from "react";
|
|
27
|
+
const CreateFormTabs = ({ schema, resourceConfig, options, isDrawer }) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const dispatch = useDispatch();
|
|
30
|
+
const [value, setValue] = useState(0);
|
|
31
|
+
const handleChange = (event) => {
|
|
32
|
+
const { name, value: value2, type } = event.target;
|
|
33
|
+
let payloadValue;
|
|
34
|
+
switch (type) {
|
|
35
|
+
case "checkbox":
|
|
36
|
+
payloadValue = event.target.checked;
|
|
37
|
+
break;
|
|
38
|
+
case "select":
|
|
39
|
+
payloadValue = value2;
|
|
40
|
+
break;
|
|
41
|
+
case "text":
|
|
42
|
+
case "number":
|
|
43
|
+
case "email":
|
|
44
|
+
payloadValue = value2;
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
payloadValue = value2;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
console.log("DashAutoFormMuiTabs: dispatch method deprecated");
|
|
51
|
+
};
|
|
52
|
+
const handleTabChange = (event, newValue) => {
|
|
53
|
+
setValue(newValue);
|
|
54
|
+
};
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
return () => {
|
|
57
|
+
console.log("DashAutoFormMuiTabs: dispatch method deprecated");
|
|
58
|
+
};
|
|
59
|
+
}, [dispatch]);
|
|
60
|
+
const tabGroups = groupByTabs(schema);
|
|
61
|
+
if (((_a = options == null ? void 0 : options.meta) == null ? void 0 : _a.tabs) === "mui") {
|
|
62
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { width: "100%" }, children: [
|
|
63
|
+
/* @__PURE__ */ jsx(Box, { sx: { borderBottom: 1, borderColor: "divider" }, children: /* @__PURE__ */ jsx(Tabs, { value, onChange: handleTabChange, children: tabGroups.map((group, idx) => /* @__PURE__ */ jsx(Tab, { label: group[0].tab || (options == null ? void 0 : options.label) || "" }, `tab-${group[0].tab || idx}`)) }) }),
|
|
64
|
+
tabGroups.map((groupOfAttributes, idx) => {
|
|
65
|
+
let grouppedAttributes = groupOfAttributes.filter(
|
|
66
|
+
(attribute) => (attribute == null ? void 0 : attribute.inCreate) !== false
|
|
67
|
+
);
|
|
68
|
+
if (isDrawer) {
|
|
69
|
+
grouppedAttributes = grouppedAttributes.filter(
|
|
70
|
+
(attribute) => (attribute == null ? void 0 : attribute.inDrawer) !== false
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
role: "tabpanel",
|
|
77
|
+
hidden: value !== idx,
|
|
78
|
+
style: { padding: "20px 0" },
|
|
79
|
+
children: grouppedAttributes.map((attribute, i) => /* @__PURE__ */ jsx("div", { children: AttributeToInput("create", resourceConfig, attribute, i, __spreadProps(__spreadValues({}, options), { handleChange })) }, `input-${i}`))
|
|
80
|
+
},
|
|
81
|
+
`panel-${idx}`
|
|
82
|
+
);
|
|
83
|
+
})
|
|
84
|
+
] });
|
|
85
|
+
}
|
|
86
|
+
return groupByTabs(schema).map((groupOfAttributes, idx) => {
|
|
87
|
+
let grouppedAttributes = groupOfAttributes.filter(
|
|
88
|
+
(attribute) => (attribute == null ? void 0 : attribute.inCreate) !== false
|
|
89
|
+
);
|
|
90
|
+
if (isDrawer) {
|
|
91
|
+
grouppedAttributes = grouppedAttributes.filter(
|
|
92
|
+
(attribute) => (attribute == null ? void 0 : attribute.inDrawer) !== false
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return grouppedAttributes.length && /* @__PURE__ */ jsx(
|
|
96
|
+
FormTab,
|
|
97
|
+
{
|
|
98
|
+
value: idx,
|
|
99
|
+
label: groupOfAttributes[0].tab || (options == null ? void 0 : options.label) || "",
|
|
100
|
+
children: grouppedAttributes.map((attribute, i) => /* @__PURE__ */ jsx("div", { children: AttributeToInput("create", resourceConfig, attribute, i, __spreadProps(__spreadValues({}, options), { handleChange })) }, `input-${i}`))
|
|
101
|
+
},
|
|
102
|
+
`tab-${groupOfAttributes[0].tab || idx}`
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const EditFormTabs = ({ schema, resourceConfig, options, isDrawer }) => {
|
|
107
|
+
var _a;
|
|
108
|
+
const dispatch = useDispatch();
|
|
109
|
+
const [value, setValue] = useState(0);
|
|
110
|
+
const handleChange = (event) => {
|
|
111
|
+
const { name, value: value2, type } = event.target;
|
|
112
|
+
let payloadValue;
|
|
113
|
+
switch (type) {
|
|
114
|
+
case "checkbox":
|
|
115
|
+
payloadValue = event.target.checked;
|
|
116
|
+
break;
|
|
117
|
+
case "select":
|
|
118
|
+
payloadValue = value2;
|
|
119
|
+
break;
|
|
120
|
+
case "text":
|
|
121
|
+
case "number":
|
|
122
|
+
case "email":
|
|
123
|
+
payloadValue = value2;
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
payloadValue = value2;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
console.log("DashAutoFormMuiTabs: dispatch method deprecated");
|
|
130
|
+
};
|
|
131
|
+
const handleTabChange = (event, newValue) => {
|
|
132
|
+
setValue(newValue);
|
|
133
|
+
};
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
return () => {
|
|
136
|
+
console.log("DashAutoFormMuiTabs: dispatch method deprecated");
|
|
137
|
+
};
|
|
138
|
+
}, [dispatch]);
|
|
139
|
+
const tabGroups = groupByTabs(schema);
|
|
140
|
+
if (((_a = options == null ? void 0 : options.meta) == null ? void 0 : _a.tabs) === "mui") {
|
|
141
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { width: "100%" }, children: [
|
|
142
|
+
/* @__PURE__ */ jsx(Box, { sx: { borderBottom: 1, borderColor: "divider" }, children: /* @__PURE__ */ jsx(Tabs, { value, onChange: handleTabChange, children: tabGroups.map((group, idx) => /* @__PURE__ */ jsx(Tab, { label: group[0].tab || (options == null ? void 0 : options.label) || "" }, `tab-${group[0].tab || idx}`)) }) }),
|
|
143
|
+
tabGroups.map((groupOfAttributes, idx) => {
|
|
144
|
+
let grouppedAttributes = groupOfAttributes.filter(
|
|
145
|
+
(attribute) => (attribute == null ? void 0 : attribute.inEdit) !== false
|
|
146
|
+
);
|
|
147
|
+
if (isDrawer) {
|
|
148
|
+
grouppedAttributes = grouppedAttributes.filter(
|
|
149
|
+
(attribute) => (attribute == null ? void 0 : attribute.inDrawer) !== false
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return /* @__PURE__ */ jsx(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
role: "tabpanel",
|
|
156
|
+
hidden: value !== idx,
|
|
157
|
+
style: { padding: "20px 0" },
|
|
158
|
+
children: grouppedAttributes.map((attribute, i) => /* @__PURE__ */ jsx("div", { children: AttributeToInput("edit", resourceConfig, attribute, i, __spreadProps(__spreadValues({}, options), { handleChange })) }, `input-${i}`))
|
|
159
|
+
},
|
|
160
|
+
`panel-${idx}`
|
|
161
|
+
);
|
|
162
|
+
})
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
return groupByTabs(schema).map((groupOfAttributes, idx) => {
|
|
166
|
+
let grouppedAttributes = groupOfAttributes.filter(
|
|
167
|
+
(attribute) => (attribute == null ? void 0 : attribute.inEdit) !== false
|
|
168
|
+
);
|
|
169
|
+
if (isDrawer) {
|
|
170
|
+
grouppedAttributes = grouppedAttributes.filter(
|
|
171
|
+
(attribute) => (attribute == null ? void 0 : attribute.inDrawer) !== false
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return grouppedAttributes.length && /* @__PURE__ */ jsx(
|
|
175
|
+
FormTab,
|
|
176
|
+
{
|
|
177
|
+
value: idx,
|
|
178
|
+
label: groupOfAttributes[0].tab || (options == null ? void 0 : options.label) || "",
|
|
179
|
+
children: grouppedAttributes.map((attribute, i) => /* @__PURE__ */ jsx("div", { children: AttributeToInput("edit", resourceConfig, attribute, i, __spreadProps(__spreadValues({}, options), { handleChange })) }, `input-${i}`))
|
|
180
|
+
},
|
|
181
|
+
`tab-${groupOfAttributes[0].tab || idx}`
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
const ViewFormTabs = ({ schema, resourceConfig, options, isDrawer }) => {
|
|
186
|
+
var _a;
|
|
187
|
+
const dispatch = useDispatch();
|
|
188
|
+
const [value, setValue] = useState(0);
|
|
189
|
+
const handleChange = (event) => {
|
|
190
|
+
const { name, value: value2, type } = event.target;
|
|
191
|
+
let payloadValue;
|
|
192
|
+
switch (type) {
|
|
193
|
+
case "checkbox":
|
|
194
|
+
payloadValue = event.target.checked;
|
|
195
|
+
break;
|
|
196
|
+
case "select":
|
|
197
|
+
payloadValue = value2;
|
|
198
|
+
break;
|
|
199
|
+
case "text":
|
|
200
|
+
case "number":
|
|
201
|
+
case "email":
|
|
202
|
+
payloadValue = value2;
|
|
203
|
+
break;
|
|
204
|
+
default:
|
|
205
|
+
payloadValue = value2;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
console.log("DashAutoFormMuiTabs: dispatch method deprecated");
|
|
209
|
+
};
|
|
210
|
+
const handleTabChange = (event, newValue) => {
|
|
211
|
+
setValue(newValue);
|
|
212
|
+
};
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
return () => {
|
|
215
|
+
console.log("DashAutoFormMuiTabs: dispatch method deprecated");
|
|
216
|
+
};
|
|
217
|
+
}, [dispatch]);
|
|
218
|
+
const tabGroups = groupByTabs(schema);
|
|
219
|
+
if (((_a = options == null ? void 0 : options.meta) == null ? void 0 : _a.tabs) === "mui") {
|
|
220
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { width: "100%" }, children: [
|
|
221
|
+
/* @__PURE__ */ jsx(Box, { sx: { borderBottom: 1, borderColor: "divider" }, children: /* @__PURE__ */ jsx(Tabs, { value, onChange: handleTabChange, children: tabGroups.map((group, idx) => /* @__PURE__ */ jsx(Tab, { label: group[0].tab || (options == null ? void 0 : options.label) || "" }, `tab-${group[0].tab || idx}`)) }) }),
|
|
222
|
+
tabGroups.map((groupOfAttributes, idx) => {
|
|
223
|
+
let grouppedAttributes = groupOfAttributes.filter(
|
|
224
|
+
(attribute) => (attribute == null ? void 0 : attribute.inShow) !== false
|
|
225
|
+
);
|
|
226
|
+
if (isDrawer) {
|
|
227
|
+
grouppedAttributes = grouppedAttributes.filter(
|
|
228
|
+
(attribute) => (attribute == null ? void 0 : attribute.inDrawer) !== false
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return /* @__PURE__ */ jsx(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
role: "tabpanel",
|
|
235
|
+
hidden: value !== idx,
|
|
236
|
+
style: { padding: "20px 0" },
|
|
237
|
+
children: grouppedAttributes.map((attribute, i) => /* @__PURE__ */ jsx("div", { children: AttributeToInput("view", resourceConfig, attribute, i, __spreadProps(__spreadValues({}, options), { handleChange })) }, `input-${i}`))
|
|
238
|
+
},
|
|
239
|
+
`panel-${idx}`
|
|
240
|
+
);
|
|
241
|
+
})
|
|
242
|
+
] });
|
|
243
|
+
}
|
|
244
|
+
return groupByTabs(schema).map((groupOfAttributes, idx) => {
|
|
245
|
+
let grouppedAttributes = groupOfAttributes.filter(
|
|
246
|
+
(attribute) => (attribute == null ? void 0 : attribute.inShow) !== false
|
|
247
|
+
);
|
|
248
|
+
if (isDrawer) {
|
|
249
|
+
grouppedAttributes = grouppedAttributes.filter(
|
|
250
|
+
(attribute) => (attribute == null ? void 0 : attribute.inDrawer) !== false
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return grouppedAttributes.length && /* @__PURE__ */ jsx(
|
|
254
|
+
FormTab,
|
|
255
|
+
{
|
|
256
|
+
value: idx,
|
|
257
|
+
label: groupOfAttributes[0].tab || (options == null ? void 0 : options.label) || "",
|
|
258
|
+
children: grouppedAttributes.map((attribute, i) => /* @__PURE__ */ jsx("div", { children: AttributeToInput("view", resourceConfig, attribute, i, __spreadProps(__spreadValues({}, options), { handleChange })) }, `input-${i}`))
|
|
259
|
+
},
|
|
260
|
+
`tab-${groupOfAttributes[0].tab || idx}`
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
const DashAutoFormMuiTabs = ({
|
|
265
|
+
schema,
|
|
266
|
+
resourceConfig,
|
|
267
|
+
options
|
|
268
|
+
}) => {
|
|
269
|
+
const isDrawer = options.isDrawer === true ? true : false;
|
|
270
|
+
const meta = (options == null ? void 0 : options.meta) || {};
|
|
271
|
+
const commonProps = {
|
|
272
|
+
schema,
|
|
273
|
+
resourceConfig,
|
|
274
|
+
options,
|
|
275
|
+
isDrawer
|
|
276
|
+
};
|
|
277
|
+
switch (options.mode) {
|
|
278
|
+
case "create":
|
|
279
|
+
return /* @__PURE__ */ jsx(CreateFormTabs, __spreadValues({}, commonProps));
|
|
280
|
+
case "edit":
|
|
281
|
+
return /* @__PURE__ */ jsx(EditFormTabs, __spreadValues({}, commonProps));
|
|
282
|
+
case "view":
|
|
283
|
+
return /* @__PURE__ */ jsx(ViewFormTabs, __spreadValues({}, commonProps));
|
|
284
|
+
default:
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var DashAutoFormMuiTabs_default = DashAutoFormMuiTabs;
|
|
289
|
+
export {
|
|
290
|
+
DashAutoFormMuiTabs_default as default
|
|
291
|
+
};
|
package/dist/DashAutoFormTabs.js
CHANGED
|
@@ -1 +1,132 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
21
|
+
import { FormTab } from "react-admin";
|
|
22
|
+
import groupByTabs from "./utils/groupByTabs";
|
|
23
|
+
import AttributeToInput from "./mui/AttributeToInput";
|
|
24
|
+
const DashAutoFormTabs = ({
|
|
25
|
+
schema,
|
|
26
|
+
resourceConfig,
|
|
27
|
+
options
|
|
28
|
+
}) => {
|
|
29
|
+
const isDrawer = options.isDrawer === true ? true : false;
|
|
30
|
+
const handleChange = (event) => {
|
|
31
|
+
const { name, value, type } = event.target;
|
|
32
|
+
let payloadValue;
|
|
33
|
+
switch (type) {
|
|
34
|
+
case "checkbox":
|
|
35
|
+
payloadValue = event.target.checked;
|
|
36
|
+
break;
|
|
37
|
+
case "select":
|
|
38
|
+
payloadValue = value;
|
|
39
|
+
break;
|
|
40
|
+
case "text":
|
|
41
|
+
case "number":
|
|
42
|
+
case "email":
|
|
43
|
+
payloadValue = value;
|
|
44
|
+
break;
|
|
45
|
+
// Add cases for other input types as needed
|
|
46
|
+
default:
|
|
47
|
+
payloadValue = value;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
options = __spreadProps(__spreadValues({}, options), { handleChange });
|
|
52
|
+
const renderInputs = (mode, grouppedAttributes) => {
|
|
53
|
+
return grouppedAttributes.map((attribute, i) => /* @__PURE__ */ jsx("div", { children: AttributeToInput(mode, resourceConfig, attribute, i, options) }, `input-${i}`));
|
|
54
|
+
};
|
|
55
|
+
const filterAttributes = (groupOfAttributes, mode) => {
|
|
56
|
+
let filtered = groupOfAttributes.filter((attribute) => {
|
|
57
|
+
switch (mode) {
|
|
58
|
+
case "create":
|
|
59
|
+
return (attribute == null ? void 0 : attribute.inCreate) !== false;
|
|
60
|
+
case "edit":
|
|
61
|
+
return (attribute == null ? void 0 : attribute.inEdit) !== false;
|
|
62
|
+
case "view":
|
|
63
|
+
return (attribute == null ? void 0 : attribute.inShow) !== false;
|
|
64
|
+
default:
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (isDrawer) {
|
|
69
|
+
filtered = filtered.filter((attribute) => (attribute == null ? void 0 : attribute.inDrawer) !== false);
|
|
70
|
+
}
|
|
71
|
+
return filtered;
|
|
72
|
+
};
|
|
73
|
+
const tabGroups = groupByTabs(schema);
|
|
74
|
+
const getFilteredTabGroups = (mode) => {
|
|
75
|
+
return tabGroups.map((group) => ({
|
|
76
|
+
original: group,
|
|
77
|
+
filtered: filterAttributes(group, mode)
|
|
78
|
+
})).filter((g) => g.filtered.length > 0);
|
|
79
|
+
};
|
|
80
|
+
switch (options.mode) {
|
|
81
|
+
case "create": {
|
|
82
|
+
const filteredGroups = getFilteredTabGroups("create");
|
|
83
|
+
if (filteredGroups.length === 1) {
|
|
84
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderInputs("create", filteredGroups[0].filtered) });
|
|
85
|
+
}
|
|
86
|
+
return filteredGroups.map((group, idx) => /* @__PURE__ */ jsx(
|
|
87
|
+
FormTab,
|
|
88
|
+
{
|
|
89
|
+
value: idx,
|
|
90
|
+
label: group.original[0].tab || (options == null ? void 0 : options.label) || (resourceConfig == null ? void 0 : resourceConfig.label),
|
|
91
|
+
children: renderInputs("create", group.filtered)
|
|
92
|
+
},
|
|
93
|
+
`tab-${group.original[0].tab || idx}`
|
|
94
|
+
));
|
|
95
|
+
}
|
|
96
|
+
case "edit": {
|
|
97
|
+
const filteredGroups = getFilteredTabGroups("edit");
|
|
98
|
+
if (filteredGroups.length === 1) {
|
|
99
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderInputs("edit", filteredGroups[0].filtered) });
|
|
100
|
+
}
|
|
101
|
+
return filteredGroups.map((group, idx) => /* @__PURE__ */ jsx(
|
|
102
|
+
FormTab,
|
|
103
|
+
{
|
|
104
|
+
value: idx,
|
|
105
|
+
label: group.original[0].tab || (options == null ? void 0 : options.label) || (resourceConfig == null ? void 0 : resourceConfig.label),
|
|
106
|
+
children: renderInputs("edit", group.filtered)
|
|
107
|
+
},
|
|
108
|
+
`tab-${group.original[0].tab || idx}`
|
|
109
|
+
));
|
|
110
|
+
}
|
|
111
|
+
case "view": {
|
|
112
|
+
const filteredGroups = getFilteredTabGroups("view");
|
|
113
|
+
if (filteredGroups.length === 1) {
|
|
114
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderInputs("view", filteredGroups[0].filtered) });
|
|
115
|
+
}
|
|
116
|
+
return filteredGroups.map((group, idx) => /* @__PURE__ */ jsx(
|
|
117
|
+
FormTab,
|
|
118
|
+
{
|
|
119
|
+
value: idx,
|
|
120
|
+
label: group.original[0].tab || (options == null ? void 0 : options.label) || (resourceConfig == null ? void 0 : resourceConfig.label),
|
|
121
|
+
children: renderInputs("view", group.filtered)
|
|
122
|
+
},
|
|
123
|
+
`tab-${group.original[0].tab || idx}`
|
|
124
|
+
));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
DashAutoFormTabs.whyDidYouRender = true;
|
|
129
|
+
var DashAutoFormTabs_default = DashAutoFormTabs;
|
|
130
|
+
export {
|
|
131
|
+
DashAutoFormTabs_default as default
|
|
132
|
+
};
|
package/dist/DashAutoGroup.js
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
import{Fragment
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SimpleShowLayout } from "react-admin";
|
|
3
|
+
import { AttributeToField } from "./mui/AttributeToField";
|
|
4
|
+
import groupByTabs from "./utils/groupByTabs";
|
|
5
|
+
import { AutoAdminSettings } from ".";
|
|
6
|
+
const DashAutoGroup = (resourceConfig, options) => {
|
|
7
|
+
return /* @__PURE__ */ jsx(SimpleShowLayout, { children: groupByTabs(resourceConfig.schema).map((groupOfAttributes, idx) => {
|
|
8
|
+
const label = groupOfAttributes[0].tab || AutoAdminSettings.defaultTabName;
|
|
9
|
+
const count = groupOfAttributes.filter((attribute) => (attribute == null ? void 0 : attribute.inShow) !== false).length;
|
|
10
|
+
return count ? /* @__PURE__ */ jsxs("fieldset", { children: [
|
|
11
|
+
/* @__PURE__ */ jsx("legend", { children: label }),
|
|
12
|
+
groupOfAttributes.filter((attribute) => (attribute == null ? void 0 : attribute.inShow) !== false).map(
|
|
13
|
+
(attribute, i) => AttributeToField(
|
|
14
|
+
"view",
|
|
15
|
+
resourceConfig,
|
|
16
|
+
attribute,
|
|
17
|
+
i,
|
|
18
|
+
options
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
] }, "fieldset-group-" + idx) : /* @__PURE__ */ jsx(Fragment, {});
|
|
22
|
+
}) });
|
|
23
|
+
};
|
|
24
|
+
var DashAutoGroup_default = DashAutoGroup;
|
|
25
|
+
export {
|
|
26
|
+
DashAutoGroup_default as default
|
|
27
|
+
};
|
package/dist/DashAutoLayout.js
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import{jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SimpleShowLayout } from "react-admin";
|
|
3
|
+
import AutoTabs from "./DashAutoTabs";
|
|
4
|
+
import { AttributeToField } from "./mui/AttributeToField";
|
|
5
|
+
import hashedGroupByTabs from "./utils/hashedGroupByTabs";
|
|
6
|
+
const DashAutoLayout = (resourceConfig, options) => {
|
|
7
|
+
const renderShow = (tab, options2, forceAttributeToFieldMethod) => {
|
|
8
|
+
const groupedTabs = hashedGroupByTabs(resourceConfig.schema);
|
|
9
|
+
const groupedAttributesByTab = groupedTabs[tab] ? groupedTabs[tab] : [];
|
|
10
|
+
return groupedAttributesByTab.filter((attribute) => (attribute == null ? void 0 : attribute.inShow) !== false).map(
|
|
11
|
+
(attribute, idx) => AttributeToField(
|
|
12
|
+
forceAttributeToFieldMethod || "view",
|
|
13
|
+
resourceConfig,
|
|
14
|
+
attribute,
|
|
15
|
+
idx,
|
|
16
|
+
options2
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
if (!resourceConfig.showLayout || typeof resourceConfig.showLayout !== "function") {
|
|
21
|
+
console.error(
|
|
22
|
+
"showLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs"
|
|
23
|
+
);
|
|
24
|
+
return AutoTabs(resourceConfig);
|
|
25
|
+
}
|
|
26
|
+
return /* @__PURE__ */ jsx(SimpleShowLayout, { children: resourceConfig.showLayout(renderShow) });
|
|
27
|
+
};
|
|
28
|
+
var DashAutoLayout_default = DashAutoLayout;
|
|
29
|
+
export {
|
|
30
|
+
DashAutoLayout_default as default
|
|
31
|
+
};
|