@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.
- package/README.md +32 -6
- 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 +134 -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
package/README.md
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dashadmin/dash-auto-admin
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
yarn lint:fix - performs a prettier fix
|
|
5
|
-
yarn lint - perform an eslint check, including prettier rules
|
|
3
|
+
> Schema-driven auto-generation of admin CRUD views.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
## Overview
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
Generates List, Create, Edit, Drawer and dynamic Form layouts (groups, tabs) from resource configuration, dramatically reducing hand-written CRUD screens.
|
|
8
|
+
|
|
9
|
+
## Key exports & features
|
|
10
|
+
|
|
11
|
+
- `DashAutoList`, `DashAutoCreate`, `DashAutoEdit`, `DashAutoDrawer`
|
|
12
|
+
- `DashAutoAdminForm` with form groups, tabs and layouts
|
|
13
|
+
- Config-driven fields and validation
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# From the public npm registry
|
|
19
|
+
npm install @dashadmin/dash-auto-admin
|
|
20
|
+
|
|
21
|
+
# Or the local Verdaccio registry (unscoped)
|
|
22
|
+
npm install dash-auto-admin --registry http://localhost:4873
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Internal Dash dependencies
|
|
26
|
+
|
|
27
|
+
`@dashadmin/dash-constants`, `@dashadmin/dash-dialog`
|
|
28
|
+
|
|
29
|
+
## Development & publishing
|
|
30
|
+
|
|
31
|
+
This package is part of the **dash-frontend-core** monorepo. See [`DEVELOPMENT.md`](../../DEVELOPMENT.md) for the source-modification workflow, local Verdaccio publishing, npm publishing and version-bump policy.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
_Part of the [Dash Framework](https://www.npmjs.com/org/dashadmin) · `@dashadmin` scope._
|
|
@@ -1 +1,64 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
21
|
+
import React, { createContext, useContext } from "react";
|
|
22
|
+
const defaultComponentMap = {};
|
|
23
|
+
const ComponentRegistryContext = createContext({
|
|
24
|
+
components: defaultComponentMap,
|
|
25
|
+
registerComponent: () => {
|
|
26
|
+
},
|
|
27
|
+
registerComponents: () => {
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const useComponentRegistry = () => useContext(ComponentRegistryContext);
|
|
31
|
+
const ComponentRegistryProvider = ({
|
|
32
|
+
children,
|
|
33
|
+
customComponents = {}
|
|
34
|
+
}) => {
|
|
35
|
+
const [components, setComponents] = React.useState(__spreadValues(__spreadValues({}, defaultComponentMap), customComponents));
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (customComponents && Object.keys(customComponents).length > 0) {
|
|
38
|
+
setComponents((prev) => __spreadValues(__spreadValues({}, prev), customComponents));
|
|
39
|
+
}
|
|
40
|
+
}, [customComponents]);
|
|
41
|
+
const registerComponent = React.useCallback((type, component) => {
|
|
42
|
+
setComponents((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
43
|
+
[type]: component
|
|
44
|
+
}));
|
|
45
|
+
}, []);
|
|
46
|
+
const registerComponents = React.useCallback((componentMap) => {
|
|
47
|
+
setComponents((prev) => __spreadValues(__spreadValues({}, prev), componentMap));
|
|
48
|
+
}, []);
|
|
49
|
+
return /* @__PURE__ */ jsx(
|
|
50
|
+
ComponentRegistryContext.Provider,
|
|
51
|
+
{
|
|
52
|
+
value: {
|
|
53
|
+
components,
|
|
54
|
+
registerComponent,
|
|
55
|
+
registerComponents
|
|
56
|
+
},
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
ComponentRegistryProvider,
|
|
63
|
+
useComponentRegistry
|
|
64
|
+
};
|
|
@@ -1 +1,137 @@
|
|
|
1
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { Box } from "@mui/material";
|
|
23
|
+
import {
|
|
24
|
+
useResourceContext,
|
|
25
|
+
useRecordContext,
|
|
26
|
+
Toolbar,
|
|
27
|
+
SimpleForm
|
|
28
|
+
} from "react-admin";
|
|
29
|
+
import validate from "./utils/validate";
|
|
30
|
+
import { ToolbarCreateButton, ToolbarDeleteButton, ToolbarSaveButton } from "./toolbar/buttons/ToolbarButtons";
|
|
31
|
+
import { useDataProvider } from "react-admin";
|
|
32
|
+
import { DashAutoAdminFormProvider } from "./context/DashAutoAdminFormContext";
|
|
33
|
+
const DashAutoAdminForm = ({
|
|
34
|
+
resourceConfig,
|
|
35
|
+
onSubmit,
|
|
36
|
+
beforeSubmit,
|
|
37
|
+
onError,
|
|
38
|
+
//onCancel,
|
|
39
|
+
toolbar,
|
|
40
|
+
mode,
|
|
41
|
+
children
|
|
42
|
+
}) => {
|
|
43
|
+
const resource = useResourceContext();
|
|
44
|
+
const record = useRecordContext();
|
|
45
|
+
const dataProvider = useDataProvider();
|
|
46
|
+
const debug = false;
|
|
47
|
+
const onCreateSave = (values) => __async(null, null, function* () {
|
|
48
|
+
if (debug) console.log("onCreateSave called with values:", values);
|
|
49
|
+
window.dispatchEvent(
|
|
50
|
+
new MessageEvent("dash-global-loader", { data: true })
|
|
51
|
+
);
|
|
52
|
+
try {
|
|
53
|
+
if (beforeSubmit) {
|
|
54
|
+
if (debug) console.log("beforeSubmit called with values:", values);
|
|
55
|
+
values = beforeSubmit(values);
|
|
56
|
+
if (debug) console.log("beforeSubmit returned values:", values);
|
|
57
|
+
}
|
|
58
|
+
const { data } = yield dataProvider.create(resource, {
|
|
59
|
+
data: values
|
|
60
|
+
});
|
|
61
|
+
if (debug) console.log("dataProvider.create returned data:", data);
|
|
62
|
+
if (onSubmit) {
|
|
63
|
+
if (debug) console.log("onSubmit called with data:", data);
|
|
64
|
+
onSubmit(data);
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (onError) {
|
|
68
|
+
if (debug) console.log("onError called with error:", error);
|
|
69
|
+
onError(error);
|
|
70
|
+
}
|
|
71
|
+
} finally {
|
|
72
|
+
window.dispatchEvent(
|
|
73
|
+
new MessageEvent("dash-global-loader", { data: false })
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const onUpdateSave = (values) => __async(null, null, function* () {
|
|
78
|
+
if (debug) console.log("onUpdateSave called with values:", values);
|
|
79
|
+
window.dispatchEvent(
|
|
80
|
+
new MessageEvent("dash-global-loader", { data: true })
|
|
81
|
+
);
|
|
82
|
+
try {
|
|
83
|
+
if (beforeSubmit) {
|
|
84
|
+
if (debug) console.log("beforeSubmit called with values:", values);
|
|
85
|
+
values = beforeSubmit(values);
|
|
86
|
+
if (debug) console.log("beforeSubmit returned values:", values);
|
|
87
|
+
}
|
|
88
|
+
const { data } = yield dataProvider.update(resource, {
|
|
89
|
+
id: record == null ? void 0 : record.id,
|
|
90
|
+
data: values,
|
|
91
|
+
previousData: record
|
|
92
|
+
});
|
|
93
|
+
if (debug) console.log("dataProvider.update returned data:", data);
|
|
94
|
+
if (onSubmit) {
|
|
95
|
+
if (debug) console.log("onSubmit called with data:", data);
|
|
96
|
+
onSubmit(data);
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (onError) {
|
|
100
|
+
if (debug) console.log("onError called with error:", error);
|
|
101
|
+
onError(error);
|
|
102
|
+
}
|
|
103
|
+
} finally {
|
|
104
|
+
window.dispatchEvent(
|
|
105
|
+
new MessageEvent("dash-global-loader", { data: false })
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
let onSave = onCreateSave;
|
|
110
|
+
switch (mode) {
|
|
111
|
+
case "edit":
|
|
112
|
+
onSave = onUpdateSave;
|
|
113
|
+
break;
|
|
114
|
+
case "create":
|
|
115
|
+
onSave = onCreateSave;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
const defaultToolbar = () => /* @__PURE__ */ jsxs(Toolbar, { children: [
|
|
119
|
+
mode === "edit" && /* @__PURE__ */ jsx(ToolbarSaveButton, { resourceConfig }),
|
|
120
|
+
mode === "create" && /* @__PURE__ */ jsx(ToolbarCreateButton, { resourceConfig }),
|
|
121
|
+
/* @__PURE__ */ jsx(ToolbarDeleteButton, { resourceConfig })
|
|
122
|
+
] });
|
|
123
|
+
return /* @__PURE__ */ jsx(DashAutoAdminFormProvider, { value: { onSave, mode }, children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
124
|
+
SimpleForm,
|
|
125
|
+
{
|
|
126
|
+
toolbar: toolbar || defaultToolbar(),
|
|
127
|
+
onSubmit: onSave,
|
|
128
|
+
validate: validate(resourceConfig.schema),
|
|
129
|
+
reValidateMode: "onBlur",
|
|
130
|
+
children
|
|
131
|
+
}
|
|
132
|
+
) }) });
|
|
133
|
+
};
|
|
134
|
+
var DashAutoAdminForm_default = DashAutoAdminForm;
|
|
135
|
+
export {
|
|
136
|
+
DashAutoAdminForm_default as default
|
|
137
|
+
};
|
|
@@ -1 +1,63 @@
|
|
|
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
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { Drawer } from "@mui/material";
|
|
34
|
+
import React from "react";
|
|
35
|
+
const DashAutoAdminResizableDrawerContext = React.createContext(400);
|
|
36
|
+
const DashAutoAdminResizableDrawer = (_a) => {
|
|
37
|
+
var _b = _a, {
|
|
38
|
+
children,
|
|
39
|
+
defaultWidth
|
|
40
|
+
} = _b, props = __objRest(_b, [
|
|
41
|
+
"children",
|
|
42
|
+
"defaultWidth"
|
|
43
|
+
]);
|
|
44
|
+
const [drawerWidth, setDrawerWidth] = React.useState(defaultWidth);
|
|
45
|
+
const Dragger = () => {
|
|
46
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
Drawer,
|
|
50
|
+
__spreadProps(__spreadValues({
|
|
51
|
+
PaperProps: { style: { width: drawerWidth } }
|
|
52
|
+
}, props), {
|
|
53
|
+
children: /* @__PURE__ */ jsxs(DashAutoAdminResizableDrawerContext.Provider, { value: drawerWidth, children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Dragger, {}),
|
|
55
|
+
children
|
|
56
|
+
] })
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
DashAutoAdminResizableDrawer,
|
|
62
|
+
DashAutoAdminResizableDrawerContext
|
|
63
|
+
};
|
|
@@ -1 +1,57 @@
|
|
|
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
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
33
|
+
import { SaveButton } from "react-admin";
|
|
34
|
+
import { useFormContext } from "react-hook-form";
|
|
35
|
+
const DashAutoAdminSaveButton = (props) => {
|
|
36
|
+
const _a = props, { resourceConfig } = _a, customProps = __objRest(_a, ["resourceConfig"]);
|
|
37
|
+
const { formState } = useFormContext();
|
|
38
|
+
const alwaysEnabled = (resourceConfig == null ? void 0 : resourceConfig.saveButtonAlwaysEnabled) === true ? true : false;
|
|
39
|
+
const handleClick = (e) => {
|
|
40
|
+
if (customProps == null ? void 0 : customProps.onClick) {
|
|
41
|
+
customProps.onClick(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
45
|
+
SaveButton,
|
|
46
|
+
__spreadProps(__spreadValues({
|
|
47
|
+
alwaysEnable: alwaysEnabled
|
|
48
|
+
}, customProps), {
|
|
49
|
+
onClick: handleClick,
|
|
50
|
+
disabled: formState.isSubmitting
|
|
51
|
+
})
|
|
52
|
+
) });
|
|
53
|
+
};
|
|
54
|
+
var DashAutoAdminSaveButton_default = DashAutoAdminSaveButton;
|
|
55
|
+
export {
|
|
56
|
+
DashAutoAdminSaveButton_default as default
|
|
57
|
+
};
|
package/dist/DashAutoCreate.js
CHANGED
|
@@ -1 +1,102 @@
|
|
|
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
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
import AutoTabbedForm from "./DashAutoTabbedForm";
|
|
34
|
+
import { Create, TopToolbar, ListButton, Toolbar } from "react-admin";
|
|
35
|
+
import evalActionPermission from "./utils/evalActionPermission";
|
|
36
|
+
import AutoTitle from "./common/DashAutoTitle";
|
|
37
|
+
import DashAutoAdminSaveButton from "./DashAutoAdminSaveButton";
|
|
38
|
+
const DashAutoCreate = ({
|
|
39
|
+
resourceConfig,
|
|
40
|
+
toolbar,
|
|
41
|
+
actions,
|
|
42
|
+
onSubmit,
|
|
43
|
+
onError,
|
|
44
|
+
beforeSubmit,
|
|
45
|
+
isDrawer,
|
|
46
|
+
locale
|
|
47
|
+
}) => {
|
|
48
|
+
const CreateActions = (_a) => {
|
|
49
|
+
var props = __objRest(_a, []);
|
|
50
|
+
const _showListwbutton = resourceConfig.drawer === true ? false : resourceConfig.toolbarListButton ? true : false;
|
|
51
|
+
const hasToolbar = !!(resourceConfig == null ? void 0 : resourceConfig.AutoEditTopToolbarElements) || _showListwbutton;
|
|
52
|
+
if (!hasToolbar) return null;
|
|
53
|
+
return /* @__PURE__ */ jsxs(TopToolbar, __spreadProps(__spreadValues({ sx: { mb: 2 } }, props), { children: [
|
|
54
|
+
_showListwbutton && /* @__PURE__ */ jsx(ListButton, {}),
|
|
55
|
+
(resourceConfig == null ? void 0 : resourceConfig.AutoEditTopToolbarElements) ? resourceConfig.AutoCreateTopToolbarElements(resourceConfig) : /* @__PURE__ */ jsx(Fragment, {})
|
|
56
|
+
] }));
|
|
57
|
+
};
|
|
58
|
+
const CreateToolbar = (_b) => {
|
|
59
|
+
var props = __objRest(_b, []);
|
|
60
|
+
var _a;
|
|
61
|
+
const SaveComponent = resourceConfig.toolbarSaveButton && resourceConfig.toolbarSaveButton.component ? resourceConfig.toolbarSaveButton.component : DashAutoAdminSaveButton;
|
|
62
|
+
return /* @__PURE__ */ jsxs(Toolbar, __spreadProps(__spreadValues({}, props), { children: [
|
|
63
|
+
evalActionPermission(
|
|
64
|
+
resourceConfig,
|
|
65
|
+
resourceConfig.toolbarSaveButton
|
|
66
|
+
) && /* @__PURE__ */ jsx(
|
|
67
|
+
SaveComponent,
|
|
68
|
+
__spreadValues({
|
|
69
|
+
resourceConfig,
|
|
70
|
+
onSubmit
|
|
71
|
+
}, resourceConfig.toolbarSaveButton && ((_a = resourceConfig.toolbarSaveButton) == null ? void 0 : _a.props))
|
|
72
|
+
),
|
|
73
|
+
(resourceConfig == null ? void 0 : resourceConfig.AutoEditBottomToolbarElements) ? resourceConfig.AutoCreateBottomToolbarElements(resourceConfig) : /* @__PURE__ */ jsx(Fragment, {})
|
|
74
|
+
] }));
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
Create,
|
|
78
|
+
{
|
|
79
|
+
component: "div",
|
|
80
|
+
actions: actions || /* @__PURE__ */ jsx(CreateActions, {}),
|
|
81
|
+
mutationMode: resourceConfig.mutationMode,
|
|
82
|
+
title: /* @__PURE__ */ jsx(AutoTitle, { resourceConfig }),
|
|
83
|
+
children: /* @__PURE__ */ jsx(
|
|
84
|
+
AutoTabbedForm,
|
|
85
|
+
{
|
|
86
|
+
mode: "create",
|
|
87
|
+
resourceConfig,
|
|
88
|
+
toolbar: toolbar || /* @__PURE__ */ jsx(CreateToolbar, {}),
|
|
89
|
+
onSubmit,
|
|
90
|
+
onError,
|
|
91
|
+
beforeSubmit,
|
|
92
|
+
isDrawer,
|
|
93
|
+
locale
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
var DashAutoCreate_default = DashAutoCreate;
|
|
100
|
+
export {
|
|
101
|
+
DashAutoCreate_default as default
|
|
102
|
+
};
|