@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
|
@@ -1 +1,630 @@
|
|
|
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 { createElement } from "react";
|
|
34
|
+
import {
|
|
35
|
+
ArrayInput,
|
|
36
|
+
ImageInput,
|
|
37
|
+
FileInput,
|
|
38
|
+
BooleanInput,
|
|
39
|
+
DateInput,
|
|
40
|
+
DateTimeInput,
|
|
41
|
+
NumberInput,
|
|
42
|
+
SelectArrayInput,
|
|
43
|
+
SelectInput,
|
|
44
|
+
ChipField,
|
|
45
|
+
ImageField,
|
|
46
|
+
PasswordInput,
|
|
47
|
+
ReferenceArrayInput,
|
|
48
|
+
ReferenceInput,
|
|
49
|
+
SimpleFormIterator,
|
|
50
|
+
SingleFieldList,
|
|
51
|
+
TextInput,
|
|
52
|
+
useRecordContext
|
|
53
|
+
} from "react-admin";
|
|
54
|
+
import { ErrorMessage } from "@hookform/error-message";
|
|
55
|
+
import { InputAdornment, InputLabel, Typography } from "@mui/material";
|
|
56
|
+
import Visibility from "@mui/icons-material/Visibility";
|
|
57
|
+
import { UserAction } from "../wrappers";
|
|
58
|
+
import { FunctionField } from "react-admin";
|
|
59
|
+
import { FileField } from "react-admin";
|
|
60
|
+
import React from "react";
|
|
61
|
+
import enumToChoices from "../utils/enumToChoices";
|
|
62
|
+
import isEnum from "../utils/isEnum";
|
|
63
|
+
import { useLocation, useParams } from "react-router";
|
|
64
|
+
import replaceParams from "../utils/replaceParams";
|
|
65
|
+
import { useEditContext } from "react-admin";
|
|
66
|
+
import { useFormContext } from "react-hook-form";
|
|
67
|
+
import { useComponentRegistry } from "../DashAutoAdminComponentRegistry";
|
|
68
|
+
const FunctionFieldWrapper = (_a) => {
|
|
69
|
+
var _b = _a, {
|
|
70
|
+
index,
|
|
71
|
+
method,
|
|
72
|
+
input,
|
|
73
|
+
children
|
|
74
|
+
} = _b, _props = __objRest(_b, [
|
|
75
|
+
"index",
|
|
76
|
+
"method",
|
|
77
|
+
"input",
|
|
78
|
+
"children"
|
|
79
|
+
]);
|
|
80
|
+
const sortable = (input == null ? void 0 : input.sortable) === true ? true : false;
|
|
81
|
+
const {
|
|
82
|
+
formState: { errors }
|
|
83
|
+
} = useFormContext();
|
|
84
|
+
if (method === "edit") {
|
|
85
|
+
return /* @__PURE__ */ jsxs(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
className: `auto-admin-field auto-admin-field-${method}`,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
FunctionField,
|
|
92
|
+
__spreadProps(__spreadValues({
|
|
93
|
+
label: (input == null ? void 0 : input.label) || input.attribute,
|
|
94
|
+
sortable
|
|
95
|
+
}, sortable && { sortBy: input.listAttribute || input.attribute }), {
|
|
96
|
+
render: (record) => {
|
|
97
|
+
return React.cloneElement(children, { record });
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
),
|
|
101
|
+
!(input == null ? void 0 : input.hideErrorMessage) || (input == null ? void 0 : input.custom) && /* @__PURE__ */ jsx(
|
|
102
|
+
ErrorMessage,
|
|
103
|
+
{
|
|
104
|
+
errors,
|
|
105
|
+
name: input.attribute,
|
|
106
|
+
render: (error) => {
|
|
107
|
+
var _a2, _b2;
|
|
108
|
+
return error ? /* @__PURE__ */ jsx(Typography, { className: "dash-admin-field-error", color: "error", children: typeof error.message === "string" ? error.message : typeof ((_a2 = error.message) == null ? void 0 : _a2.message) === "string" ? (_b2 = error.message) == null ? void 0 : _b2.message : JSON.stringify(error) }) : null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
index
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
return /* @__PURE__ */ jsx("div", { className: `auto-admin-field auto-admin-field-${method}`, children }, index);
|
|
118
|
+
};
|
|
119
|
+
const useSafeEditContext = () => {
|
|
120
|
+
try {
|
|
121
|
+
return useEditContext();
|
|
122
|
+
} catch (error) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const useSafeRecordContext = () => {
|
|
127
|
+
try {
|
|
128
|
+
return useRecordContext();
|
|
129
|
+
} catch (error) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const useRecordByMethod = (method, mode) => {
|
|
134
|
+
const editContext = useSafeEditContext();
|
|
135
|
+
const recordContext = useSafeRecordContext();
|
|
136
|
+
if (method === "edit" || mode === "edit") {
|
|
137
|
+
return editContext;
|
|
138
|
+
}
|
|
139
|
+
return recordContext;
|
|
140
|
+
};
|
|
141
|
+
const AttributeToInput = (method, resourceConfig, input, index, options) => {
|
|
142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
143
|
+
const DEBUG = false;
|
|
144
|
+
const { components } = useComponentRegistry();
|
|
145
|
+
const mode = (options == null ? void 0 : options.mode) || "view";
|
|
146
|
+
const record = useRecordByMethod(method, options == null ? void 0 : options.mode);
|
|
147
|
+
const location = useLocation();
|
|
148
|
+
const params = useParams();
|
|
149
|
+
const typeComponentMapper = (type) => {
|
|
150
|
+
const component = components[type];
|
|
151
|
+
if (component) {
|
|
152
|
+
return { custom: true, type: "component", component };
|
|
153
|
+
}
|
|
154
|
+
return { custom: true, type: "component", component: () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
+
"No component for ",
|
|
156
|
+
type
|
|
157
|
+
] }) };
|
|
158
|
+
};
|
|
159
|
+
const ComponentWrapper = (resourceConfig == null ? void 0 : resourceConfig.fieldWrapper) && typeof resourceConfig.fieldWrapper === "function" ? resourceConfig.fieldWrapper : ({
|
|
160
|
+
_record,
|
|
161
|
+
_method,
|
|
162
|
+
_attribute,
|
|
163
|
+
_resourceConfig,
|
|
164
|
+
children
|
|
165
|
+
}) => children;
|
|
166
|
+
if (typeof input.type === "string" && !input.type.includes(".") && !Array.isArray(input.type)) {
|
|
167
|
+
switch (input.type) {
|
|
168
|
+
case "string":
|
|
169
|
+
case "text":
|
|
170
|
+
case "String":
|
|
171
|
+
input.type = String;
|
|
172
|
+
input.slotProps = {
|
|
173
|
+
fullWidth: (_b = (_a = input == null ? void 0 : input.fieldProps) == null ? void 0 : _a.fullWidth) != null ? _b : true
|
|
174
|
+
};
|
|
175
|
+
break;
|
|
176
|
+
case "textarea":
|
|
177
|
+
input.type = String;
|
|
178
|
+
input.multiple = true;
|
|
179
|
+
input.slotProps = {
|
|
180
|
+
fullWidth: (_d = (_c = input == null ? void 0 : input.fieldProps) == null ? void 0 : _c.fullWidth) != null ? _d : true
|
|
181
|
+
};
|
|
182
|
+
input.fieldProps = __spreadProps(__spreadValues({}, input.fieldProps || {}), {
|
|
183
|
+
multiline: (_f = (_e = input == null ? void 0 : input.fieldProps) == null ? void 0 : _e.multiline) != null ? _f : true,
|
|
184
|
+
rows: (_h = (_g = input == null ? void 0 : input.fieldProps) == null ? void 0 : _g.rows) != null ? _h : 4
|
|
185
|
+
});
|
|
186
|
+
break;
|
|
187
|
+
case "number":
|
|
188
|
+
case "Number":
|
|
189
|
+
case "integer":
|
|
190
|
+
input.type = Number;
|
|
191
|
+
break;
|
|
192
|
+
case "boolean":
|
|
193
|
+
case "Boolean":
|
|
194
|
+
input.type = Boolean;
|
|
195
|
+
break;
|
|
196
|
+
case "date":
|
|
197
|
+
case "Date":
|
|
198
|
+
input.type = Date;
|
|
199
|
+
break;
|
|
200
|
+
case "custom":
|
|
201
|
+
default:
|
|
202
|
+
input.custom = true;
|
|
203
|
+
DEBUG && console.log("\u{1F527} AttributeToInput - custom type detected, input.component:", input == null ? void 0 : input.component);
|
|
204
|
+
DEBUG && console.log("\u{1F527} AttributeToInput - components available:", Object.keys(components));
|
|
205
|
+
if (typeof (input == null ? void 0 : input.component) === "string") {
|
|
206
|
+
const mappedResult = typeComponentMapper(input.component);
|
|
207
|
+
DEBUG && console.log("\u{1F527} AttributeToInput - typeComponentMapper result:", mappedResult);
|
|
208
|
+
input = __spreadValues(__spreadValues({}, input), mappedResult);
|
|
209
|
+
DEBUG && console.log("\u{1F527} AttributeToInput - after merge, input.component:", input.component);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (options && options.useReadOnlyInputAsTextField && input.readOnly) {
|
|
214
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
215
|
+
ComponentWrapper,
|
|
216
|
+
__spreadProps(__spreadValues({
|
|
217
|
+
label: input.label,
|
|
218
|
+
source: input.listAttribute || input.attribute
|
|
219
|
+
}, record && { record }), {
|
|
220
|
+
method,
|
|
221
|
+
attribute: input,
|
|
222
|
+
resourceConfig,
|
|
223
|
+
children: /* @__PURE__ */ createElement(
|
|
224
|
+
TextInput,
|
|
225
|
+
__spreadValues(__spreadProps(__spreadValues({
|
|
226
|
+
fullWidth: true
|
|
227
|
+
}, record && { record }), {
|
|
228
|
+
key: index,
|
|
229
|
+
label: input.label,
|
|
230
|
+
source: input.listAttribute || input.attribute
|
|
231
|
+
}), __spreadProps(__spreadValues({}, input.fieldProps), {
|
|
232
|
+
editable: false,
|
|
233
|
+
InputProps: {
|
|
234
|
+
readOnly: true,
|
|
235
|
+
endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(Visibility, {}) })
|
|
236
|
+
}
|
|
237
|
+
}))
|
|
238
|
+
)
|
|
239
|
+
}),
|
|
240
|
+
index
|
|
241
|
+
) });
|
|
242
|
+
} else if (options && options.readOnlyComponent && input.readOnly) {
|
|
243
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ createElement(
|
|
244
|
+
ComponentWrapper,
|
|
245
|
+
__spreadProps(__spreadValues({}, record && { record }), {
|
|
246
|
+
method,
|
|
247
|
+
attribute: input,
|
|
248
|
+
key: index,
|
|
249
|
+
label: input.label,
|
|
250
|
+
source: input.listAttribute || input.attribute,
|
|
251
|
+
resourceConfig
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ jsx(
|
|
254
|
+
options.readOnlyComponent,
|
|
255
|
+
__spreadValues(__spreadProps(__spreadValues({
|
|
256
|
+
fullWidth: true
|
|
257
|
+
}, record && { record }), {
|
|
258
|
+
input,
|
|
259
|
+
label: input.label,
|
|
260
|
+
source: input.listAttribute || input.attribute
|
|
261
|
+
}), __spreadProps(__spreadValues({}, input.fieldProps), {
|
|
262
|
+
editable: false,
|
|
263
|
+
InputProps: { readOnly: true }
|
|
264
|
+
})),
|
|
265
|
+
index
|
|
266
|
+
)
|
|
267
|
+
) });
|
|
268
|
+
}
|
|
269
|
+
if (!input.label) input.label = input.attribute;
|
|
270
|
+
if (input.custom && input.component || input.type === "component" && input.component) {
|
|
271
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
272
|
+
UserAction,
|
|
273
|
+
{
|
|
274
|
+
record,
|
|
275
|
+
method: mode,
|
|
276
|
+
attribute: input,
|
|
277
|
+
resourceConfig
|
|
278
|
+
},
|
|
279
|
+
index
|
|
280
|
+
) });
|
|
281
|
+
}
|
|
282
|
+
if (Array.isArray(input.type) && input.type.length > 0) {
|
|
283
|
+
const inputType = input.type[0];
|
|
284
|
+
if (isEnum(inputType)) {
|
|
285
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
286
|
+
SelectArrayInput,
|
|
287
|
+
__spreadProps(__spreadValues({
|
|
288
|
+
fullWidth: true,
|
|
289
|
+
label: input.label,
|
|
290
|
+
source: input.attribute,
|
|
291
|
+
choices: enumToChoices(inputType)
|
|
292
|
+
}, input == null ? void 0 : input.fieldProps), {
|
|
293
|
+
onChange: (e) => {
|
|
294
|
+
var _a2;
|
|
295
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
296
|
+
options.handleChange(e);
|
|
297
|
+
}
|
|
298
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
299
|
+
input.fieldProps.onChange(e);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}),
|
|
303
|
+
index
|
|
304
|
+
) });
|
|
305
|
+
}
|
|
306
|
+
if (typeof inputType === "string") {
|
|
307
|
+
const _params = __spreadValues(__spreadValues({}, params), (location.hash.match(/\d+/g) || []).map(Number).reduce((acc, curr, currentIndex) => {
|
|
308
|
+
acc[currentIndex] = curr;
|
|
309
|
+
return acc;
|
|
310
|
+
}, {}));
|
|
311
|
+
const _inputType = replaceParams(_params, inputType);
|
|
312
|
+
const [reference, sourceName] = _inputType.split(".");
|
|
313
|
+
const safeIfNull = (choice) => (choice ? choice[sourceName] : "?") || "??";
|
|
314
|
+
if (input && input.multiple === false && input.component) {
|
|
315
|
+
const CustomComponent = input.component;
|
|
316
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
317
|
+
ReferenceInput,
|
|
318
|
+
__spreadProps(__spreadValues({
|
|
319
|
+
fullWidth: true,
|
|
320
|
+
allowEmpty: true,
|
|
321
|
+
filter: true,
|
|
322
|
+
pagination: false,
|
|
323
|
+
label: input.label,
|
|
324
|
+
reference,
|
|
325
|
+
source: input.attribute
|
|
326
|
+
}, input.componentProps), {
|
|
327
|
+
children: /* @__PURE__ */ jsx(
|
|
328
|
+
CustomComponent,
|
|
329
|
+
{
|
|
330
|
+
optionText: safeIfNull,
|
|
331
|
+
method,
|
|
332
|
+
attribute: input,
|
|
333
|
+
onChange: (e) => {
|
|
334
|
+
var _a2;
|
|
335
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
336
|
+
options.handleChange(e);
|
|
337
|
+
}
|
|
338
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
339
|
+
input.fieldProps.onChange(e);
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
resourceConfig
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
}),
|
|
346
|
+
index
|
|
347
|
+
) });
|
|
348
|
+
}
|
|
349
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
350
|
+
ReferenceArrayInput,
|
|
351
|
+
__spreadProps(__spreadValues({
|
|
352
|
+
fullWidth: true,
|
|
353
|
+
filter: true,
|
|
354
|
+
pagination: false,
|
|
355
|
+
label: input.label,
|
|
356
|
+
reference,
|
|
357
|
+
source: input.attribute
|
|
358
|
+
}, input.componentProps), {
|
|
359
|
+
children: /* @__PURE__ */ jsx(SingleFieldList, __spreadProps(__spreadValues({}, input.fieldProps), { children: /* @__PURE__ */ jsx(ChipField, { source: sourceName }) }))
|
|
360
|
+
}),
|
|
361
|
+
index
|
|
362
|
+
) });
|
|
363
|
+
} else {
|
|
364
|
+
const inputTypeArray = input.type;
|
|
365
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
366
|
+
ArrayInput,
|
|
367
|
+
__spreadProps(__spreadValues({
|
|
368
|
+
label: input.label,
|
|
369
|
+
source: input.attribute
|
|
370
|
+
}, input.componentProps), {
|
|
371
|
+
children: /* @__PURE__ */ jsx(SimpleFormIterator, { children: inputTypeArray.map(
|
|
372
|
+
(attribute, idx) => AttributeToInput(method, resourceConfig, attribute, idx)
|
|
373
|
+
) })
|
|
374
|
+
}),
|
|
375
|
+
index
|
|
376
|
+
) });
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (input && input.type === ImageInput) {
|
|
380
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
381
|
+
ImageInput,
|
|
382
|
+
__spreadProps(__spreadValues({
|
|
383
|
+
placeholder: "Arr\xE1stre una im\xE1gen o haga click aqu\xED para seleccionar",
|
|
384
|
+
source: input.attribute,
|
|
385
|
+
label: input.label,
|
|
386
|
+
accept: "image/*"
|
|
387
|
+
}, input.fieldProps), {
|
|
388
|
+
children: /* @__PURE__ */ jsx(ImageField, { source: "src", title: "title" })
|
|
389
|
+
}),
|
|
390
|
+
index
|
|
391
|
+
) });
|
|
392
|
+
}
|
|
393
|
+
if (input && input.type === FileInput) {
|
|
394
|
+
/* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
395
|
+
FileInput,
|
|
396
|
+
__spreadProps(__spreadValues({
|
|
397
|
+
placeholder: "Arr\xE1stre un archivo o haga click aqu\xED para seleccionar",
|
|
398
|
+
source: input.attribute,
|
|
399
|
+
label: input.label
|
|
400
|
+
}, input.fieldProps), {
|
|
401
|
+
children: /* @__PURE__ */ jsx(FileField, { source: "src", title: "title" })
|
|
402
|
+
}),
|
|
403
|
+
index
|
|
404
|
+
) });
|
|
405
|
+
}
|
|
406
|
+
if (typeof input.type === "string") {
|
|
407
|
+
if (input.type === "select" && Array.isArray(input.options) && input.options.length > 0) {
|
|
408
|
+
const choices = input.options.map((opt) => ({
|
|
409
|
+
id: opt.id,
|
|
410
|
+
name: opt.name
|
|
411
|
+
}));
|
|
412
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
413
|
+
SelectInput,
|
|
414
|
+
__spreadValues(__spreadProps(__spreadValues({
|
|
415
|
+
fullWidth: true,
|
|
416
|
+
label: input.label,
|
|
417
|
+
source: input.listAttribute || input.attribute,
|
|
418
|
+
choices
|
|
419
|
+
}, input.fieldProps), {
|
|
420
|
+
onChange: (e) => {
|
|
421
|
+
var _a2;
|
|
422
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
423
|
+
options.handleChange(e);
|
|
424
|
+
}
|
|
425
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
426
|
+
input.fieldProps.onChange(e);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}), input.componentProps),
|
|
430
|
+
index
|
|
431
|
+
) });
|
|
432
|
+
}
|
|
433
|
+
if (input.type === "select" && (!input.options || input.options.length === 0)) {
|
|
434
|
+
console.warn(`Select field "${input.attribute}" has no options defined. Skipping render.`);
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
const _params = __spreadValues(__spreadValues({}, params), (location.pathname.match(/\d+/g) || []).map(Number).reduce((acc, curr, currentIndex) => {
|
|
438
|
+
acc[currentIndex] = curr;
|
|
439
|
+
return acc;
|
|
440
|
+
}, {}));
|
|
441
|
+
const _inputType = replaceParams(_params, input.type);
|
|
442
|
+
const [reference, sourceName] = _inputType.split(".");
|
|
443
|
+
const CustomComponent = input.component || SelectInput;
|
|
444
|
+
if (input && input.multiple === false) {
|
|
445
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
446
|
+
ReferenceInput,
|
|
447
|
+
__spreadProps(__spreadValues({
|
|
448
|
+
allowEmpty: true,
|
|
449
|
+
filters: true,
|
|
450
|
+
label: input.label,
|
|
451
|
+
source: input.listAttribute || input.attribute,
|
|
452
|
+
reference,
|
|
453
|
+
sort: { field: sourceName, order: "ASC" }
|
|
454
|
+
}, input.componentProps), {
|
|
455
|
+
children: /* @__PURE__ */ jsx(
|
|
456
|
+
CustomComponent,
|
|
457
|
+
__spreadProps(__spreadValues({
|
|
458
|
+
optionText: sourceName,
|
|
459
|
+
method,
|
|
460
|
+
attribute: input,
|
|
461
|
+
label: (input == null ? void 0 : input.label) || ""
|
|
462
|
+
}, input.fieldProps), {
|
|
463
|
+
onChange: (e) => {
|
|
464
|
+
var _a2;
|
|
465
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
466
|
+
options.handleChange(e);
|
|
467
|
+
}
|
|
468
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
469
|
+
input.fieldProps.onChange(e);
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
resourceConfig
|
|
473
|
+
})
|
|
474
|
+
)
|
|
475
|
+
}),
|
|
476
|
+
index
|
|
477
|
+
) });
|
|
478
|
+
}
|
|
479
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
480
|
+
ReferenceArrayInput,
|
|
481
|
+
__spreadProps(__spreadValues({
|
|
482
|
+
reference,
|
|
483
|
+
source: input.listAttribute || input.attribute
|
|
484
|
+
}, input.componentProps), {
|
|
485
|
+
children: /* @__PURE__ */ jsx(
|
|
486
|
+
SelectArrayInput,
|
|
487
|
+
__spreadProps(__spreadValues({
|
|
488
|
+
optionText: sourceName,
|
|
489
|
+
fullWidth: true,
|
|
490
|
+
label: (input == null ? void 0 : input.label) || ""
|
|
491
|
+
}, input.fieldProps), {
|
|
492
|
+
onChange: (e) => {
|
|
493
|
+
var _a2;
|
|
494
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
495
|
+
options.handleChange(e);
|
|
496
|
+
}
|
|
497
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
498
|
+
input.fieldProps.onChange(e);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
})
|
|
502
|
+
)
|
|
503
|
+
}),
|
|
504
|
+
index
|
|
505
|
+
) });
|
|
506
|
+
}
|
|
507
|
+
switch (input.type) {
|
|
508
|
+
case Number:
|
|
509
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
510
|
+
NumberInput,
|
|
511
|
+
__spreadProps(__spreadValues({
|
|
512
|
+
fullWidth: true,
|
|
513
|
+
label: input.label,
|
|
514
|
+
source: input.attribute
|
|
515
|
+
}, input.fieldProps), {
|
|
516
|
+
onChange: (e) => {
|
|
517
|
+
var _a2;
|
|
518
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
519
|
+
options.handleChange(e);
|
|
520
|
+
}
|
|
521
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
522
|
+
input.fieldProps.onChange(e);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}),
|
|
526
|
+
index
|
|
527
|
+
) });
|
|
528
|
+
case Boolean:
|
|
529
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsxs("div", { children: [
|
|
530
|
+
(input == null ? void 0 : input.showLabel) !== false && /* @__PURE__ */ jsx(InputLabel, { htmlFor: input.listAttribute || input.attribute, children: input.label }),
|
|
531
|
+
/* @__PURE__ */ jsx(
|
|
532
|
+
BooleanInput,
|
|
533
|
+
__spreadProps(__spreadValues({
|
|
534
|
+
record,
|
|
535
|
+
id: input.listAttribute || input.attribute,
|
|
536
|
+
label: input.label,
|
|
537
|
+
source: input.listAttribute || input.attribute
|
|
538
|
+
}, input.fieldProps), {
|
|
539
|
+
onChange: (e) => {
|
|
540
|
+
var _a2;
|
|
541
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
542
|
+
options.handleChange(e);
|
|
543
|
+
}
|
|
544
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
545
|
+
input.fieldProps.onChange(e);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}),
|
|
549
|
+
index
|
|
550
|
+
)
|
|
551
|
+
] }) });
|
|
552
|
+
case Date:
|
|
553
|
+
return input.fieldProps && input.fieldProps.showTime ? /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
554
|
+
DateTimeInput,
|
|
555
|
+
__spreadValues({
|
|
556
|
+
label: input.label,
|
|
557
|
+
source: input.attribute
|
|
558
|
+
}, input.fieldProps),
|
|
559
|
+
index
|
|
560
|
+
) }) : /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
561
|
+
DateInput,
|
|
562
|
+
__spreadProps(__spreadValues({
|
|
563
|
+
label: input.label,
|
|
564
|
+
source: input.attribute
|
|
565
|
+
}, input.fieldProps), {
|
|
566
|
+
onChange: (e) => {
|
|
567
|
+
var _a2;
|
|
568
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
569
|
+
options.handleChange(e);
|
|
570
|
+
}
|
|
571
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
572
|
+
input.fieldProps.onChange(e);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}),
|
|
576
|
+
index
|
|
577
|
+
) });
|
|
578
|
+
}
|
|
579
|
+
if (isEnum(input.type)) {
|
|
580
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
581
|
+
SelectInput,
|
|
582
|
+
{
|
|
583
|
+
label: input.label,
|
|
584
|
+
source: input.attribute,
|
|
585
|
+
choices: enumToChoices(input.type),
|
|
586
|
+
InputProps: input.fieldOptions,
|
|
587
|
+
onChange: (e) => {
|
|
588
|
+
var _a2;
|
|
589
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
590
|
+
options.handleChange(e);
|
|
591
|
+
}
|
|
592
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
593
|
+
input.fieldProps.onChange(e);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
index
|
|
598
|
+
) });
|
|
599
|
+
}
|
|
600
|
+
if (input.isPassword) {
|
|
601
|
+
const passwordProps = __spreadValues({
|
|
602
|
+
key: index,
|
|
603
|
+
label: input.label,
|
|
604
|
+
source: input.attribute
|
|
605
|
+
}, input.slotProps ? { slotProps: input.slotProps } : {});
|
|
606
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(PasswordInput, __spreadValues({}, passwordProps)) });
|
|
607
|
+
}
|
|
608
|
+
const textFieldProps = __spreadProps(__spreadValues(__spreadValues({
|
|
609
|
+
label: input.label,
|
|
610
|
+
source: input.listAttribute || input.attribute
|
|
611
|
+
}, input.fieldProps), input.slotProps ? { slotProps: input.slotProps } : {}), {
|
|
612
|
+
onChange: (e) => {
|
|
613
|
+
var _a2;
|
|
614
|
+
if (options == null ? void 0 : options.handleChange) {
|
|
615
|
+
options.handleChange(e);
|
|
616
|
+
}
|
|
617
|
+
if ((_a2 = input.fieldProps) == null ? void 0 : _a2.onChange) {
|
|
618
|
+
input.fieldProps.onChange(e);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
return /* @__PURE__ */ jsx(FunctionFieldWrapper, { index, method: mode, input, children: /* @__PURE__ */ jsx(
|
|
623
|
+
TextInput,
|
|
624
|
+
__spreadValues({}, textFieldProps)
|
|
625
|
+
) });
|
|
626
|
+
};
|
|
627
|
+
var AttributeToInput_default = AttributeToInput;
|
|
628
|
+
export {
|
|
629
|
+
AttributeToInput_default as default
|
|
630
|
+
};
|