@dashadmin/dash-auto-admin 1.3.24 → 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,135 @@
|
|
|
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 { CreateButton } from "react-admin";
|
|
22
|
+
import { ExportButton } from "react-admin";
|
|
23
|
+
import { ListButton } from "react-admin";
|
|
24
|
+
import { EditButton } from "react-admin";
|
|
25
|
+
import { DeleteButton } from "react-admin";
|
|
26
|
+
import DashAutoAdminSaveButton from "../../DashAutoAdminSaveButton";
|
|
27
|
+
import { DeleteWithConfirmButton } from "react-admin";
|
|
28
|
+
import { WithRecord } from "react-admin";
|
|
29
|
+
import { SaveButton } from "react-admin";
|
|
30
|
+
const checkIfModeEnablesButton = (modes, mode) => {
|
|
31
|
+
if (!modes) return true;
|
|
32
|
+
if (!mode) return true;
|
|
33
|
+
if (modes[mode] === false) return false;
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
const ToolbarSaveButton = (props) => {
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
const { resourceConfig, mode } = props;
|
|
39
|
+
if (!resourceConfig) {
|
|
40
|
+
return /* @__PURE__ */ jsx(SaveButton, {});
|
|
41
|
+
}
|
|
42
|
+
if (!resourceConfig.toolbarSaveButton) {
|
|
43
|
+
return /* @__PURE__ */ jsx(SaveButton, {});
|
|
44
|
+
}
|
|
45
|
+
if ((_a = resourceConfig.toolbarSaveButton) == null ? void 0 : _a.enabled) {
|
|
46
|
+
if (checkIfModeEnablesButton(resourceConfig.toolbarSaveButton.modes, mode)) {
|
|
47
|
+
const buttonProps = __spreadProps(__spreadValues({}, ((_b = resourceConfig.toolbarSaveButton) == null ? void 0 : _b.props) || {}), {
|
|
48
|
+
alwaysEnable: (resourceConfig == null ? void 0 : resourceConfig.saveButtonAlwaysEnabled) === true ? true : false
|
|
49
|
+
});
|
|
50
|
+
return ((_c = resourceConfig.toolbarSaveButton) == null ? void 0 : _c.component) ? /* @__PURE__ */ jsx(resourceConfig.toolbarSaveButton.component, __spreadValues({}, buttonProps)) : /* @__PURE__ */ jsx(DashAutoAdminSaveButton, __spreadValues({}, buttonProps));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
const ToolbarListButton = (props) => {
|
|
56
|
+
var _a, _b, _c, _d;
|
|
57
|
+
const { resourceConfig, mode } = props;
|
|
58
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(ListButton, {});
|
|
59
|
+
if (!!((resourceConfig == null ? void 0 : resourceConfig.list) !== false) && ((resourceConfig == null ? void 0 : resourceConfig.toolbarListButton) && !!((resourceConfig == null ? void 0 : resourceConfig.toolbarListButton.enabled) !== false))) {
|
|
60
|
+
return checkIfModeEnablesButton(resourceConfig.toolbarListButton.modes, mode) ? /* @__PURE__ */ jsx(ListButton, {}) : null;
|
|
61
|
+
} else if ((_a = resourceConfig.toolbarListButton) == null ? void 0 : _a.enabled) {
|
|
62
|
+
if (checkIfModeEnablesButton(resourceConfig.toolbarEditButton.modes, mode)) {
|
|
63
|
+
return ((_b = resourceConfig.toolbarListButton) == null ? void 0 : _b.component) ? /* @__PURE__ */ jsx(resourceConfig.toolbarListButton.component, __spreadValues({}, ((_c = resourceConfig.toolbarListButton) == null ? void 0 : _c.props) || {})) : /* @__PURE__ */ jsx(ListButton, __spreadValues({}, ((_d = resourceConfig.toolbarListButton) == null ? void 0 : _d.props) || {}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
};
|
|
68
|
+
const ToolbarEditButton = (props) => {
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
const { resourceConfig, mode } = props;
|
|
71
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(EditButton, {});
|
|
72
|
+
if (!!((resourceConfig == null ? void 0 : resourceConfig.edit) !== false) && ((resourceConfig == null ? void 0 : resourceConfig.toolbarEditButton) && !!((resourceConfig == null ? void 0 : resourceConfig.toolbarEditButton.enabled) !== false))) {
|
|
73
|
+
return checkIfModeEnablesButton(resourceConfig.toolbarEditButton.modes, mode) ? /* @__PURE__ */ jsx(EditButton, {}) : null;
|
|
74
|
+
} else if ((_a = resourceConfig.toolbarEditButton) == null ? void 0 : _a.enabled) {
|
|
75
|
+
if (checkIfModeEnablesButton(resourceConfig.toolbarEditButton.modes, mode)) {
|
|
76
|
+
return ((_b = resourceConfig.toolbarEditButton) == null ? void 0 : _b.component) ? /* @__PURE__ */ jsx(resourceConfig.toolbarEditButton.component, __spreadValues({}, ((_c = resourceConfig.toolbarEditButton) == null ? void 0 : _c.props) || {})) : /* @__PURE__ */ jsx(EditButton, __spreadValues({}, ((_d = resourceConfig.toolbarEditButton) == null ? void 0 : _d.props) || {}));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
};
|
|
81
|
+
const ToolbarCreateButton = (props) => {
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
|
+
const { resourceConfig, mode } = props;
|
|
84
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(CreateButton, {});
|
|
85
|
+
if (!!((resourceConfig == null ? void 0 : resourceConfig.create) !== false) && ((resourceConfig == null ? void 0 : resourceConfig.toolbarCreateButton) && !!((resourceConfig == null ? void 0 : resourceConfig.toolbarCreateButton.enabled) !== false))) {
|
|
86
|
+
return checkIfModeEnablesButton(resourceConfig.toolbarCreateButton.modes, mode) ? /* @__PURE__ */ jsx(CreateButton, {}) : null;
|
|
87
|
+
} else if ((_a = resourceConfig.toolbarCreateButton) == null ? void 0 : _a.enabled) {
|
|
88
|
+
if (checkIfModeEnablesButton(resourceConfig.toolbarCreateButton.modes, mode)) {
|
|
89
|
+
return ((_b = resourceConfig.toolbarCreateButton) == null ? void 0 : _b.component) ? /* @__PURE__ */ jsx(resourceConfig.toolbarCreateButton.component, __spreadValues({}, ((_c = resourceConfig.toolbarCreateButton) == null ? void 0 : _c.props) || {})) : /* @__PURE__ */ jsx(CreateButton, __spreadValues({}, ((_d = resourceConfig.toolbarCreateButton) == null ? void 0 : _d.props) || {}));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
};
|
|
94
|
+
const ToolbarDeleteButton = (props) => {
|
|
95
|
+
var _a, _b, _c, _d, _e;
|
|
96
|
+
const { resourceConfig, mode } = props;
|
|
97
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(DeleteButton, {});
|
|
98
|
+
if (!!((resourceConfig == null ? void 0 : resourceConfig.delete) !== false) && !!(resourceConfig == null ? void 0 : resourceConfig.toolbarDeleteButton)) {
|
|
99
|
+
return checkIfModeEnablesButton(resourceConfig.toolbarDeleteButton.modes, mode) ? /* @__PURE__ */ jsx(DeleteButton, {}) : null;
|
|
100
|
+
} else if (!!(resourceConfig == null ? void 0 : resourceConfig.toolbarDeleteButton) && !!((resourceConfig == null ? void 0 : resourceConfig.toolbarDeleteButton.enabled) !== false)) {
|
|
101
|
+
if (checkIfModeEnablesButton(resourceConfig.toolbarCreateButton.modes, mode)) {
|
|
102
|
+
if (!!((_a = resourceConfig.toolbarDeleteButton) == null ? void 0 : _a.props) && ((_b = resourceConfig.toolbarDeleteButton.props) == null ? void 0 : _b.confirm)) {
|
|
103
|
+
return /* @__PURE__ */ jsx(
|
|
104
|
+
WithRecord,
|
|
105
|
+
{
|
|
106
|
+
render: (record) => /* @__PURE__ */ jsx(DeleteWithConfirmButton, { record })
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return ((_c = resourceConfig.toolbarDeleteButton) == null ? void 0 : _c.component) ? /* @__PURE__ */ jsx(resourceConfig.toolbarDeleteButton.component, __spreadValues({}, ((_d = resourceConfig.toolbarDeleteButton) == null ? void 0 : _d.props) || {})) : /* @__PURE__ */ jsx(DeleteButton, __spreadValues({}, ((_e = resourceConfig.toolbarDeleteButton) == null ? void 0 : _e.props) || {}));
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
115
|
+
const ToolbarExportButton = (props) => {
|
|
116
|
+
var _a, _b, _c, _d;
|
|
117
|
+
const { resourceConfig, mode } = props;
|
|
118
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(ExportButton, {});
|
|
119
|
+
if (!!((resourceConfig == null ? void 0 : resourceConfig.exporter) !== false) && ((resourceConfig == null ? void 0 : resourceConfig.toolbarExportButton) && !!((resourceConfig == null ? void 0 : resourceConfig.toolbarExportButton.enabled) !== false))) {
|
|
120
|
+
return checkIfModeEnablesButton(resourceConfig.toolbarExportButton.modes, mode) ? /* @__PURE__ */ jsx(ExportButton, {}) : null;
|
|
121
|
+
} else if ((_a = resourceConfig.toolbarExportButton) == null ? void 0 : _a.enabled) {
|
|
122
|
+
if (checkIfModeEnablesButton(resourceConfig.toolbarExportButton.modes, mode)) {
|
|
123
|
+
return ((_b = resourceConfig.toolbarExportButton) == null ? void 0 : _b.component) ? /* @__PURE__ */ jsx(resourceConfig.toolbarExportButton.component, __spreadValues({}, ((_c = resourceConfig.toolbarExportButton) == null ? void 0 : _c.props) || {})) : /* @__PURE__ */ jsx(ExportButton, __spreadValues({}, ((_d = resourceConfig.toolbarExportButton) == null ? void 0 : _d.props) || {}));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
ToolbarCreateButton,
|
|
130
|
+
ToolbarDeleteButton,
|
|
131
|
+
ToolbarEditButton,
|
|
132
|
+
ToolbarExportButton,
|
|
133
|
+
ToolbarListButton,
|
|
134
|
+
ToolbarSaveButton
|
|
135
|
+
};
|
|
File without changes
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
class SimpleLogger {
|
|
5
|
+
constructor(prefix, debug) {
|
|
6
|
+
__publicField(this, "prefix", prefix);
|
|
7
|
+
__publicField(this, "debug", debug);
|
|
8
|
+
__publicField(this, "loggerID", Math.random().toString(32).slice(2, 6));
|
|
9
|
+
}
|
|
10
|
+
getLogString() {
|
|
11
|
+
return `ReactAutoAdmin | ${this.prefix} [${this.loggerID}]`;
|
|
12
|
+
}
|
|
13
|
+
get log() {
|
|
14
|
+
if (!this.debug) {
|
|
15
|
+
return () => {
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const boundLogFn = console.log.bind(
|
|
19
|
+
console,
|
|
20
|
+
`\u26AA ${this.getLogString()}`
|
|
21
|
+
);
|
|
22
|
+
return boundLogFn;
|
|
23
|
+
}
|
|
24
|
+
get warn() {
|
|
25
|
+
if (!this.debug) {
|
|
26
|
+
return () => {
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const boundLogFn = console.warn.bind(
|
|
30
|
+
console,
|
|
31
|
+
`\u{1F7E1} ${this.getLogString()}`
|
|
32
|
+
);
|
|
33
|
+
return boundLogFn;
|
|
34
|
+
}
|
|
35
|
+
get error() {
|
|
36
|
+
if (!this.debug) {
|
|
37
|
+
return () => {
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const boundLogFn = console.error.bind(
|
|
41
|
+
console,
|
|
42
|
+
`\u{1F534} ${this.getLogString()}`
|
|
43
|
+
);
|
|
44
|
+
return boundLogFn;
|
|
45
|
+
}
|
|
46
|
+
setEnabled(logging) {
|
|
47
|
+
this.debug = logging;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
SimpleLogger
|
|
52
|
+
};
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const evalActionPermission = (resourceConfig, action) => {
|
|
2
|
+
let result = true;
|
|
3
|
+
if (action === null || action === void 0) return true;
|
|
4
|
+
if (!action) return false;
|
|
5
|
+
if (typeof action === "function") result = action(resourceConfig);
|
|
6
|
+
return result;
|
|
7
|
+
};
|
|
8
|
+
var evalActionPermission_default = evalActionPermission;
|
|
9
|
+
export {
|
|
10
|
+
evalActionPermission_default as default
|
|
11
|
+
};
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
const
|
|
1
|
+
const groupByTabs = (schema) => {
|
|
2
|
+
const tabs = [];
|
|
3
|
+
schema.forEach((attribute) => {
|
|
4
|
+
let added = false;
|
|
5
|
+
tabs.forEach((tab) => {
|
|
6
|
+
const name = tab[0].tab;
|
|
7
|
+
if (name === attribute.tab) {
|
|
8
|
+
tab.push(attribute);
|
|
9
|
+
added = true;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
if (!added) {
|
|
13
|
+
tabs.push([attribute]);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return tabs;
|
|
17
|
+
};
|
|
18
|
+
var groupByTabs_default = groupByTabs;
|
|
19
|
+
export {
|
|
20
|
+
groupByTabs_default as default
|
|
21
|
+
};
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const hasehdGroupByTabs = (schema) => {
|
|
2
|
+
const tabs = [];
|
|
3
|
+
const availabletabs = [...new Set(schema.map((item) => item.tab))];
|
|
4
|
+
availabletabs.forEach((tab) => {
|
|
5
|
+
tabs[tab] = schema.filter((item) => item.tab === tab);
|
|
6
|
+
});
|
|
7
|
+
return tabs;
|
|
8
|
+
};
|
|
9
|
+
var hashedGroupByTabs_default = hasehdGroupByTabs;
|
|
10
|
+
export {
|
|
11
|
+
hashedGroupByTabs_default as default
|
|
12
|
+
};
|
package/dist/utils/invertMap.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const invertMap = (map) => {
|
|
2
|
+
if (!map) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const invertedMap = {};
|
|
6
|
+
Object.keys(map).forEach((key) => invertedMap[map[key]] = key);
|
|
7
|
+
return invertedMap;
|
|
8
|
+
};
|
|
9
|
+
var invertMap_default = invertMap;
|
|
10
|
+
export {
|
|
11
|
+
invertMap_default as default
|
|
12
|
+
};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const isClassComponent = (Component) => {
|
|
2
|
+
return !!(typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent);
|
|
3
|
+
};
|
|
4
|
+
var isClassComponent_default = isClassComponent;
|
|
5
|
+
export {
|
|
6
|
+
isClassComponent_default as default
|
|
7
|
+
};
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
function isClassComponent(component) {
|
|
3
|
+
return typeof component === "function" && !!component.prototype.isReactComponent;
|
|
4
|
+
}
|
|
5
|
+
function isFunctionComponent(component) {
|
|
6
|
+
return typeof component === "function" && String(component).includes("return React.createElement");
|
|
7
|
+
}
|
|
8
|
+
function isReactComponent(component) {
|
|
9
|
+
return isClassComponent(component) || isFunctionComponent(component);
|
|
10
|
+
}
|
|
11
|
+
function isElement(element) {
|
|
12
|
+
return React.isValidElement(element);
|
|
13
|
+
}
|
|
14
|
+
function isDOMTypeElement(element) {
|
|
15
|
+
return isElement(element) && typeof element.type === "string";
|
|
16
|
+
}
|
|
17
|
+
function isCompositeTypeElement(element) {
|
|
18
|
+
return isElement(element) && typeof element.type === "function";
|
|
19
|
+
}
|
|
20
|
+
var isComponent_default = isReactComponent;
|
|
21
|
+
export {
|
|
22
|
+
isComponent_default as default,
|
|
23
|
+
isClassComponent,
|
|
24
|
+
isCompositeTypeElement,
|
|
25
|
+
isDOMTypeElement,
|
|
26
|
+
isElement,
|
|
27
|
+
isFunctionComponent,
|
|
28
|
+
isReactComponent
|
|
29
|
+
};
|
package/dist/utils/isEnum.js
CHANGED
package/dist/utils/isFC.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
function
|
|
1
|
+
function replaceParams(params, str) {
|
|
2
|
+
delete params["*"];
|
|
3
|
+
const regex = new RegExp(`{(${Object.keys(params).join("|")})+}`, "g");
|
|
4
|
+
return str.replace(regex, (match, param) => params[param]);
|
|
5
|
+
}
|
|
6
|
+
var replaceParams_default = replaceParams;
|
|
7
|
+
export {
|
|
8
|
+
replaceParams_default as default
|
|
9
|
+
};
|
package/dist/utils/validate.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
const
|
|
1
|
+
const validate = (schema) => (values) => {
|
|
2
|
+
const errors = {};
|
|
3
|
+
schema.forEach((field) => {
|
|
4
|
+
if (field.validate) {
|
|
5
|
+
try {
|
|
6
|
+
field.validate(values[field.attribute], values);
|
|
7
|
+
} catch (error) {
|
|
8
|
+
let message = "Error";
|
|
9
|
+
if (error instanceof Error) message = error.message;
|
|
10
|
+
errors[field.attribute] = message;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return errors;
|
|
15
|
+
};
|
|
16
|
+
var validate_default = validate;
|
|
17
|
+
export {
|
|
18
|
+
validate_default as default
|
|
19
|
+
};
|
|
@@ -1 +1,60 @@
|
|
|
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 { WithRecord, Button } from "react-admin";
|
|
22
|
+
import isFC from "../utils/isFC";
|
|
23
|
+
const UserAction = (props) => {
|
|
24
|
+
const { method, attribute, resourceConfig, record, options } = props;
|
|
25
|
+
const DEBUG = false;
|
|
26
|
+
DEBUG && console.log("\u{1F527} UserAction - component:", attribute.component);
|
|
27
|
+
DEBUG && console.log("\u{1F527} UserAction - isFC(attribute.component):", isFC(attribute.component));
|
|
28
|
+
DEBUG && console.log("\u{1F527} UserAction - method:", method);
|
|
29
|
+
const locale = (options == null ? void 0 : options.locale) || props.locale;
|
|
30
|
+
if (attribute.component && isFC(attribute.component)) {
|
|
31
|
+
DEBUG && console.log("\u{1F527} UserAction - Rendering custom component");
|
|
32
|
+
const Action = attribute.component;
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
Action,
|
|
35
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
36
|
+
method,
|
|
37
|
+
attribute,
|
|
38
|
+
resourceConfig
|
|
39
|
+
}, record && { record }), attribute == null ? void 0 : attribute.componentProps), {
|
|
40
|
+
locale,
|
|
41
|
+
options
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (typeof attribute.action === "function") {
|
|
46
|
+
const callback = attribute.action;
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
WithRecord,
|
|
49
|
+
{
|
|
50
|
+
label: attribute.label,
|
|
51
|
+
render: (record2) => /* @__PURE__ */ jsx(Button, { value: attribute.label, onClick: () => callback(record2.id), children: /* @__PURE__ */ jsx(Fragment, { children: attribute.label }) })
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
var UserAction_default = UserAction;
|
|
58
|
+
export {
|
|
59
|
+
UserAction_default as default
|
|
60
|
+
};
|
package/dist/wrappers/index.js
CHANGED