@dashadmin/dash-auto-admin 1.3.25 → 1.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/DashAutoAdminComponentRegistry.js +64 -1
  2. package/dist/DashAutoAdminForm.js +137 -1
  3. package/dist/DashAutoAdminResizableDrawer.js +63 -1
  4. package/dist/DashAutoAdminSaveButton.js +57 -1
  5. package/dist/DashAutoCreate.js +102 -1
  6. package/dist/DashAutoDrawer.js +256 -1
  7. package/dist/DashAutoEdit.js +99 -1
  8. package/dist/DashAutoFiltersGenerator.js +193 -1
  9. package/dist/DashAutoFormGroups.js +118 -1
  10. package/dist/DashAutoFormLayout.js +68 -1
  11. package/dist/DashAutoFormMuiTabs.js +291 -1
  12. package/dist/DashAutoFormTabs.js +132 -1
  13. package/dist/DashAutoGroup.js +27 -1
  14. package/dist/DashAutoLayout.js +31 -1
  15. package/dist/DashAutoList.js +218 -1
  16. package/dist/DashAutoPostFilterForm.js +47 -1
  17. package/dist/DashAutoReferenceTab.js +10 -1
  18. package/dist/DashAutoResource.js +77 -1
  19. package/dist/DashAutoResourceLayout.js +16 -1
  20. package/dist/DashAutoShow.js +195 -1
  21. package/dist/DashAutoTabbedForm.js +244 -1
  22. package/dist/DashAutoTabbedForm.review.js +221 -1
  23. package/dist/DashAutoTabs.js +11 -1
  24. package/dist/DashFilterWrapper.js +62 -1
  25. package/dist/DashRedirect.js +56 -1
  26. package/dist/TabbedLayout.js +38 -1
  27. package/dist/common/DashAutoTitle.js +33 -1
  28. package/dist/common/components/FabButton.js +59 -1
  29. package/dist/common/components/TranslatedLabel.js +60 -1
  30. package/dist/common/settings/Settings.js +196 -1
  31. package/dist/common/settings/SettingsBarIcons.js +61 -1
  32. package/dist/context/DashAutoAdminFormContext.js +15 -1
  33. package/dist/hooks/useAutoAdminLoadingStateMediator.js +36 -1
  34. package/dist/hooks/useAutoAdminTranslate.js +61 -1
  35. package/dist/hooks/useHash.js +24 -1
  36. package/dist/hooks/useLogger.js +20 -1
  37. package/dist/hooks/useRoutePathPattern.js +20 -1
  38. package/dist/hooks/useVirtualHash.js +28 -1
  39. package/dist/index.js +77 -3406
  40. package/dist/list/DashAutoListActions.js +57 -1
  41. package/dist/list/DashAutoListDatagridWrapper.js +68 -1
  42. package/dist/list/DashAutoListDefaultActionsWrapper.js +14 -1
  43. package/dist/list/DashAutoListFilterFormWithButton.js +80 -1
  44. package/dist/list/DashAutoListTopToolbar.js +180 -1
  45. package/dist/mui/AttributeToField.js +576 -1
  46. package/dist/mui/AttributeToInput.js +630 -1
  47. package/dist/mui/AutoAdminResizableDrawer.js +63 -1
  48. package/dist/mui/AutoDataGrid.js +120 -1
  49. package/dist/mui/AutoReferenceFormTab.js +53 -1
  50. package/dist/mui/AutoReferenceTab.js +46 -1
  51. package/dist/mui/AutoTabs.js +19 -1
  52. package/dist/mui/components/ExtendedPagination.js +34 -1
  53. package/dist/mui/components/ListStringField.js +25 -1
  54. package/dist/providers/DashAuthProvider.js +215 -1
  55. package/dist/providers/DashDataProvider.js +310 -1
  56. package/dist/providers/index.js +10 -1
  57. package/dist/react-admin.d.js +0 -0
  58. package/dist/toolbar/buttons/BottomToolbarButtons.js +65 -1
  59. package/dist/toolbar/buttons/DashResourceButton.js +181 -1
  60. package/dist/toolbar/buttons/ListButtons.js +80 -1
  61. package/dist/toolbar/buttons/ToolbarButtons.js +135 -1
  62. package/dist/types/ActionCallback.d.js +0 -0
  63. package/dist/utils/SimpleLogger.js +52 -1
  64. package/dist/utils/enumToChoices.js +5 -1
  65. package/dist/utils/evalActionPermission.js +11 -1
  66. package/dist/utils/groupByTabs.js +21 -1
  67. package/dist/utils/hashedGroupByTabs.js +12 -1
  68. package/dist/utils/invertMap.js +12 -1
  69. package/dist/utils/isClassComponent.js +7 -1
  70. package/dist/utils/isComponent.js +29 -1
  71. package/dist/utils/isEnum.js +5 -1
  72. package/dist/utils/isFC.js +8 -1
  73. package/dist/utils/replaceParams.js +9 -1
  74. package/dist/utils/validate.js +19 -1
  75. package/dist/wrappers/UserAction.js +60 -1
  76. package/dist/wrappers/index.js +4 -1
  77. package/package.json +135 -120
  78. package/src/DashAutoAdminComponentRegistry.tsx +75 -0
  79. package/src/DashAutoAdminForm.tsx +155 -0
  80. package/src/DashAutoAdminResizableDrawer.tsx +69 -0
  81. package/src/DashAutoAdminSaveButton.tsx +116 -0
  82. package/src/DashAutoCreate.tsx +118 -0
  83. package/src/DashAutoDrawer.tsx +288 -0
  84. package/src/DashAutoEdit.tsx +109 -0
  85. package/src/DashAutoFiltersGenerator.tsx +208 -0
  86. package/src/DashAutoFormGroups.tsx +146 -0
  87. package/src/DashAutoFormLayout.tsx.review +113 -0
  88. package/src/DashAutoFormMuiTabs.tsx +368 -0
  89. package/src/DashAutoFormTabs.tsx +177 -0
  90. package/src/DashAutoGroup.tsx +42 -0
  91. package/src/DashAutoLayout.tsx +57 -0
  92. package/src/DashAutoList.tsx +237 -0
  93. package/src/DashAutoPostFilterForm.tsx +35 -0
  94. package/src/DashAutoReferenceTab.tsx +9 -0
  95. package/src/DashAutoResource.tsx +85 -0
  96. package/src/DashAutoResourceLayout.tsx +50 -0
  97. package/src/DashAutoShow.tsx +200 -0
  98. package/src/DashAutoTabbedForm.review.tsx +262 -0
  99. package/src/DashAutoTabbedForm.tsx +324 -0
  100. package/src/DashAutoTabs.tsx +19 -0
  101. package/src/DashFilterWrapper.tsx +43 -0
  102. package/src/DashRedirect.tsx +46 -0
  103. package/src/TabbedLayout.tsx +29 -0
  104. package/src/common/DashAutoTitle.tsx +24 -0
  105. package/src/common/components/FabButton.tsx +40 -0
  106. package/src/common/components/TranslatedLabel.tsx +81 -0
  107. package/src/common/settings/Settings.tsx +236 -0
  108. package/src/common/settings/SettingsBarIcons.tsx +72 -0
  109. package/src/context/DashAutoAdminFormContext.tsx +31 -0
  110. package/src/hooks/useAutoAdminLoadingStateMediator.tsx +42 -0
  111. package/src/hooks/useAutoAdminTranslate.tsx +106 -0
  112. package/src/hooks/useHash.tsx +27 -0
  113. package/src/hooks/useLogger.tsx +23 -0
  114. package/src/hooks/useRoutePathPattern.tsx +24 -0
  115. package/src/hooks/useVirtualHash.tsx +34 -0
  116. package/src/index.ts +85 -0
  117. package/src/interfaces/ICustomResourceSubComponent.ts +11 -0
  118. package/src/interfaces/IDashApplicationLayoutMainAction.ts +37 -0
  119. package/src/interfaces/IDashApplicationLayoutMenuItem.ts +24 -0
  120. package/src/interfaces/IDashAutoAdminAttribute.ts +104 -0
  121. package/src/interfaces/IDashAutoAdminCustomFieldComponent.ts +18 -0
  122. package/src/interfaces/IDashAutoAdminFormOptions.ts +22 -0
  123. package/src/interfaces/IDashAutoAdminListActions.ts +13 -0
  124. package/src/interfaces/IDashAutoAdminReference.ts +16 -0
  125. package/src/interfaces/IDashAutoAdminResourceConfig.ts +360 -0
  126. package/src/interfaces/IDashAutoForm.ts +24 -0
  127. package/src/interfaces/IDashAutoGridButton.ts +35 -0
  128. package/src/interfaces/IDashAutoShow.ts +12 -0
  129. package/src/interfaces/IGroupExtraData.ts +8 -0
  130. package/src/interfaces/IRecord.ts +7 -0
  131. package/src/interfaces/IReferenceFilter.ts +55 -0
  132. package/src/interfaces/IResourceComponent.ts +8 -0
  133. package/src/interfaces/IToolbarButton.ts +11 -0
  134. package/src/list/DashAutoListActions.tsx +88 -0
  135. package/src/list/DashAutoListDatagridWrapper.tsx +74 -0
  136. package/src/list/DashAutoListDefaultActionsWrapper.tsx +31 -0
  137. package/src/list/DashAutoListFilterFormWithButton.tsx +93 -0
  138. package/src/list/DashAutoListTopToolbar.tsx +240 -0
  139. package/src/mui/AttributeToField.tsx +657 -0
  140. package/src/mui/AttributeToInput.tsx +728 -0
  141. package/src/mui/AutoAdminResizableDrawer.tsx +69 -0
  142. package/src/mui/AutoDataGrid.tsx +127 -0
  143. package/src/mui/AutoReferenceFormTab.tsx +51 -0
  144. package/src/mui/AutoReferenceTab.tsx +45 -0
  145. package/src/mui/AutoTabs.tsx +32 -0
  146. package/src/mui/components/ExtendedPagination.tsx +23 -0
  147. package/src/mui/components/ListStringField.tsx +32 -0
  148. package/src/providers/DashAuthProvider.ts +341 -0
  149. package/src/providers/DashDataProvider.ts +466 -0
  150. package/src/providers/index.ts +17 -0
  151. package/src/toolbar/buttons/BottomToolbarButtons.tsx +59 -0
  152. package/src/toolbar/buttons/DashResourceButton.tsx +223 -0
  153. package/src/toolbar/buttons/ListButtons.tsx +137 -0
  154. package/src/toolbar/buttons/ToolbarButtons.tsx +186 -0
  155. package/src/utils/SimpleLogger.tsx +46 -0
  156. package/src/utils/enumToChoices.tsx +3 -0
  157. package/src/utils/evalActionPermission.tsx +14 -0
  158. package/src/utils/groupByTabs.tsx +23 -0
  159. package/src/utils/hashedGroupByTabs.tsx +16 -0
  160. package/src/utils/invertMap.tsx +10 -0
  161. package/src/utils/isClassComponent.tsx +9 -0
  162. package/src/utils/isComponent.tsx +45 -0
  163. package/src/utils/isEnum.tsx +3 -0
  164. package/src/utils/isFC.tsx +6 -0
  165. package/src/utils/replaceParams.tsx +6 -0
  166. package/src/utils/validate.tsx +24 -0
  167. package/src/wrappers/UserAction.tsx +67 -0
  168. package/src/wrappers/index.tsx +1 -0
  169. /package/{dist → src}/DashAutoAdminSaveButton.tsx.bkup +0 -0
  170. /package/{dist/DashAutoFormLayout.tsx.review → src/DashAutoFormLayout.tsx} +0 -0
  171. /package/{dist → src}/DashAutoFormTabs.review +0 -0
  172. /package/{dist → src}/DashAutoFormTabs.tsx.formcontext.wip +0 -0
  173. /package/{dist → src}/mui/AttributeToField.tsx.review +0 -0
  174. /package/{dist → src}/mui/AttributeToInput.tsx.review +0 -0
  175. /package/{dist → src}/react-admin.d.ts +0 -0
  176. /package/{dist → src}/types/ActionCallback.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,3411 +1,82 @@
1
- import { jsx as r, Fragment as E, jsxs as T } from "react/jsx-runtime";
2
- import { SelectInput as lt, ReferenceInput as wt, DateInput as Qt, TextInput as At, SelectArrayInput as gt, Pagination as Pe, ListContext as ut, WithRecord as It, Button as Zt, TextField as Ut, FunctionField as tt, ReferenceArrayField as vt, SingleFieldList as Bt, ChipField as Et, ArrayField as Se, Datagrid as Yt, ReferenceField as Fe, FileInput as Tt, FileField as te, ImageInput as Dt, ImageField as ee, DateField as Le, DateTimeInput as ae, BooleanField as jt, NumberField as ke, useRedirect as re, useResourceContext as _t, useRecordContext as bt, DeleteWithConfirmButton as Mt, ShowButton as Ie, EditButton as st, DeleteButton as U, useUnselectAll as Gt, FilterFormBase as _e, SaveButton as Pt, CreateButton as pt, ListButton as nt, ExportButton as yt, FilterForm as Me, useRefresh as Ge, SavedQueriesList as $e, List as Re, useDataProvider as oe, Loading as le, SimpleForm as Y, TabbedForm as Oe, useTranslate as et, Create as Ne, Toolbar as mt, TopToolbar as W, Edit as xe, Tab as se, TabbedShowLayout as We, SimpleShowLayout as ne, Show as X, ReferenceArrayInput as Ht, ArrayInput as Ve, SimpleFormIterator as ze, BooleanInput as Ce, NumberInput as Ue, PasswordInput as je, useEditContext as He, FormTab as K, ReferenceManyField as Je } from "react-admin";
3
- import * as O from "react";
4
- import S, { useContext as at, useState as R, useEffect as _, createContext as ie, createElement as P, memo as rt, useMemo as $, cloneElement as qe, useCallback as z } from "react";
5
- import { useParams as $t, useLocation as Rt } from "react-router";
6
- import { Chip as Ke, InputLabel as ce, IconButton as Xe, Tooltip as it, TableContainer as Qe, CircularProgress as Ze, Fab as de, Box as N, Button as ue, Collapse as Ye, SwipeableDrawer as ta, Drawer as ea, InputAdornment as aa, Typography as ra, Tabs as Ot, Tab as Nt } from "@mui/material";
7
- import x from "prop-types";
8
- import { DASHAppConstants as oa, DASHAdminSystemConstants as la } from "@dashadmin/dash-constants";
9
- import { Edit as sa, Visibility as na, Add as ia, Refresh as ca } from "@mui/icons-material";
10
- import da from "@mui/icons-material/Settings";
11
- import ua from "@mui/icons-material/FilterAltOff";
12
- import { useForm as ba, FormProvider as ma, useFormContext as xt, get as ha } from "react-hook-form";
13
- import fa from "@mui/icons-material/KeyboardArrowUp";
14
- import pa from "@mui/icons-material/KeyboardArrowDown";
15
- import ya from "@mui/icons-material/Search";
16
- import { useSelector as wa, useDispatch as Wt } from "react-redux";
17
- import { match as Jt } from "node-match-path";
18
- import Aa from "@mui/icons-material/Visibility";
19
- import Q from "query-string";
20
- const ga = (e, a) => {
21
- const {
22
- label: t,
23
- source: o,
24
- reference: c,
25
- optionText: u,
26
- alwaysOn: l = !0,
27
- referenceComponent: m,
28
- fieldProps: b = {},
29
- slotProps: d = {},
30
- inputOptions: i = {},
31
- multiple: n = !1,
32
- date: f = !1
33
- } = e;
34
- if (console.log("🔧 DashAutoFiltersGenerator DEBUG - generateFilter called:", {
35
- idx: a,
36
- label: t,
37
- source: o,
38
- reference: c,
39
- hasReferenceComponent: !!m,
40
- fieldProps: b,
41
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
42
- }), m && !c) {
43
- console.log("🔧 DashAutoFiltersGenerator DEBUG - Rendering with reference component (no reference):", {
44
- idx: a,
45
- source: o,
46
- label: t,
47
- referenceComponent: m.name,
48
- fieldProps: b,
49
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
50
- });
51
- const h = m, p = {
52
- source: o,
53
- label: t,
54
- alwaysOn: l,
55
- ...b
56
- // fieldProps contains all component-specific props
57
- };
58
- return console.log("🔧 DashAutoFiltersGenerator DEBUG - Final props for reference component (DETAILED):", {
59
- idx: a,
60
- source: o,
61
- label: t,
62
- finalProps: p,
63
- fieldPropsResource: b?.resource,
64
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
65
- }), /* @__PURE__ */ r(
66
- h,
67
- {
68
- ...p
69
- },
70
- a
71
- );
72
- }
73
- let s = m || lt;
74
- return c && typeof c == "object" ? (n && !m && (s = gt), console.log("🔗 DashAutoFiltersGenerator DEBUG - Rendering with object reference:", {
75
- idx: a,
76
- source: o,
77
- label: t,
78
- reference: c,
79
- ReferenceComponent: s.name,
80
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
81
- }), /* @__PURE__ */ r(
82
- s,
83
- {
84
- choices: c,
85
- label: t,
86
- source: o,
87
- alwaysOn: l,
88
- ...b
89
- },
90
- a
91
- )) : c ? (console.log("🔗 DashAutoFiltersGenerator DEBUG - Rendering ReferenceInput:", {
92
- idx: a,
93
- source: o,
94
- label: t,
95
- reference: c,
96
- ReferenceComponent: s.name,
97
- inputOptions: i,
98
- fieldProps: b,
99
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
100
- }), /* @__PURE__ */ r(
101
- wt,
102
- {
103
- label: t,
104
- source: o,
105
- reference: c,
106
- allowEmpty: !0,
107
- alwaysOn: l,
108
- ...i,
109
- children: /* @__PURE__ */ r(
110
- s,
111
- {
112
- label: t,
113
- optionText: u,
114
- ...b
115
- }
116
- )
117
- },
118
- a
119
- )) : f ? (console.log("📅 DashAutoFiltersGenerator DEBUG - Rendering DateInput:", {
120
- idx: a,
121
- source: o,
122
- label: t,
123
- fieldProps: b,
124
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
125
- }), /* @__PURE__ */ r(
126
- Qt,
127
- {
128
- placeholder: "Date",
129
- label: t,
130
- source: o,
131
- alwaysOn: l,
132
- ...b
133
- },
134
- a
135
- )) : (console.log("📝 DashAutoFiltersGenerator DEBUG - Rendering TextInput (default):", {
136
- idx: a,
137
- source: o,
138
- label: t,
139
- fieldProps: b,
140
- slotProps: d,
141
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
142
- }), /* @__PURE__ */ r(
143
- At,
144
- {
145
- label: t,
146
- source: o,
147
- alwaysOn: l,
148
- ...b,
149
- ...d ? { slotProps: d } : {}
150
- },
151
- a
152
- ));
153
- }, va = (e, a) => {
154
- const t = e?.referenceFilters || [], o = [];
155
- return console.log("🏭 DashAutoFiltersGenerator DEBUG - dashAutoFiltersGenerator called:", {
156
- resourceConfig: e?.model || "unknown",
157
- filtersCount: t.length,
158
- filters: t.map((c) => ({
159
- id: c.id,
160
- source: c.source,
161
- label: c.label,
162
- hasReferenceComponent: !!c.referenceComponent,
163
- fieldProps: c.fieldProps
164
- })),
165
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
166
- }), t && t.length > 0 && t.forEach((c, u) => {
167
- o.push(ga(c, u));
168
- }), o;
169
- }, Ba = () => at(ut) ?? null, St = (e) => {
170
- const a = Ba();
171
- return a && a.total > a.perPage ? (
172
- // @ts-ignore - pageSizeOptions prop compatibility
173
- /* @__PURE__ */ r(Pe, { pageSizeOptions: [25, 50, 100, 250, 500, 1e3], ...e })
174
- ) : /* @__PURE__ */ r(E, {});
175
- }, Ea = ({
176
- resourceConfig: e,
177
- autoFilters: a,
178
- children: t
179
- }) => !(a && a.length || e.create || e.exporter || e.customToolbarElements) ? t : /* @__PURE__ */ r("div", { className: "top-toolbar-default", children: t }), Ta = (e) => {
180
- const a = R(!1), t = R(null);
181
- return _(() => {
182
- t[0] && (t[0]?.origin && /* @ts-ignore : An expression of type 'void' cannot be tested for truthiness.ts(1345). */
183
- t[0].origin === e && a[1](t[0].data) || a[1](t[0]?.data));
184
- }, [t[0]]), S.useEffect(() => (window.addEventListener(
185
- "auto-admin-loading-state",
186
- (o) => t[1](o)
187
- ), () => {
188
- window.removeEventListener(
189
- "auto-admin-loading-state",
190
- (o) => t[1](o)
191
- );
192
- }), []), a;
193
- }, Da = (e) => typeof e > "u" ? !1 : !!e.name, be = (e) => {
194
- const { method: a, attribute: t, resourceConfig: o, record: c, options: u } = e, l = u?.locale || e.locale;
195
- if (t.component && Da(t.component)) {
196
- const m = t.component;
197
- return /* @__PURE__ */ r(
198
- m,
199
- {
200
- method: a,
201
- attribute: t,
202
- resourceConfig: o,
203
- ...c && { record: c },
204
- ...t?.componentProps,
205
- locale: l,
206
- options: u
207
- }
208
- );
209
- }
210
- if (typeof t.action == "function") {
211
- const m = t.action;
212
- return /* @__PURE__ */ r(
213
- It,
214
- {
215
- label: t.label,
216
- render: (b) => /* @__PURE__ */ r(Zt, { value: t.label, onClick: () => m(b.id), children: /* @__PURE__ */ r(E, { children: t.label }) })
217
- }
218
- );
219
- }
220
- return null;
221
- }, Pa = (e) => {
222
- if (!e)
223
- return !1;
224
- const a = {};
225
- return Object.keys(e).forEach((t) => a[e[t]] = t), a;
226
- }, me = ({
227
- record: e,
228
- source: a,
229
- map: t
230
- }) => {
231
- const o = Pa(t);
232
- return /* @__PURE__ */ r(E, { children: e[a].map((c) => [
233
- /* @__PURE__ */ r(
234
- Ke,
235
- {
236
- label: o && o[c] ? o[c] : c
237
- },
238
- c
239
- ),
240
- /* @__PURE__ */ r(E, { children: " " })
241
- ]) });
242
- };
243
- me.defaultProps = { addLabel: !0 };
244
- const Ft = (e) => typeof e == "object" && !(e.attribute && e.type);
245
- function ct(e, a) {
246
- delete e["*"];
247
- const t = new RegExp(`{(${Object.keys(e).join("|")})+}`, "g");
248
- return a.replace(t, (o, c) => e[c]);
249
- }
250
- const he = {}, fe = ie({
251
- components: he,
252
- registerComponent: () => {
253
- },
254
- registerComponents: () => {
255
- }
256
- }), pe = () => at(fe), $r = ({
257
- children: e,
258
- customComponents: a = {}
259
- }) => {
260
- const [t, o] = S.useState({
261
- ...he,
262
- ...a
263
- });
264
- S.useEffect(() => {
265
- a && Object.keys(a).length > 0 && o((l) => ({
266
- ...l,
267
- ...a
268
- }));
269
- }, [a]);
270
- const c = S.useCallback((l, m) => {
271
- o((b) => ({
272
- ...b,
273
- [l]: m
274
- }));
275
- }, []), u = S.useCallback((l) => {
276
- o((m) => ({
277
- ...m,
278
- ...l
279
- }));
280
- }, []);
281
- return /* @__PURE__ */ r(
282
- fe.Provider,
283
- {
284
- value: {
285
- components: t,
286
- registerComponent: c,
287
- registerComponents: u
288
- },
289
- children: e
290
- }
291
- );
292
- }, ot = (e, a, t, o, c, u, l) => {
293
- const { components: m } = pe(), b = $t(), d = t.sortable === !0, i = (s) => {
294
- const h = m[s];
295
- return h ? { custom: !0, type: "component", component: h } : { custom: !0, type: "component", component: () => /* @__PURE__ */ T(E, { children: [
296
- "No component for ",
297
- s
298
- ] }) };
299
- }, n = a?.fieldWrapper && typeof a.fieldWrapper == "function" ? a.fieldWrapper : ({
300
- _record: s,
301
- _method: h,
302
- _attribute: p,
303
- _resourceConfig: y,
304
- children: A
305
- }) => A;
306
- if (l = c?.record ? c.record : l, c && c.useReadOnlyInputAsTextField === !0 && t.readOnly)
307
- return /* @__PURE__ */ r(
308
- n,
309
- {
310
- label: t.label,
311
- sortable: d,
312
- source: t.listAttribute ? t.listAttribute : t.attribute,
313
- ...l && { record: l },
314
- method: e,
315
- attribute: t,
316
- resourceConfig: a,
317
- children: /* @__PURE__ */ P(
318
- Ut,
319
- {
320
- ...l && { record: l },
321
- sortable: d,
322
- ...d && {
323
- sortBy: t.listAttribute || t.attribute
324
- },
325
- key: o,
326
- label: t.label,
327
- source: t.listAttribute ? t.listAttribute : t.attribute,
328
- ...t.fieldProps,
329
- editable: !1,
330
- InputProps: { readOnly: !0 },
331
- disabled: !0
332
- }
333
- )
334
- },
335
- o
336
- );
337
- if (c && c.readOnlyComponent && t.readOnly)
338
- return /* @__PURE__ */ P(
339
- n,
340
- {
341
- ...l && { record: l },
342
- method: e,
343
- attribute: t,
344
- key: o,
345
- label: t.label,
346
- sortable: d,
347
- source: t.listAttribute ? t.listAttribute : t.attribute,
348
- resourceConfig: a
349
- },
350
- /* @__PURE__ */ r(
351
- c.readOnlyComponent,
352
- {
353
- ...l && { record: l },
354
- sortable: d,
355
- ...d && {
356
- sortBy: t.listAttribute || t.attribute
357
- },
358
- input: t,
359
- label: t.label,
360
- source: t.listAttribute ? t.listAttribute : t.attribute,
361
- ...t.fieldProps,
362
- editable: !1,
363
- InputProps: { readOnly: !0 }
364
- },
365
- o
366
- )
367
- );
368
- if (typeof t.type == "string" && !t.type.includes(".") && !Array.isArray(t.type))
369
- switch (t.type) {
370
- case "string":
371
- case "text":
372
- case "String":
373
- t.type = String;
374
- break;
375
- case "number":
376
- case "Number":
377
- case "integer":
378
- t.type = Number;
379
- break;
380
- case "boolean":
381
- case "Boolean":
382
- t.type = Boolean;
383
- break;
384
- case "date":
385
- case "Date":
386
- t.type = Date;
387
- break;
388
- default:
389
- t.custom = !0, typeof t?.component == "string" && (t = { ...t, ...i(t.component) });
390
- break;
391
- }
392
- if (t.custom && t.component || t.type === "component" && t.component)
393
- return /* @__PURE__ */ r(
394
- tt,
395
- {
396
- label: t.label,
397
- sortable: d,
398
- ...d && {
399
- sortBy: t.listAttribute || t.attribute
400
- },
401
- render: (s) => /* @__PURE__ */ P(
402
- n,
403
- {
404
- ...s && { record: s },
405
- method: e,
406
- attribute: t,
407
- key: o,
408
- label: t.label,
409
- sortable: d,
410
- source: t.listAttribute ? t.listAttribute : t.attribute,
411
- resourceConfig: a
412
- },
413
- /* @__PURE__ */ r(
414
- be,
415
- {
416
- ...s && { record: s },
417
- method: e,
418
- attribute: t,
419
- resourceConfig: a,
420
- options: c
421
- },
422
- `custom_component_${o}`
423
- )
424
- )
425
- },
426
- `function_field_${o}`
427
- );
428
- if (Array.isArray(t.type) && t.type.length > 0) {
429
- const s = t.type[0];
430
- if (t.label || (t.label = t.attribute), Ft(s))
431
- return /* @__PURE__ */ P(
432
- n,
433
- {
434
- ...l && { record: l },
435
- method: e,
436
- attribute: t,
437
- key: o,
438
- label: t.label,
439
- sortable: d,
440
- source: t.listAttribute ? t.listAttribute : t.attribute,
441
- resourceConfig: a
442
- },
443
- /* @__PURE__ */ r(
444
- me,
445
- {
446
- label: t.label,
447
- source: t.listAttribute ? t.listAttribute : t.attribute,
448
- map: s
449
- },
450
- o
451
- )
452
- );
453
- if (typeof s == "string") {
454
- const h = { ...b, ...(location.hash.match(/\d+/g) || []).map(Number).reduce((w, g, B) => (w[B] = g, w), {}) }, p = ct(h, s), [y, A] = p.split(".");
455
- return /* @__PURE__ */ P(
456
- n,
457
- {
458
- ...l && { record: l },
459
- method: e,
460
- attribute: t,
461
- key: o,
462
- label: t.label,
463
- sortable: d,
464
- source: t.listAttribute ? t.listAttribute : t.attribute,
465
- resourceConfig: a
466
- },
467
- /* @__PURE__ */ r(E, { children: /* @__PURE__ */ r(
468
- vt,
469
- {
470
- sortable: d,
471
- ...d && {
472
- sortBy: t.listAttribute || t.attribute
473
- },
474
- label: t.label,
475
- source: t.listAttribute ? t.listAttribute : t.attribute,
476
- reference: y,
477
- ...t.componentProps,
478
- children: /* @__PURE__ */ r(Bt, { ...t.fieldProps, children: /* @__PURE__ */ r(Et, { source: A }) })
479
- },
480
- o
481
- ) })
482
- );
483
- } else {
484
- const h = t.type;
485
- return /* @__PURE__ */ P(
486
- n,
487
- {
488
- ...l && { record: l },
489
- method: e,
490
- attribute: t,
491
- key: o,
492
- label: t.label,
493
- sortable: d,
494
- source: t.listAttribute ? t.listAttribute : t.attribute,
495
- resourceConfig: a,
496
- ...t.componentProps
497
- },
498
- /* @__PURE__ */ r(E, { children: /* @__PURE__ */ r(
499
- Se,
500
- {
501
- sortable: d,
502
- ...d && {
503
- sortBy: t.listAttribute || t.attribute
504
- },
505
- label: t.label,
506
- source: t.listAttribute ? t.listAttribute : t.attribute,
507
- ...t.fieldProps,
508
- children: /* @__PURE__ */ r(Yt, { children: h.map(
509
- (p, y) => ot(
510
- e,
511
- a,
512
- p,
513
- y,
514
- c
515
- )
516
- ) })
517
- },
518
- o
519
- ) })
520
- );
521
- }
522
- }
523
- if (typeof t.type == "string") {
524
- const s = { ...b, ...(location.hash.match(/\d+/g) || []).map(Number).reduce((g, B, v) => (g[v] = B, g), {}) }, h = ct(s, t.type), [p, y] = h.split(".");
525
- if (t && t.multiple === !1) {
526
- const g = {
527
- ...l && { record: l },
528
- method: e,
529
- attribute: t,
530
- label: t.label,
531
- sortable: d,
532
- source: t.listAttribute ? t.listAttribute : t.attribute,
533
- resourceConfig: a
534
- }, B = {
535
- ...l && { record: l },
536
- sortable: d,
537
- ...d && {
538
- sortBy: t.listAttribute || t.attribute
539
- },
540
- label: t.label,
541
- link: "show",
542
- source: t.listAttribute ? t.listAttribute : t.attribute,
543
- reference: p,
544
- ...t.componentProps
545
- };
546
- return /* @__PURE__ */ r(
547
- n,
548
- {
549
- ...g,
550
- children: /* @__PURE__ */ r(
551
- Fe,
552
- {
553
- ...B
554
- }
555
- )
556
- }
557
- );
558
- }
559
- const A = {
560
- ...l && { record: l },
561
- method: e,
562
- attribute: t,
563
- label: t.label,
564
- sortable: d,
565
- source: t.listAttribute ? t.listAttribute : t.attribute,
566
- resourceConfig: a
567
- }, w = {
568
- ...l && { record: l },
569
- sortable: d,
570
- ...d && {
571
- sortBy: t.listAttribute || t.attribute
572
- },
573
- label: t.label,
574
- source: t.listAttribute ? t.listAttribute : t.attribute,
575
- reference: p
576
- };
577
- return /* @__PURE__ */ r(n, { ...A, children: /* @__PURE__ */ r(vt, { ...w, children: /* @__PURE__ */ r(Bt, { ...t.fieldProps, children: /* @__PURE__ */ r(Et, { source: y }) }) }) });
578
- }
579
- switch (t.type) {
580
- case Number:
581
- return /* @__PURE__ */ P(
582
- tt,
583
- {
584
- label: t.label,
585
- sortable: d,
586
- ...d && {
587
- sortBy: t.listAttribute || t.attribute
588
- },
589
- key: `function_field_${o}`,
590
- render: (s) => /* @__PURE__ */ P(
591
- n,
592
- {
593
- ...s && { record: s },
594
- method: e,
595
- attribute: t,
596
- key: o,
597
- label: t.label,
598
- sortable: d,
599
- source: t.listAttribute ? t.listAttribute : t.attribute,
600
- resourceConfig: a
601
- },
602
- /* @__PURE__ */ r(
603
- ke,
604
- {
605
- label: t.label,
606
- ...l && { record: l },
607
- sortable: t.sortable === !0,
608
- source: t.listAttribute ? t.listAttribute : t.attribute,
609
- ...t.fieldProps
610
- },
611
- `number_field_${o}`
612
- )
613
- )
614
- }
615
- );
616
- case Boolean:
617
- return l ? /* @__PURE__ */ T(E, { children: [
618
- t?.showLabel !== !1 && /* @__PURE__ */ P(
619
- n,
620
- {
621
- ...l && { record: l },
622
- method: e,
623
- attribute: t,
624
- key: o,
625
- label: t.label,
626
- sortable: d,
627
- source: t.listAttribute ? t.listAttribute : t.attribute,
628
- resourceConfig: a
629
- },
630
- /* @__PURE__ */ r(
631
- ce,
632
- {
633
- htmlFor: t.listAttribute ? t.listAttribute : t.attribute,
634
- children: t.label
635
- }
636
- )
637
- ),
638
- /* @__PURE__ */ P(
639
- n,
640
- {
641
- ...l && { record: l },
642
- method: e,
643
- attribute: t,
644
- key: o,
645
- label: t.label,
646
- sortable: d,
647
- source: t.listAttribute ? t.listAttribute : t.attribute,
648
- resourceConfig: a
649
- },
650
- /* @__PURE__ */ P(
651
- jt,
652
- {
653
- sortable: d,
654
- ...d && {
655
- sortBy: t.listAttribute || t.attribute
656
- },
657
- record: l,
658
- key: o,
659
- id: t.listAttribute ? t.listAttribute : t.attribute,
660
- label: t.label,
661
- source: t.listAttribute ? t.listAttribute : t.attribute,
662
- ...t.fieldProps
663
- }
664
- )
665
- )
666
- ] }) : /* @__PURE__ */ r(
667
- tt,
668
- {
669
- label: t.label,
670
- sortable: d,
671
- ...d && {
672
- sortBy: t.listAttribute || t.attribute
673
- },
674
- render: (s) => /* @__PURE__ */ r(E, { children: /* @__PURE__ */ P(
675
- n,
676
- {
677
- ...s && { record: s },
678
- method: e,
679
- attribute: t,
680
- key: o,
681
- label: t.label,
682
- sortable: d,
683
- source: t.listAttribute ? t.listAttribute : t.attribute,
684
- resourceConfig: a
685
- },
686
- /* @__PURE__ */ r(
687
- jt,
688
- {
689
- record: l,
690
- id: t.listAttribute ? t.listAttribute : t.attribute,
691
- label: t.label,
692
- source: t.listAttribute ? t.listAttribute : t.attribute,
693
- ...t.fieldProps
694
- },
695
- o
696
- )
697
- ) })
698
- }
699
- );
700
- case ae:
701
- case Date:
702
- return /* @__PURE__ */ P(
703
- n,
704
- {
705
- ...l && { record: l },
706
- method: e,
707
- attribute: t,
708
- label: t.label,
709
- sortable: d,
710
- source: t.listAttribute ? t.listAttribute : t.attribute,
711
- key: o,
712
- resourceConfig: a
713
- },
714
- /* @__PURE__ */ P(
715
- Le,
716
- {
717
- ...l && { record: l },
718
- key: o,
719
- sortable: d,
720
- ...d && {
721
- sortBy: t.listAttribute || t.attribute
722
- },
723
- label: t.label,
724
- showTime: t.fieldProps && t.fieldProps.showTime || !1,
725
- source: t.listAttribute ? t.listAttribute : t.attribute,
726
- ...t.fieldProps
727
- }
728
- )
729
- );
730
- case Dt:
731
- return /* @__PURE__ */ P(
732
- n,
733
- {
734
- ...l && { record: l },
735
- method: e,
736
- attribute: t,
737
- key: o,
738
- label: t.label,
739
- sortable: d,
740
- source: t.listAttribute ? t.listAttribute : t.attribute,
741
- resourceConfig: a
742
- },
743
- /* @__PURE__ */ P(
744
- ee,
745
- {
746
- ...l && { record: l },
747
- sortable: d,
748
- ...d && {
749
- sortBy: t.listAttribute || t.attribute
750
- },
751
- key: o,
752
- source: t.attribute,
753
- label: t.label
754
- }
755
- )
756
- );
757
- case Tt:
758
- return /* @__PURE__ */ P(
759
- n,
760
- {
761
- ...l && { record: l },
762
- method: e,
763
- attribute: t,
764
- key: o,
765
- label: t.label,
766
- sortable: d,
767
- source: t.listAttribute ? t.listAttribute : t.attribute,
768
- resourceConfig: a
769
- },
770
- /* @__PURE__ */ P(
771
- te,
772
- {
773
- ...l && { record: l },
774
- sortable: d,
775
- ...d && {
776
- sortBy: t.listAttribute || t.attribute
777
- },
778
- key: o,
779
- source: t.listAttribute ?? t.attribute,
780
- title: t.listAttribute,
781
- download: !0
782
- }
783
- )
784
- );
785
- }
786
- const f = {
787
- ...l && { record: l },
788
- sortable: d,
789
- ...d && {
790
- sortBy: t.listAttribute || t.attribute
791
- },
792
- label: t.label,
793
- source: t.listAttribute ? t.listAttribute : t.attribute,
794
- ...t.fieldProps,
795
- ...t.slotProps ? { slotProps: t.slotProps } : {}
796
- };
797
- return /* @__PURE__ */ r(
798
- n,
799
- {
800
- label: t.label,
801
- sortable: d,
802
- source: t.listAttribute ? t.listAttribute : t.attribute,
803
- ...l && { record: l },
804
- method: e,
805
- attribute: t,
806
- resourceConfig: a,
807
- children: /* @__PURE__ */ r(
808
- Ut,
809
- {
810
- ...f
811
- }
812
- )
813
- }
814
- );
815
- }, Sa = () => {
816
- const [e, a] = S.useState(() => window.location.hash), t = S.useCallback((u) => {
817
- a(u.data);
818
- }, []);
819
- S.useEffect(() => (window.addEventListener("virtualhash", t), () => {
820
- window.removeEventListener("virtualhash", t);
821
- }), []);
822
- const o = S.useCallback(
823
- (u) => {
824
- history.replaceState(null, "", u), window.dispatchEvent(new MessageEvent("virtualhash", { data: u }));
825
- },
826
- [e]
827
- );
828
- return { hash: e, setVirtualHash: (u) => {
829
- o(u);
830
- } };
831
- }, Fa = oa.system.URL_PREFIX, qt = {
832
- true: { _scrollToTop: !0 },
833
- false: {}
834
- }, ye = (e) => {
835
- const a = re(), t = e.children?.type || Xe, o = { ...e, ...e.children?.props };
836
- let {
837
- navigate: c,
838
- scrollToTop: u,
839
- mode: l,
840
- size: m,
841
- navigation: b,
842
- resourceConfig: d,
843
- record: i,
844
- resource: n,
845
- showIcon: f = !0,
846
- title: s,
847
- icon: h,
848
- ...p
849
- } = o;
850
- const y = n || _t(), A = i || bt();
851
- m || (m = "small"), b || (b = d?.drawer ? l === "edit" && d.drawerOptions?.edit === !1 || l === "show" && d.drawerOptions?.show === !1 || l === "create" && d.drawerOptions?.create === !1 ? "redirect" : "virtualhash" : "redirect"), c || (c = (D) => `${Fa}${y}/${b === "virtualhash" ? "inline" : ""}${l === "edit" ? "/" + D.id + "/edit" : l === "show" ? "/" + D.id + "/show" : l === "create" ? "/create" : ""}`);
852
- const { setVirtualHash: w } = Sa(), g = (D) => {
853
- if (D.preventDefault(), D.stopPropagation(), o.onClick) {
854
- o.onClick(D);
855
- return;
856
- }
857
- if (b === "virtualhash") {
858
- const I = c(A);
859
- w(I);
860
- }
861
- b === "redirect" && (l === "create" ? a(l, y) : a(l, y, A.id));
862
- }, B = m === "small" ? {
863
- "& .MuiButton-startIcon": { margin: 0 },
864
- "& .MuiButton-text": { paddingLeft: "4px" },
865
- borderRadius: "50% !important",
866
- padding: 0,
867
- minWidth: "30px",
868
- width: "30px",
869
- height: "30px",
870
- overflow: "hidden"
871
- } : {}, v = m === "small" ? "" : e?.label;
872
- if (l === "destroy")
873
- return /* @__PURE__ */ r(it, { title: e?.label, children: /* @__PURE__ */ r(Mt, { label: v, sx: { ...B }, size: m, record: A }) });
874
- if (l === "custom") {
875
- const { title: D, ...I } = p;
876
- return /* @__PURE__ */ r(it, { title: e?.label, children: /* @__PURE__ */ r(
877
- t,
878
- {
879
- onClick: (M) => g(M),
880
- state: qt[String(u)],
881
- size: m,
882
- ...I
883
- }
884
- ) });
885
- } else {
886
- if (!f && e.children)
887
- return O.cloneElement(e.children, {
888
- onClick: (H) => g(H),
889
- ...e.children.props
890
- });
891
- const { title: D, ...I } = p, M = /* @__PURE__ */ r(
892
- t,
893
- {
894
- onClick: (H) => g(H),
895
- state: qt[String(u)],
896
- size: m,
897
- title: e.children ? void 0 : D,
898
- ...I,
899
- children: f && (h || (l === "edit" ? /* @__PURE__ */ r(sa, {}) : l === "show" ? /* @__PURE__ */ r(na, {}) : l === "create" ? /* @__PURE__ */ r(ia, {}) : l))
900
- }
901
- );
902
- return /* @__PURE__ */ r(it, { title: e?.label || "", children: M });
903
- }
904
- };
905
- ye.propTypes = {
906
- icon: x.element,
907
- label: x.string,
908
- record: x.any,
909
- scrollToTop: x.bool,
910
- navigate: x.func,
911
- navigation: x.string,
912
- children: x.element,
913
- showIcon: x.bool
914
- };
915
- const Vt = rt(
916
- ye,
917
- (e, a) => e.resource === a.resource && (e.record && a.record ? e.record.id === a.record.id : e.record == a.record) && // eslint-disable-line eqeqeq
918
- e.label === a.label && e.showIcon === a.showIcon && e.icon === a.icon
919
- ), La = (e) => {
920
- const { resourceConfig: a } = e;
921
- let t = Ie;
922
- if (!a) return /* @__PURE__ */ r(t, {});
923
- if (a.listViewButton) {
924
- if (a.listViewButton.component && (t = a.listViewButton.component), a.listViewButton.enabled === !1 || a?.view === !1) return /* @__PURE__ */ r(E, {});
925
- a.listViewButton?.size || (a.listViewButton.size = "small");
926
- }
927
- const o = {
928
- mode: "show",
929
- resourceConfig: a,
930
- ...a.listViewButton?.props || {}
931
- };
932
- return /* @__PURE__ */ r(Vt, { ...o, resourceConfig: a, ...a.listDeleteButton?.props || {} });
933
- }, ka = (e) => {
934
- const { resourceConfig: a } = e;
935
- let t = st;
936
- if (!a)
937
- return /* @__PURE__ */ r(t, {});
938
- if (a.listEditButton) {
939
- if (a.listEditButton.component && (t = a.listEditButton.component), a.listEditButton.enabled === !1 || a?.edit === !1) return /* @__PURE__ */ r(E, {});
940
- a.listViewButton && !a.listViewButton?.size && (a.listViewButton.size = "small");
941
- }
942
- return /* @__PURE__ */ r(Vt, { mode: "edit", resourceConfig: a, ...a.listViewButton?.props || {} });
943
- }, Ia = (e) => {
944
- const { resourceConfig: a } = e;
945
- let t = U;
946
- if (!a) return /* @__PURE__ */ r(t, {});
947
- if (a.listDeleteButton) {
948
- if (a.listDeleteButton.component && (t = a.listDeleteButton.component), a.listDeleteButton.enabled === !1 || a?.delete === !1) return /* @__PURE__ */ r(E, {});
949
- a.listViewButton?.size || (a.listViewButton.size = "small");
950
- }
951
- return /* @__PURE__ */ r(Vt, { mode: "destroy", resourceConfig: a, ...a.listDeleteButton?.props || {} });
952
- }, _a = rt(La), Ma = rt(ka), Ga = rt(Ia), Lt = ({
953
- resourceConfig: e,
954
- schema: a,
955
- locale: t,
956
- ...o
957
- }) => {
958
- const c = t || e?.locale, u = e?.schema || a;
959
- if (!u || !u.filter)
960
- throw new Error(
961
- "Schema must be present as prop or as an attribute of resourceConfig object, and must be iterable"
962
- );
963
- const l = $(
964
- () => u.filter((s) => s.attribute === "id").length !== 0,
965
- [u]
966
- ), m = $(() => ({
967
- //...{selectedIds:[]},
968
- ...e.dataGridProps,
969
- ...o
970
- }), [e.dataGridProps, o]), b = $(
971
- () => u.filter((s) => s.inList !== !1),
972
- [u, c]
973
- ), d = rt((s) => {
974
- const { children: h, className: p, gridWrapperProps: y } = s;
975
- return /* @__PURE__ */ r(
976
- Qe,
977
- {
978
- sx: { mt: 1 },
979
- className: "dash-datagrid-wrapper " + (p || ""),
980
- ...y,
981
- children: h
982
- }
983
- );
984
- }), i = e.dataGridWrapper || d, n = e.dataGridRootComponent || Yt, f = $(() => e?.customListButtons ? e.customListButtons.map((s, h) => /* @__PURE__ */ r(
985
- s.component,
986
- {
987
- ...s.props
988
- },
989
- "list_custom_buttton" + h
990
- )) : null, [e?.customListButtons]);
991
- return /* @__PURE__ */ r(i, { className: e?.dataGridProps?.stickyHeader ? "dash-sticky-header" : "", children: /* @__PURE__ */ T(n, { ...m, children: [
992
- !l && e.hideSchemaId !== !0 && /* @__PURE__ */ r(
993
- tt,
994
- {
995
- source: "id",
996
- sortable: !0,
997
- render: (s) => {
998
- const h = s?.id;
999
- return h && isNaN(Number(h)) ? String(h).slice(-6) : h;
1000
- }
1001
- },
1002
- "default_id_field_0"
1003
- ),
1004
- b.map(
1005
- (s, h) => ot("list", e, s, h)
1006
- ),
1007
- /* @__PURE__ */ r(_a, { resourceConfig: e }, "list_view_btn"),
1008
- /* @__PURE__ */ r(Ma, { resourceConfig: e }, "list_edit_btn"),
1009
- /* @__PURE__ */ r(Ga, { resourceConfig: e }, "list_delete_btn"),
1010
- f
1011
- ] }) });
1012
- }, $a = () => at(ut) ?? null, Ra = ({
1013
- resourceConfig: e,
1014
- dataGridProps: a,
1015
- locale: t
1016
- }) => {
1017
- const c = $a()?.setFilters, u = Rt(), [l, m] = R(u.pathname), [b] = Ta("getList"), d = Gt(e.listProps?.storeKey || e.model), i = () => {
1018
- d(), c && c({}, []);
1019
- };
1020
- return _(() => {
1021
- l !== u.pathname && (e?.resetFiltersOnLocationChange === !0 && (console.info("Resetting Filters on Location change"), i()), m(u.pathname));
1022
- }, [u, l]), /* @__PURE__ */ T("div", { className: b ? "loading-overlay" : "default-overlay", children: [
1023
- b && /* @__PURE__ */ r(Ze, { className: "datagrid-olverlay-loading" }),
1024
- /* @__PURE__ */ r(Lt, { resourceConfig: e, ...a, locale: t })
1025
- ] });
1026
- }, Kt = (e) => {
1027
- const { icon: a, onClick: t, tooltip: o, children: c, ...u } = e, l = a ? qe(e.icon, { sx: { fontSize: 16 }, fontSize: "small" }) : /* @__PURE__ */ r(da, { sx: { fontSize: 16 }, fontSize: "small" });
1028
- return /* @__PURE__ */ r(it, { title: o, children: /* @__PURE__ */ r(
1029
- de,
1030
- {
1031
- size: "small",
1032
- "aria-label": "settings",
1033
- color: "primary",
1034
- onClick: t,
1035
- style: {
1036
- position: "absolute"
1037
- },
1038
- className: "toolbar-settings-button",
1039
- ...u,
1040
- children: l
1041
- }
1042
- ) });
1043
- }, Oa = () => O.useContext(ut) ?? null, Na = O.forwardRef((e, a) => {
1044
- const { filters: t, resourceConfig: o } = e, c = Oa(), u = c?.displayedFilters ?? [], l = c?.filterValues ?? {}, m = c?.setFilters, b = ba({
1045
- defaultValues: l
1046
- }), d = (f) => {
1047
- Object.keys(f).length > 0 && m && m(f, u);
1048
- };
1049
- O.useEffect(() => {
1050
- const f = (s) => {
1051
- s.key === "Enter" && (s.preventDefault(), b.handleSubmit(d)());
1052
- };
1053
- return document.addEventListener("keydown", f), () => {
1054
- document.removeEventListener("keydown", f);
1055
- };
1056
- }, []);
1057
- const { reset: i } = b, n = b.handleSubmit(d);
1058
- return O.useImperativeHandle(a, () => ({
1059
- submit() {
1060
- n();
1061
- },
1062
- reset() {
1063
- i();
1064
- }
1065
- })), /* @__PURE__ */ r(ma, { ...b, children: /* @__PURE__ */ T(N, { mb: 1, children: [
1066
- /* @__PURE__ */ r(
1067
- _e,
1068
- {
1069
- onSubmit: d,
1070
- filters: t
1071
- }
1072
- ),
1073
- o?.filterButtonPosition === "filters-container" && /* @__PURE__ */ r(ue, { className: "toolbar-filters-filter-button", onClick: () => b.handleSubmit(d)(), variant: "contained", color: "primary", type: "button", children: "Filtrar" })
1074
- ] }) });
1075
- }), j = (e) => {
1076
- const { resourceConfig: a, ...t } = e, { formState: o } = xt(), c = a?.saveButtonAlwaysEnabled === !0;
1077
- return /* @__PURE__ */ r(E, { children: /* @__PURE__ */ r(
1078
- Pt,
1079
- {
1080
- alwaysEnable: c,
1081
- ...t,
1082
- onClick: (l) => {
1083
- t?.onClick && t.onClick(l);
1084
- },
1085
- disabled: o.isSubmitting
1086
- }
1087
- ) });
1088
- }, G = (e, a) => !e || !a ? !0 : e[a] !== !1, xa = (e) => {
1089
- const { resourceConfig: a, mode: t } = e;
1090
- if (!a)
1091
- return /* @__PURE__ */ r(Pt, {});
1092
- if (!a.toolbarSaveButton)
1093
- return /* @__PURE__ */ r(Pt, {});
1094
- if (a.toolbarSaveButton?.enabled && G(a.toolbarSaveButton.modes, t)) {
1095
- const o = {
1096
- ...a.toolbarSaveButton?.props || {},
1097
- alwaysEnable: a?.saveButtonAlwaysEnabled === !0
1098
- };
1099
- return a.toolbarSaveButton?.component ? /* @__PURE__ */ r(a.toolbarSaveButton.component, { ...o }) : /* @__PURE__ */ r(j, { ...o });
1100
- }
1101
- return null;
1102
- }, we = (e) => {
1103
- const { resourceConfig: a, mode: t } = e;
1104
- return a ? a?.list !== !1 && a?.toolbarListButton && a?.toolbarListButton.enabled !== !1 ? G(a.toolbarListButton.modes, t) ? /* @__PURE__ */ r(nt, {}) : null : a.toolbarListButton?.enabled && G(a.toolbarEditButton.modes, t) ? a.toolbarListButton?.component ? /* @__PURE__ */ r(a.toolbarListButton.component, { ...a.toolbarListButton?.props || {} }) : /* @__PURE__ */ r(nt, { ...a.toolbarListButton?.props || {} }) : null : /* @__PURE__ */ r(nt, {});
1105
- }, Ae = (e) => {
1106
- const { resourceConfig: a, mode: t } = e;
1107
- return a ? a?.edit !== !1 && a?.toolbarEditButton && a?.toolbarEditButton.enabled !== !1 ? G(a.toolbarEditButton.modes, t) ? /* @__PURE__ */ r(st, {}) : null : a.toolbarEditButton?.enabled && G(a.toolbarEditButton.modes, t) ? a.toolbarEditButton?.component ? /* @__PURE__ */ r(a.toolbarEditButton.component, { ...a.toolbarEditButton?.props || {} }) : /* @__PURE__ */ r(st, { ...a.toolbarEditButton?.props || {} }) : null : /* @__PURE__ */ r(st, {});
1108
- }, ht = (e) => {
1109
- const { resourceConfig: a, mode: t } = e;
1110
- return a ? a?.create !== !1 && a?.toolbarCreateButton && a?.toolbarCreateButton.enabled !== !1 ? G(a.toolbarCreateButton.modes, t) ? /* @__PURE__ */ r(pt, {}) : null : a.toolbarCreateButton?.enabled && G(a.toolbarCreateButton.modes, t) ? a.toolbarCreateButton?.component ? /* @__PURE__ */ r(a.toolbarCreateButton.component, { ...a.toolbarCreateButton?.props || {} }) : /* @__PURE__ */ r(pt, { ...a.toolbarCreateButton?.props || {} }) : null : /* @__PURE__ */ r(pt, {});
1111
- }, zt = (e) => {
1112
- const { resourceConfig: a, mode: t } = e;
1113
- return a ? a?.delete !== !1 && a?.toolbarDeleteButton ? G(a.toolbarDeleteButton.modes, t) ? /* @__PURE__ */ r(U, {}) : null : a?.toolbarDeleteButton && a?.toolbarDeleteButton.enabled !== !1 ? G(a.toolbarCreateButton.modes, t) && a.toolbarDeleteButton?.props && a.toolbarDeleteButton.props?.confirm ? /* @__PURE__ */ r(
1114
- It,
1115
- {
1116
- render: (o) => /* @__PURE__ */ r(Mt, { record: o })
1117
- }
1118
- ) : a.toolbarDeleteButton?.component ? /* @__PURE__ */ r(a.toolbarDeleteButton.component, { ...a.toolbarDeleteButton?.props || {} }) : /* @__PURE__ */ r(U, { ...a.toolbarDeleteButton?.props || {} }) : null : /* @__PURE__ */ r(U, {});
1119
- }, Ct = (e) => {
1120
- const { resourceConfig: a, mode: t } = e;
1121
- return a ? a?.exporter !== !1 && a?.toolbarExportButton && a?.toolbarExportButton.enabled !== !1 ? G(a.toolbarExportButton.modes, t) ? /* @__PURE__ */ r(yt, {}) : null : a.toolbarExportButton?.enabled && G(a.toolbarExportButton.modes, t) ? a.toolbarExportButton?.component ? /* @__PURE__ */ r(a.toolbarExportButton.component, { ...a.toolbarExportButton?.props || {} }) : /* @__PURE__ */ r(yt, { ...a.toolbarExportButton?.props || {} }) : null : /* @__PURE__ */ r(yt, {});
1122
- }, Wa = () => at(ut) ?? null, ge = S.forwardRef((e, a) => {
1123
- const t = () => {
1124
- console.error("handleSubmit at ToolbarFilters not implemented");
1125
- }, o = () => {
1126
- console.error("reset at ToolbarFilters not implemented");
1127
- };
1128
- S.useImperativeHandle(a, () => ({
1129
- submit() {
1130
- t();
1131
- },
1132
- reset() {
1133
- o();
1134
- }
1135
- }));
1136
- const { resourceConfig: c, filters: u } = e;
1137
- return c.hideDefaultFilters !== !0 ? /* @__PURE__ */ r(Me, { filters: u }) : /* @__PURE__ */ r(E, {});
1138
- });
1139
- ge.displayName = "ToolbarFilters";
1140
- const Va = (e) => {
1141
- const {
1142
- resourceConfig: a,
1143
- autoFilters: t,
1144
- filters: o,
1145
- countFilters: c,
1146
- expanded: u,
1147
- setExpanded: l,
1148
- filterCountToCollapse: m = 5,
1149
- collapsedSize: b = "60px",
1150
- fabButtonSize: d = "20px"
1151
- // Default to 20px as requested
1152
- } = e, n = Wa()?.setFilters, f = Gt(a.listProps?.storeKey || a.model), s = a.FilterFormComponent ? a.FilterFormComponent : a.filterWithSubmit === !0 ? Na : ge, h = S.useRef(null), p = Ge(), y = () => {
1153
- f(), n && n({}, []), h.current?.reset();
1154
- }, A = () => {
1155
- p();
1156
- };
1157
- return /* @__PURE__ */ T("div", { children: [
1158
- /* @__PURE__ */ T(
1159
- "div",
1160
- {
1161
- style: {
1162
- display: "flex",
1163
- justifyContent: "flex-start",
1164
- flexWrap: "wrap"
1165
- },
1166
- className: "toolbar-actions",
1167
- children: [
1168
- /* @__PURE__ */ r(ht, { mode: "create", resourceConfig: a }),
1169
- /* @__PURE__ */ r(Ct, { mode: "create", resourceConfig: a }),
1170
- typeof a.customToolbarElements == "function" ? a.customToolbarElements(o) : a.customToolbarElements,
1171
- typeof a.customToolbarActions == "function" ? a.customToolbarActions(o) : a.customToolbarActions,
1172
- !!a.showSavedQueries && /* @__PURE__ */ r($e, {})
1173
- ]
1174
- }
1175
- ),
1176
- c ? /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
1177
- Ye,
1178
- {
1179
- className: "toolbar-collapse",
1180
- orientation: "vertical",
1181
- collapsedSize: b,
1182
- in: u,
1183
- timeout: "auto",
1184
- children: /* @__PURE__ */ r("div", { className: "toolbar-filters", children: /* @__PURE__ */ r(s, { ref: h, resourceConfig: a, filters: o }) })
1185
- }
1186
- ) }) : /* @__PURE__ */ r(E, {}),
1187
- c && a?.filterWithSubmit === !0 && a?.filterButtonPosition !== "filters-container" ? /* @__PURE__ */ r(
1188
- "div",
1189
- {
1190
- style: {
1191
- display: "flex",
1192
- justifyContent: "flex-end",
1193
- flexWrap: "wrap"
1194
- },
1195
- className: "toolbar-buttons",
1196
- children: /* @__PURE__ */ r(
1197
- ue,
1198
- {
1199
- endIcon: /* @__PURE__ */ r(ya, {}),
1200
- variant: "contained",
1201
- onClick: () => {
1202
- h.current?.submit();
1203
- },
1204
- children: "Filtrar"
1205
- }
1206
- )
1207
- }
1208
- ) : /* @__PURE__ */ r(E, {}),
1209
- /* @__PURE__ */ T(N, { className: "toolbar-right-buttons", sx: {
1210
- gap: 0.5,
1211
- padding: 0.5
1212
- }, children: [
1213
- /* @__PURE__ */ r(
1214
- Kt,
1215
- {
1216
- onClick: A,
1217
- size: "small",
1218
- "aria-label": "refresh",
1219
- color: "primary",
1220
- icon: /* @__PURE__ */ r(ca, { sx: { fontSize: "1rem" } }),
1221
- tooltip: "Refrescar",
1222
- style: {
1223
- width: d,
1224
- height: d,
1225
- minHeight: d
1226
- }
1227
- }
1228
- ),
1229
- c && t ? /* @__PURE__ */ r(
1230
- Kt,
1231
- {
1232
- onClick: y,
1233
- size: "small",
1234
- "aria-label": "refresh",
1235
- color: "primary",
1236
- icon: /* @__PURE__ */ r(ua, { sx: { fontSize: "1rem" } }),
1237
- tooltip: "Borrar filtros",
1238
- style: {
1239
- width: d,
1240
- height: d,
1241
- minHeight: d
1242
- }
1243
- }
1244
- ) : /* @__PURE__ */ r(E, {}),
1245
- c ? /* @__PURE__ */ r(
1246
- de,
1247
- {
1248
- size: "small",
1249
- "aria-label": "collapse",
1250
- color: "primary",
1251
- onClick: () => l(!u),
1252
- style: {
1253
- width: d,
1254
- height: d,
1255
- minHeight: d
1256
- },
1257
- className: "toolbar-collapse-button",
1258
- children: u ? /* @__PURE__ */ r(pa, { sx: { fontSize: "1rem" } }) : /* @__PURE__ */ r(fa, { sx: { fontSize: "1rem" } })
1259
- }
1260
- ) : /* @__PURE__ */ r(E, {})
1261
- ] })
1262
- ] });
1263
- }, ve = (e, a) => process.env["VITE_" + e] || null, za = ve("FILTERS_COLLAPSE_COUNT"), Ca = ve("FILTERS_COLLAPSE_SIZE"), Ua = (e) => {
1264
- const { filters: a, resourceConfig: t, autoFilters: o, listProps: c } = e, l = `filters.collapsed.${t.model.replace(/\//g, "_")}`, [m, b] = R(() => {
1265
- const s = localStorage.getItem(l);
1266
- return s !== null ? JSON.parse(s) : !1;
1267
- });
1268
- _(() => {
1269
- localStorage.setItem(l, JSON.stringify(m)), console.log("💾 Persisting filter state:", { storeKey: l, expanded: m });
1270
- }, [m, l]);
1271
- const d = (s) => {
1272
- console.log("🔄 Setting expanded:", { storeKey: l, value: s }), b(s);
1273
- }, i = t.referenceFilters && t.referenceFilters.length ? t.referenceFilters.length : 0;
1274
- let n = !!(a || t.create || t.exporter || t.customToolbarElements);
1275
- if (t?.toolbar === !1 && (n = !1), !n) return null;
1276
- const f = /* @__PURE__ */ r(
1277
- Va,
1278
- {
1279
- resourceConfig: t,
1280
- autoFilters: o,
1281
- filters: a,
1282
- countFilters: i,
1283
- expanded: m,
1284
- setExpanded: d,
1285
- filterCountToCollapse: za,
1286
- collapsedSize: Ca
1287
- }
1288
- );
1289
- return t.customListActions ? /* @__PURE__ */ r(
1290
- t.customListActions,
1291
- {
1292
- resourceConfig: t,
1293
- listProps: c,
1294
- children: f
1295
- }
1296
- ) : f;
1297
- }, ja = ({
1298
- resourceConfig: e,
1299
- autoFilters: a,
1300
- listProps: t,
1301
- ListActionsWrapper: o
1302
- }) => (console.log("🎬 DashAutoList DEBUG - Rendering actions (fieldProps standardized):", {
1303
- resourceModel: e.model,
1304
- autoFiltersCount: a.length,
1305
- hasCustomToolbarElements: !!e.customToolbarElements,
1306
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1307
- }), /* @__PURE__ */ r(
1308
- o,
1309
- {
1310
- autoFilters: a,
1311
- resourceConfig: e,
1312
- children: /* @__PURE__ */ r(
1313
- Ua,
1314
- {
1315
- filters: a,
1316
- resourceConfig: e,
1317
- autoFilters: a,
1318
- listProps: t
1319
- }
1320
- )
1321
- }
1322
- )), Rr = ({
1323
- resourceConfig: e,
1324
- customToolbarElements: a,
1325
- beforeSubmit: t,
1326
- onSubmit: o,
1327
- onError: c,
1328
- Pagination: u,
1329
- children: l,
1330
- dataGridProps: m,
1331
- locale: b,
1332
- ...d
1333
- }) => {
1334
- const { exporter: i } = e;
1335
- _(() => {
1336
- console.log("📋 DashAutoList DEBUG - Component initialized (fieldProps standardized):", {
1337
- resourceModel: e.model,
1338
- hasReferenceFilters: !!(e.referenceFilters && e.referenceFilters.length > 0),
1339
- referenceFiltersCount: e.referenceFilters?.length || 0,
1340
- referenceFilters: e.referenceFilters?.map((B) => ({
1341
- id: B.id,
1342
- source: B.source,
1343
- label: B.label,
1344
- hasReferenceComponent: !!B.referenceComponent,
1345
- fieldProps: B.fieldProps
1346
- // Only fieldProps now
1347
- })) || [],
1348
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1349
- });
1350
- }, [e]), a && (e.customToolbarElements = a), console.log("🔧 DashAutoList DEBUG - About to generate filters (fieldProps only):", {
1351
- resourceModel: e.model,
1352
- referenceFilters: e.referenceFilters,
1353
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1354
- });
1355
- const n = va(e);
1356
- console.log("✅ DashAutoList DEBUG - Filters generated (fieldProps standardized):", {
1357
- resourceModel: e.model,
1358
- filtersCount: n.length,
1359
- filters: n.map((B, v) => ({
1360
- index: v,
1361
- key: B.key,
1362
- type: B.type?.name || "unknown",
1363
- props: B.props
1364
- })),
1365
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1366
- });
1367
- const f = Gt(
1368
- e.listProps?.storeKey || e.model
1369
- ), s = { ...e.dataGridProps, ...m }, [, h] = R(!1);
1370
- _(() => {
1371
- const B = (v) => {
1372
- e.model === v.data.resource && h(v.data.value);
1373
- };
1374
- return window.addEventListener("dash-global-loader", B), () => {
1375
- window.removeEventListener("dash-global-loader", B);
1376
- };
1377
- }, [e.model]);
1378
- const p = e.listActionsWrapper || Ea;
1379
- _(() => {
1380
- e.resetSelectedIdsOnLoad && f();
1381
- }, [e.resetSelectedIdsOnLoad, f]);
1382
- const A = (e.toolbar === !1 ? !1 : n && n.length > 0 || e.create || e.exporter || e.customToolbarElements) ? /* @__PURE__ */ r(
1383
- ja,
1384
- {
1385
- resourceConfig: e,
1386
- autoFilters: n,
1387
- listProps: d,
1388
- ListActionsWrapper: p
1389
- }
1390
- ) : null, w = {
1391
- /* default storeKey */
1392
- sort: { field: "id", order: "ASC" },
1393
- storeKey: e?.model,
1394
- // Explicitly set resource to ensure List component works correctly
1395
- resource: e?.model,
1396
- ...d,
1397
- ...e.listProps || {},
1398
- // Set actions to the element (will be rendered inside List context)
1399
- actions: A,
1400
- pagination: u ? /* @__PURE__ */ r(u, { ...e.paginationProps }) : /* @__PURE__ */ r(St, { ...e.paginationProps }),
1401
- ...i && { exporter: i },
1402
- ...e.bulkActionButtons && { bulkActionButtons: e.bulkActionButtons }
1403
- };
1404
- console.log("🚀 DashAutoList DEBUG - Final list props (fieldProps standardized):", {
1405
- resourceModel: e.model,
1406
- finalListProps: {
1407
- ...w,
1408
- actions: A ? "rendered" : "null"
1409
- },
1410
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1411
- });
1412
- const g = e.contextComponent ? e.contextComponent : ({ children: B }) => B;
1413
- return w ? e.listComponent ? e.listComponent(e, o, c) : /* @__PURE__ */ r(
1414
- Re,
1415
- {
1416
- component: "div",
1417
- ...w,
1418
- children: /* @__PURE__ */ r(g, { mode: "list", resourceConfig: e, children: e.dataGridComponent ? /* @__PURE__ */ r(
1419
- e.dataGridComponent,
1420
- {
1421
- resourceConfig: e,
1422
- dataGridProps: s
1423
- }
1424
- ) : /* @__PURE__ */ r(
1425
- Ra,
1426
- {
1427
- resourceConfig: e,
1428
- dataGridProps: s,
1429
- locale: b
1430
- }
1431
- ) })
1432
- }
1433
- ) : /* @__PURE__ */ r(E, {});
1434
- }, Be = ie({
1435
- mode: "create"
1436
- }), J = Be.Provider, Or = () => at(Be), Ee = ({
1437
- resourceConfig: e,
1438
- onSubmit: a,
1439
- beforeSubmit: t,
1440
- onError: o,
1441
- toolbar: c,
1442
- mode: u,
1443
- isDrawer: l = !1,
1444
- locale: m
1445
- }) => {
1446
- const b = _t(), d = bt(), i = oe();
1447
- let n = u === "create" && e?.formGroupModes?.create ? e.formGroupModes.create : u === "edit" && e?.formGroupModes?.edit ? e.formGroupModes.edit : e?.formGroupMode ? e.formGroupMode : "tabs";
1448
- const f = () => L(e.schema).filter((D) => D.filter((M) => u === "create" ? M?.inCreate !== !1 : u === "edit" ? M?.inEdit !== !1 : !0).length > 0).length, s = $(() => f(), [e.schema, u, m]);
1449
- n === "tabs" && s <= 1 && (n = "layout");
1450
- const h = wa(
1451
- (v) => v.formData || {}
1452
- ), p = z(
1453
- async (v) => {
1454
- if (console.log("onCreateSave called with values:", v), !b)
1455
- throw new Error("Resource is required");
1456
- try {
1457
- t && (v = t(v));
1458
- const { data: D } = await i.create(b, {
1459
- data: v
1460
- });
1461
- a && a(D);
1462
- } catch (D) {
1463
- o && o(D);
1464
- }
1465
- },
1466
- [b, t, i, a, o]
1467
- ), y = z(
1468
- async (v) => {
1469
- console.log("onUpdateSave called with values:", v);
1470
- try {
1471
- t && (v = t(v));
1472
- const { data: D } = await i.update(b + "/" + d.id, {
1473
- id: d?.id,
1474
- data: v,
1475
- previousData: d
1476
- });
1477
- a && a(D);
1478
- } catch (D) {
1479
- o && o(D);
1480
- }
1481
- },
1482
- [b, d, t, i, a, o]
1483
- );
1484
- let A = p;
1485
- switch (u) {
1486
- case "edit":
1487
- A = y;
1488
- break;
1489
- case "create":
1490
- A = p;
1491
- break;
1492
- }
1493
- const w = $(() => e.contextComponent || (({ children: v }) => /* @__PURE__ */ r(E, { children: v })), [e.contextComponent, m]), g = $(() => ({ onSave: A, mode: u, locale: m }), [A, u, m]);
1494
- if (!h) return /* @__PURE__ */ r(le, {});
1495
- if (u === "create" && typeof e?.createComponent == "function")
1496
- return /* @__PURE__ */ r(
1497
- Y,
1498
- {
1499
- toolbar: c || null,
1500
- onSubmit: A,
1501
- validate: q(e.schema),
1502
- reValidateMode: "onBlur",
1503
- className: "auto-admin-grouped-form",
1504
- children: /* @__PURE__ */ r(J, { value: g, children: /* @__PURE__ */ r(w, { mode: u, resourceConfig: e, children: e.createComponent(e) }) })
1505
- },
1506
- "create-form"
1507
- );
1508
- if (u === "edit" && typeof e?.editComponent == "function")
1509
- return /* @__PURE__ */ r(
1510
- Y,
1511
- {
1512
- warnWhenUnsavedChanges: !0,
1513
- toolbar: c || null,
1514
- onSubmit: A,
1515
- validate: q(e.schema),
1516
- reValidateMode: "onBlur",
1517
- className: "auto-admin-grouped-form",
1518
- children: /* @__PURE__ */ r(J, { value: g, children: /* @__PURE__ */ r(w, { mode: u, resourceConfig: e, children: e.editComponent(e) }) })
1519
- },
1520
- "edit-form"
1521
- );
1522
- const B = $(() => ({ children: D }) => /* @__PURE__ */ r(J, { value: g, children: /* @__PURE__ */ r(w, { mode: u, resourceConfig: e, children: D }) }), [g, w, u, e, m]);
1523
- if (n === "tabs" && L(e.schema).length > 1)
1524
- return /* @__PURE__ */ r(E, { children: /* @__PURE__ */ r(
1525
- Oe,
1526
- {
1527
- toolbar: c || null,
1528
- onSubmit: A,
1529
- validate: q(e.schema),
1530
- className: "tabbed-form-custom dash-auto-admin-tabbed-form",
1531
- resetOptions: { keepDirtyValues: !0 },
1532
- syncWithLocation: e.syncTabsWithLocation || !1,
1533
- defaultValues: u === "create" ? h : { ...d, ...h },
1534
- component: B,
1535
- children: dt({
1536
- schema: e.schema,
1537
- resourceConfig: e,
1538
- options: { mode: u, isDrawer: l, locale: m }
1539
- })
1540
- },
1541
- "tabbed-form"
1542
- ) });
1543
- if (n === "groups")
1544
- return /* @__PURE__ */ r(
1545
- Y,
1546
- {
1547
- toolbar: c || null,
1548
- onSubmit: A,
1549
- validate: q(e.schema),
1550
- reValidateMode: "onBlur",
1551
- className: "auto-admin-grouped-form",
1552
- children: /* @__PURE__ */ r(J, { value: g, children: /* @__PURE__ */ r(w, { mode: u, resourceConfig: e, children: sr({ schema: e.schema, resourceConfig: e, options: {
1553
- mode: u,
1554
- isDrawer: l
1555
- } }) }) })
1556
- },
1557
- "groups-form"
1558
- );
1559
- if (n === "layout")
1560
- return /* @__PURE__ */ r(
1561
- Y,
1562
- {
1563
- toolbar: c || null,
1564
- onSubmit: A,
1565
- validate: q(e.schema),
1566
- reValidateMode: "onBlur",
1567
- className: "auto-admin-grouped-form",
1568
- children: /* @__PURE__ */ r(J, { value: g, children: /* @__PURE__ */ r(w, { mode: u, resourceConfig: e, children: nr({ schema: e.schema, resourceConfig: e, options: {
1569
- mode: u,
1570
- isDrawer: l
1571
- } }) }) })
1572
- },
1573
- "layout-form"
1574
- );
1575
- }, Ha = (e, a) => {
1576
- let t = !0;
1577
- return a == null ? !0 : a ? (typeof a == "function" && (t = a(e)), t) : !1;
1578
- }, V = ({
1579
- resourceConfig: e,
1580
- record: a,
1581
- ...t
1582
- }) => {
1583
- const o = et(), c = o(e.label, { _: e.label });
1584
- return /* @__PURE__ */ r("span", { children: a ? `${o("dash.action.edit")} "${a[e.schema[0].attribute]}"` : c });
1585
- }, Ja = ({
1586
- resourceConfig: e,
1587
- toolbar: a,
1588
- actions: t,
1589
- onSubmit: o,
1590
- onError: c,
1591
- beforeSubmit: u,
1592
- isDrawer: l,
1593
- locale: m
1594
- }) => {
1595
- const b = ({ ...i }) => {
1596
- const n = e.drawer === !0 ? !1 : !!e.toolbarListButton;
1597
- return !!e?.AutoEditTopToolbarElements || n ? /* @__PURE__ */ T(W, { sx: { mb: 2 }, ...i, children: [
1598
- n && /* @__PURE__ */ r(nt, {}),
1599
- e?.AutoEditTopToolbarElements ? e.AutoCreateTopToolbarElements(e) : /* @__PURE__ */ r(E, {})
1600
- ] }) : null;
1601
- }, d = ({ ...i }) => {
1602
- const n = e.toolbarSaveButton && e.toolbarSaveButton.component ? e.toolbarSaveButton.component : j;
1603
- return /* @__PURE__ */ T(mt, { ...i, children: [
1604
- Ha(
1605
- e,
1606
- e.toolbarSaveButton
1607
- ) && /* @__PURE__ */ r(
1608
- n,
1609
- {
1610
- resourceConfig: e,
1611
- onSubmit: o,
1612
- ...e.toolbarSaveButton && e.toolbarSaveButton?.props
1613
- }
1614
- ),
1615
- e?.AutoEditBottomToolbarElements ? e.AutoCreateBottomToolbarElements(e) : /* @__PURE__ */ r(E, {})
1616
- ] });
1617
- };
1618
- return /* @__PURE__ */ r(
1619
- Ne,
1620
- {
1621
- component: "div",
1622
- actions: t || /* @__PURE__ */ r(b, {}),
1623
- mutationMode: e.mutationMode,
1624
- title: /* @__PURE__ */ r(V, { resourceConfig: e }),
1625
- children: /* @__PURE__ */ r(
1626
- Ee,
1627
- {
1628
- mode: "create",
1629
- resourceConfig: e,
1630
- toolbar: a || /* @__PURE__ */ r(d, {}),
1631
- onSubmit: o,
1632
- onError: c,
1633
- beforeSubmit: u,
1634
- isDrawer: l,
1635
- locale: m
1636
- }
1637
- )
1638
- }
1639
- );
1640
- }, qa = (e) => {
1641
- const { resourceConfig: a } = e;
1642
- if (!a) return /* @__PURE__ */ r(j, { resourceConfig: a });
1643
- if (a.bottomToolbarSaveButton)
1644
- if (a.bottomToolbarSaveButton?.enabled) {
1645
- const t = {
1646
- resourceConfig: a,
1647
- ...a.bottomToolbarSaveButton?.props || {},
1648
- alwaysEnable: a?.saveButtonAlwaysEnabled === !0
1649
- };
1650
- return a.bottomToolbarSaveButton?.component ? /* @__PURE__ */ r(a.bottomToolbarSaveButton.component, { ...t }) : /* @__PURE__ */ r(j, { ...t });
1651
- } else
1652
- return null;
1653
- return /* @__PURE__ */ r(j, { resourceConfig: a });
1654
- }, Ka = (e) => {
1655
- const { resourceConfig: a } = e;
1656
- return a ? a?.delete !== !1 && a?.bottomToolbarDeleteButton ? /* @__PURE__ */ r(U, {}) : a?.bottomToolbarDeleteButton && a?.bottomToolbarDeleteButton.enabled !== !1 ? a.bottomToolbarDeleteButton?.props && a.bottomToolbarDeleteButton.props?.confirm ? /* @__PURE__ */ r(
1657
- It,
1658
- {
1659
- render: (t) => /* @__PURE__ */ r(Mt, { record: t })
1660
- }
1661
- ) : a.bottomToolbarDeleteButton?.component ? /* @__PURE__ */ r(a.bottomToolbarDeleteButton.component, { ...a.bottomToolbarDeleteButton?.props || {} }) : /* @__PURE__ */ r(U, { ...a.bottomToolbarDeleteButton?.props || {} }) : null : /* @__PURE__ */ r(U, {});
1662
- }, Xa = ({
1663
- id: e,
1664
- resourceConfig: a,
1665
- onSubmit: t,
1666
- onError: o,
1667
- onCancel: c,
1668
- beforeSubmit: u,
1669
- toolbar: l,
1670
- actions: m,
1671
- isDrawer: b = !1,
1672
- locale: d
1673
- }) => {
1674
- const i = ({ ...f }) => {
1675
- const s = !!a.drawer;
1676
- return /* @__PURE__ */ T(W, { sx: { mb: 2 }, ...f, children: [
1677
- a?.AutoEditTopToolbarElements ? a.AutoEditTopToolbarElements(a) : null,
1678
- !s && /* @__PURE__ */ r(we, { mode: "edit", resourceConfig: a }),
1679
- !s && /* @__PURE__ */ r(Ae, { mode: "edit", resourceConfig: a }),
1680
- !s && /* @__PURE__ */ r(ht, { mode: "edit", resourceConfig: a }),
1681
- !s && /* @__PURE__ */ r(zt, { mode: "edit", resourceConfig: a }),
1682
- !s && /* @__PURE__ */ r(Ct, { mode: "edit", resourceConfig: a })
1683
- ] });
1684
- }, n = ({ ...f }) => /* @__PURE__ */ T(mt, { ...f, children: [
1685
- /* @__PURE__ */ r(qa, { mode: "edit", resourceConfig: a, onError: o, onSubmit: t }),
1686
- /* @__PURE__ */ r(Ka, { mode: "edit", resourceConfig: a, onError: o, onSubmit: t }),
1687
- a?.AutoEditBottomToolbarElements ? a.AutoEditBottomToolbarElements(a) : /* @__PURE__ */ r(E, {})
1688
- ] });
1689
- return /* @__PURE__ */ r(
1690
- xe,
1691
- {
1692
- component: "div",
1693
- ...e && { id: e },
1694
- actions: m || /* @__PURE__ */ r(i, {}),
1695
- mutationMode: a.mutationMode,
1696
- title: /* @__PURE__ */ r(V, { resourceConfig: a }),
1697
- ...a?.editProps || {},
1698
- children: /* @__PURE__ */ r(
1699
- Ee,
1700
- {
1701
- isDrawer: b,
1702
- mode: "edit",
1703
- resourceConfig: a,
1704
- toolbar: l || /* @__PURE__ */ r(n, {}),
1705
- onSubmit: t,
1706
- onError: o,
1707
- ...u && { beforeSubmit: u },
1708
- onCancel: c,
1709
- locale: d
1710
- }
1711
- )
1712
- }
1713
- );
1714
- }, L = (e) => {
1715
- const a = [];
1716
- return e.forEach((t) => {
1717
- let o = !1;
1718
- a.forEach((c) => {
1719
- c[0].tab === t.tab && (c.push(t), o = !0);
1720
- }), o || a.push([t]);
1721
- }), a;
1722
- }, Qa = (e, a, t) => {
1723
- const o = et();
1724
- return L(a).map((c) => {
1725
- const u = c[0].tab || t?.label || "", l = o(`dash-auto-admin-tabs.${u}`, { _: u });
1726
- return /* @__PURE__ */ r(se, { label: l, children: c.filter((m) => m?.inShow !== !1).map(
1727
- (m, b) => ot("view", e, m, b, t)
1728
- ) }, "tab_" + u);
1729
- });
1730
- }, kt = (e, a) => /* @__PURE__ */ r(We, { children: Qa(e, e.schema, a) }), Te = (e) => {
1731
- const a = [];
1732
- return [...new Set(e.map((o) => o.tab))].forEach((o) => {
1733
- a[o] = e.filter((c) => c.tab === o);
1734
- }), a;
1735
- }, Za = (e, a) => {
1736
- const t = (o, c, u) => {
1737
- const l = Te(e.schema);
1738
- return (l[o] ? l[o] : []).filter((b) => b?.inShow !== !1).map(
1739
- (b, d) => ot(
1740
- u || "view",
1741
- e,
1742
- b,
1743
- d,
1744
- c
1745
- )
1746
- );
1747
- };
1748
- return !e.showLayout || typeof e.showLayout != "function" ? (console.error(
1749
- "showLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs"
1750
- ), kt(e)) : /* @__PURE__ */ r(ne, { children: e.showLayout(t) });
1751
- }, Ya = (e, a) => /* @__PURE__ */ r(ne, { children: L(e.schema).map((t, o) => {
1752
- const c = t[0].tab || De.defaultTabName;
1753
- return t.filter((l) => l?.inShow !== !1).length ? /* @__PURE__ */ T("fieldset", { children: [
1754
- /* @__PURE__ */ r("legend", { children: c }),
1755
- t.filter((l) => l?.inShow !== !1).map(
1756
- (l, m) => ot(
1757
- "view",
1758
- e,
1759
- l,
1760
- m,
1761
- a
1762
- )
1763
- )
1764
- ] }, "fieldset-group-" + o) : /* @__PURE__ */ r(E, {});
1765
- }) }), tr = ({
1766
- resourceConfig: e,
1767
- id: a,
1768
- isDrawer: t = !1,
1769
- locale: o,
1770
- ...c
1771
- }) => {
1772
- const u = $(() => e.contextComponent || (({ children: b }) => /* @__PURE__ */ r(E, { children: b })), [e.contextComponent]), m = (() => {
1773
- const i = [];
1774
- return t || (i.push(/* @__PURE__ */ r(we, { resourceConfig: e })), i.push(/* @__PURE__ */ r(Ae, { resourceConfig: e })), i.push(/* @__PURE__ */ r(ht, { resourceConfig: e })), i.push(/* @__PURE__ */ r(zt, { resourceConfig: e })), i.push(/* @__PURE__ */ r(Ct, { resourceConfig: e }))), i;
1775
- })();
1776
- return e.showComponent && typeof e.showComponent == "function" ? /* @__PURE__ */ r(
1777
- X,
1778
- {
1779
- component: "div",
1780
- ...a && { id: a },
1781
- title: /* @__PURE__ */ r(V, { resourceConfig: e }),
1782
- ...c,
1783
- ...m.length && {
1784
- actions: /* @__PURE__ */ r(W, { sx: { mb: 2 }, children: m.map(
1785
- (b, d) => S.cloneElement(b, { key: d })
1786
- ) })
1787
- },
1788
- children: /* @__PURE__ */ T(u, { mode: "view", resourceConfig: e, children: [
1789
- e.showComponent(e),
1790
- e.references && e.references.map(
1791
- (b) => Z(b)
1792
- )
1793
- ] })
1794
- }
1795
- ) : e.formGroupMode === "tabs" ? /* @__PURE__ */ r(
1796
- X,
1797
- {
1798
- component: "div",
1799
- ...a && { id: a },
1800
- title: /* @__PURE__ */ r(V, { resourceConfig: e }),
1801
- ...c,
1802
- ...m.length && {
1803
- actions: /* @__PURE__ */ r(W, { sx: { mb: 2 }, children: m.map(
1804
- (b, d) => S.cloneElement(b, { key: d })
1805
- ) })
1806
- },
1807
- children: /* @__PURE__ */ T(u, { mode: "view", resourceConfig: e, children: [
1808
- kt(e, { mode: "view", locale: o }),
1809
- e.references && e.references.map(
1810
- (b) => Z(b)
1811
- )
1812
- ] })
1813
- }
1814
- ) : e.formGroupMode === "groups" ? /* @__PURE__ */ r(
1815
- X,
1816
- {
1817
- component: "div",
1818
- ...a && { id: a },
1819
- title: /* @__PURE__ */ r(V, { resourceConfig: e }),
1820
- ...c,
1821
- ...m.length && {
1822
- actions: /* @__PURE__ */ r(W, { sx: { mb: 2 }, children: m.map(
1823
- (b, d) => S.cloneElement(b, { key: d })
1824
- ) })
1825
- },
1826
- children: /* @__PURE__ */ T(u, { mode: "view", resourceConfig: e, children: [
1827
- Ya(e, { mode: "view", locale: o }),
1828
- e.references && e.references.map(
1829
- (b) => Z(b)
1830
- )
1831
- ] })
1832
- }
1833
- ) : e.formGroupMode === "layout" ? /* @__PURE__ */ r(
1834
- X,
1835
- {
1836
- component: "div",
1837
- ...a && { id: a },
1838
- title: /* @__PURE__ */ r(V, { resourceConfig: e }),
1839
- ...c,
1840
- ...m.length && {
1841
- actions: /* @__PURE__ */ r(W, { sx: { mb: 2 }, children: m.map(
1842
- (b, d) => S.cloneElement(b, { key: d })
1843
- ) })
1844
- },
1845
- children: /* @__PURE__ */ T(u, { mode: "view", resourceConfig: e, children: [
1846
- Za(e),
1847
- e.references && e.references.map(
1848
- (b) => Z(b)
1849
- )
1850
- ] })
1851
- }
1852
- ) : /* @__PURE__ */ r(
1853
- X,
1854
- {
1855
- component: "div",
1856
- ...a && { id: a },
1857
- title: /* @__PURE__ */ r(V, { resourceConfig: e }),
1858
- ...c,
1859
- ...m.length && {
1860
- actions: /* @__PURE__ */ r(W, { sx: { mb: 2 }, children: m.map(
1861
- (b, d) => S.cloneElement(b, { key: d })
1862
- ) })
1863
- },
1864
- children: /* @__PURE__ */ T(u, { mode: "view", resourceConfig: e, children: [
1865
- kt(e, { mode: "view", locale: o }),
1866
- e.references && e.references.map(
1867
- (b) => Z(b)
1868
- )
1869
- ] })
1870
- }
1871
- );
1872
- }, Nr = ({
1873
- resourceConfig: e,
1874
- recordId: a,
1875
- type: t = "normal",
1876
- placement: o = "right",
1877
- width: c = "100%",
1878
- // TODO: This is the default value for the drawer width, to be deprecated; must be set at a HoC.
1879
- height: u,
1880
- beforeSubmit: l,
1881
- onSubmit: m,
1882
- onError: b,
1883
- children: d,
1884
- ...i
1885
- }) => {
1886
- const n = Rt(), f = t === "swipeable" ? ta : ea, [s, h] = R(
1887
- !!n.state?.hash
1888
- ), p = () => {
1889
- h(!1);
1890
- }, y = () => {
1891
- h(!0);
1892
- }, A = (ft) => {
1893
- e.closeDrawerAfterSave && p(), m && m(ft);
1894
- }, [w, g] = R(
1895
- n.state?.hash ? n.state.hash : window.location.hash
1896
- ), B = z((ft) => {
1897
- g(ft.data), h(!0);
1898
- }, []);
1899
- _(() => (window.addEventListener("virtualhash", B), () => {
1900
- window.removeEventListener("virtualhash", B);
1901
- }), []);
1902
- let v = "edit";
1903
- Jt(
1904
- `/${e.model}/inline/create`,
1905
- String(w).substring(1)
1906
- ).matches && (v = "create");
1907
- const I = Jt(
1908
- `/${e.model}/inline/:id/:mode`,
1909
- String(w).substring(1)
1910
- );
1911
- v = I.matches && I.params?.mode ? I.params.mode : v;
1912
- const M = ["edit", "show"].includes(v) ? I.params?.id : null;
1913
- _(() => (n.state?.hash && history.replaceState(null, "", n.state.hash), () => {
1914
- history.replaceState(null, "", null);
1915
- }), []);
1916
- const H = () => e?.bottomToolbar === !1 ? /* @__PURE__ */ r(E, {}) : /* @__PURE__ */ T(mt, { children: [
1917
- v === "edit" && e?.saveButton !== !1 && /* @__PURE__ */ r(
1918
- j,
1919
- {
1920
- alwaysEnable: e?.saveButtonAlwaysEnabled === !0,
1921
- label: "Guardar",
1922
- resourceConfig: e
1923
- }
1924
- ),
1925
- v === "create" && e?.saveButton !== !1 && /* @__PURE__ */ r(
1926
- j,
1927
- {
1928
- resourceConfig: e,
1929
- alwaysEnable: e?.saveButtonAlwaysEnabled === !0,
1930
- label: "Crear"
1931
- }
1932
- ),
1933
- /* @__PURE__ */ r(Zt, { onClick: () => p(), children: /* @__PURE__ */ r(E, { children: "Cerrar" }) })
1934
- ] });
1935
- return v !== "list" && v === "create" ? /* @__PURE__ */ P(
1936
- f,
1937
- {
1938
- anchor: o,
1939
- onClose: () => p(),
1940
- ...t === "swipeable" && { onOpen: y },
1941
- open: s,
1942
- key: o,
1943
- sx: {
1944
- width: { xs: "90%", sm: "90%", md: "50%", lg: "40%" },
1945
- "& .MuiDrawer-paper": {
1946
- width: { xs: "90%", sm: "90%", md: "50%", lg: "40%" }
1947
- }
1948
- },
1949
- slotProps: {},
1950
- size: "large",
1951
- ...i
1952
- },
1953
- /* @__PURE__ */ r(
1954
- "div",
1955
- {
1956
- style: {
1957
- ...u && { height: u },
1958
- ...c && { width: c }
1959
- },
1960
- children: /* @__PURE__ */ r(
1961
- Ja,
1962
- {
1963
- toolbar: /* @__PURE__ */ r(H, {}),
1964
- isDrawer: !0,
1965
- resourceConfig: { ...e, formGroupMode: e.formGroupMode === "tabs" || !e.formGroupMode ? "groups" : e.formGroupMode },
1966
- beforeSubmit: l,
1967
- onSubmit: A,
1968
- onError: b,
1969
- onCancel: () => p()
1970
- }
1971
- )
1972
- }
1973
- )
1974
- ) : v !== "list" && v === "edit" && M ? /* @__PURE__ */ P(
1975
- f,
1976
- {
1977
- anchor: o,
1978
- onClose: () => p(),
1979
- ...t === "swipeable" && { onOpen: y },
1980
- open: s,
1981
- key: o,
1982
- sx: {
1983
- width: { xs: "90%", sm: "90%", md: "50%", lg: "40%" },
1984
- "& .MuiDrawer-paper": {
1985
- width: { xs: "90%", sm: "90%", md: "50%", lg: "40%" }
1986
- }
1987
- },
1988
- slotProps: {},
1989
- size: "large",
1990
- ...i
1991
- },
1992
- /* @__PURE__ */ r(
1993
- "div",
1994
- {
1995
- style: {
1996
- ...u && { height: u },
1997
- ...c && { width: c }
1998
- },
1999
- children: /* @__PURE__ */ r(
2000
- Xa,
2001
- {
2002
- isDrawer: !0,
2003
- toolbar: /* @__PURE__ */ r(H, {}),
2004
- id: M,
2005
- resourceConfig: { ...e, formGroupMode: e.formGroupMode === "tabs" || !e.formGroupMode ? "groups" : e.formGroupMode },
2006
- beforeSubmit: l,
2007
- onSubmit: A,
2008
- onError: b,
2009
- onCancel: () => p()
2010
- }
2011
- )
2012
- }
2013
- )
2014
- ) : v === "show" && M ? /* @__PURE__ */ P(
2015
- f,
2016
- {
2017
- anchor: o,
2018
- onClose: () => p(),
2019
- ...t === "swipeable" && { onOpen: y },
2020
- open: s,
2021
- key: o,
2022
- sx: {
2023
- width: { xs: "90%", sm: "90%", md: "50%", lg: "40%" },
2024
- "& .MuiDrawer-paper": {
2025
- width: { xs: "90%", sm: "90%", md: "50%", lg: "40%" }
2026
- }
2027
- },
2028
- slotProps: {},
2029
- size: "large",
2030
- ...i
2031
- },
2032
- /* @__PURE__ */ r(
2033
- "div",
2034
- {
2035
- style: {
2036
- ...u && { height: u },
2037
- ...c && { width: c }
2038
- },
2039
- children: /* @__PURE__ */ r(
2040
- tr,
2041
- {
2042
- isDrawer: !0,
2043
- id: M,
2044
- resourceConfig: { ...e, formGroupMode: e.formGroupMode === "tabs" || !e.formGroupMode ? "groups" : e.formGroupMode }
2045
- }
2046
- )
2047
- }
2048
- )
2049
- ) : /* @__PURE__ */ r(E, {});
2050
- };
2051
- var er = function(e) {
2052
- var a = e.as, t = e.errors, o = e.name, c = e.message, u = e.render, l = (function(f, s) {
2053
- if (f == null) return {};
2054
- var h, p, y = {}, A = Object.keys(f);
2055
- for (p = 0; p < A.length; p++) s.indexOf(h = A[p]) >= 0 || (y[h] = f[h]);
2056
- return y;
2057
- })(e, ["as", "errors", "name", "message", "render"]), m = xt(), b = ha(t || m.formState.errors, o);
2058
- if (!b) return null;
2059
- var d = b.message, i = b.types, n = Object.assign({}, l, { children: d || c });
2060
- return O.isValidElement(a) ? O.cloneElement(a, n) : u ? u({ message: d || c, messages: i }) : O.createElement(a || O.Fragment, n);
2061
- };
2062
- const Xt = (e) => Object.keys(e).map((a) => ({ id: e[a], name: a })), F = ({
2063
- index: e,
2064
- method: a,
2065
- input: t,
2066
- children: o,
2067
- ...c
2068
- }) => {
2069
- const u = t?.sortable === !0, {
2070
- formState: { errors: l }
2071
- } = xt();
2072
- return a === "edit" ? /* @__PURE__ */ T(
2073
- "div",
2074
- {
2075
- className: `auto-admin-field auto-admin-field-${a}`,
2076
- children: [
2077
- /* @__PURE__ */ r(
2078
- tt,
2079
- {
2080
- label: t?.label || t.attribute,
2081
- sortable: u,
2082
- ...u && { sortBy: t.listAttribute || t.attribute },
2083
- render: (m) => S.cloneElement(o, { record: m })
2084
- }
2085
- ),
2086
- !t?.hideErrorMessage || t?.custom && /* @__PURE__ */ r(
2087
- er,
2088
- {
2089
- errors: l,
2090
- name: t.attribute,
2091
- render: (m) => m ? /* @__PURE__ */ r(ra, { className: "dash-admin-field-error", color: "error", children: typeof m.message == "string" ? m.message : typeof m.message?.message == "string" ? m.message?.message : JSON.stringify(m) }) : null
2092
- }
2093
- )
2094
- ]
2095
- },
2096
- e
2097
- ) : /* @__PURE__ */ r("div", { className: `auto-admin-field auto-admin-field-${a}`, children: o }, e);
2098
- }, ar = () => {
2099
- try {
2100
- return He();
2101
- } catch {
2102
- return null;
2103
- }
2104
- }, rr = () => {
2105
- try {
2106
- return bt();
2107
- } catch {
2108
- return null;
2109
- }
2110
- }, or = (e, a) => {
2111
- const t = ar(), o = rr();
2112
- return e === "edit" || a === "edit" ? t : o;
2113
- }, k = (e, a, t, o, c) => {
2114
- const { components: u } = pe(), l = c?.mode || "view", m = or(e, c?.mode), b = Rt(), d = $t(), i = (s) => {
2115
- const h = u[s];
2116
- return h ? { custom: !0, type: "component", component: h } : { custom: !0, type: "component", component: () => /* @__PURE__ */ T(E, { children: [
2117
- "No component for ",
2118
- s
2119
- ] }) };
2120
- }, n = a?.fieldWrapper && typeof a.fieldWrapper == "function" ? a.fieldWrapper : ({
2121
- _record: s,
2122
- _method: h,
2123
- _attribute: p,
2124
- _resourceConfig: y,
2125
- children: A
2126
- }) => A;
2127
- if (typeof t.type == "string" && !t.type.includes(".") && !Array.isArray(t.type))
2128
- switch (t.type) {
2129
- case "string":
2130
- case "text":
2131
- case "String":
2132
- t.type = String, t.slotProps = {
2133
- fullWidth: t?.fieldProps?.fullWidth ?? !0
2134
- };
2135
- break;
2136
- case "textarea":
2137
- t.type = String, t.multiple = !0, t.slotProps = {
2138
- fullWidth: t?.fieldProps?.fullWidth ?? !0
2139
- }, t.fieldProps = {
2140
- ...t.fieldProps || {},
2141
- multiline: t?.fieldProps?.multiline ?? !0,
2142
- rows: t?.fieldProps?.rows ?? 4
2143
- };
2144
- break;
2145
- case "number":
2146
- case "Number":
2147
- case "integer":
2148
- t.type = Number;
2149
- break;
2150
- case "boolean":
2151
- case "Boolean":
2152
- t.type = Boolean;
2153
- break;
2154
- case "date":
2155
- case "Date":
2156
- t.type = Date;
2157
- break;
2158
- default:
2159
- if (t.custom = !0, typeof t?.component == "string") {
2160
- const s = i(t.component);
2161
- t = { ...t, ...s };
2162
- }
2163
- }
2164
- if (c && c.useReadOnlyInputAsTextField && t.readOnly)
2165
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2166
- n,
2167
- {
2168
- label: t.label,
2169
- source: t.listAttribute || t.attribute,
2170
- ...m && { record: m },
2171
- method: e,
2172
- attribute: t,
2173
- resourceConfig: a,
2174
- children: /* @__PURE__ */ P(
2175
- At,
2176
- {
2177
- fullWidth: !0,
2178
- ...m && { record: m },
2179
- key: o,
2180
- label: t.label,
2181
- source: t.listAttribute || t.attribute,
2182
- ...t.fieldProps,
2183
- editable: !1,
2184
- InputProps: {
2185
- readOnly: !0,
2186
- endAdornment: /* @__PURE__ */ r(aa, { position: "start", children: /* @__PURE__ */ r(Aa, {}) })
2187
- }
2188
- }
2189
- )
2190
- },
2191
- o
2192
- ) });
2193
- if (c && c.readOnlyComponent && t.readOnly)
2194
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ P(
2195
- n,
2196
- {
2197
- ...m && { record: m },
2198
- method: e,
2199
- attribute: t,
2200
- key: o,
2201
- label: t.label,
2202
- source: t.listAttribute || t.attribute,
2203
- resourceConfig: a
2204
- },
2205
- /* @__PURE__ */ r(
2206
- c.readOnlyComponent,
2207
- {
2208
- fullWidth: !0,
2209
- ...m && { record: m },
2210
- input: t,
2211
- label: t.label,
2212
- source: t.listAttribute || t.attribute,
2213
- ...t.fieldProps,
2214
- editable: !1,
2215
- InputProps: { readOnly: !0 }
2216
- },
2217
- o
2218
- )
2219
- ) });
2220
- if (t.label || (t.label = t.attribute), t.custom && t.component || t.type === "component" && t.component)
2221
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2222
- be,
2223
- {
2224
- record: m,
2225
- method: l,
2226
- attribute: t,
2227
- resourceConfig: a
2228
- },
2229
- o
2230
- ) });
2231
- if (Array.isArray(t.type) && t.type.length > 0) {
2232
- const s = t.type[0];
2233
- if (Ft(s))
2234
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2235
- gt,
2236
- {
2237
- fullWidth: !0,
2238
- label: t.label,
2239
- source: t.attribute,
2240
- choices: Xt(s),
2241
- ...t?.fieldProps,
2242
- onChange: (h) => {
2243
- c?.handleChange && c.handleChange(h), t.fieldProps?.onChange && t.fieldProps.onChange(h);
2244
- }
2245
- },
2246
- o
2247
- ) });
2248
- if (typeof s == "string") {
2249
- const h = {
2250
- ...d,
2251
- ...(b.hash.match(/\d+/g) || []).map(Number).reduce((g, B, v) => (g[v] = B, g), {})
2252
- }, p = ct(h, s), [y, A] = p.split("."), w = (g) => (g ? g[A] : "?") || "??";
2253
- if (t && t.multiple === !1 && t.component) {
2254
- const g = t.component;
2255
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2256
- wt,
2257
- {
2258
- fullWidth: !0,
2259
- allowEmpty: !0,
2260
- filter: !0,
2261
- pagination: !1,
2262
- label: t.label,
2263
- reference: y,
2264
- source: t.attribute,
2265
- ...t.componentProps,
2266
- children: /* @__PURE__ */ r(
2267
- g,
2268
- {
2269
- optionText: w,
2270
- method: e,
2271
- attribute: t,
2272
- onChange: (B) => {
2273
- c?.handleChange && c.handleChange(B), t.fieldProps?.onChange && t.fieldProps.onChange(B);
2274
- },
2275
- resourceConfig: a
2276
- }
2277
- )
2278
- },
2279
- o
2280
- ) });
2281
- }
2282
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2283
- Ht,
2284
- {
2285
- fullWidth: !0,
2286
- filter: !0,
2287
- pagination: !1,
2288
- label: t.label,
2289
- reference: y,
2290
- source: t.attribute,
2291
- ...t.componentProps,
2292
- children: /* @__PURE__ */ r(Bt, { ...t.fieldProps, children: /* @__PURE__ */ r(Et, { source: A }) })
2293
- },
2294
- o
2295
- ) });
2296
- } else {
2297
- const h = t.type;
2298
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2299
- Ve,
2300
- {
2301
- label: t.label,
2302
- source: t.attribute,
2303
- ...t.componentProps,
2304
- children: /* @__PURE__ */ r(ze, { children: h.map(
2305
- (p, y) => k(e, a, p, y)
2306
- ) })
2307
- },
2308
- o
2309
- ) });
2310
- }
2311
- }
2312
- if (t && t.type === Dt)
2313
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2314
- Dt,
2315
- {
2316
- placeholder: "Arrástre una imágen o haga click aquí para seleccionar",
2317
- source: t.attribute,
2318
- label: t.label,
2319
- accept: "image/*",
2320
- ...t.fieldProps,
2321
- children: /* @__PURE__ */ r(ee, { source: "src", title: "title" })
2322
- },
2323
- o
2324
- ) });
2325
- if (t && t.type === Tt && (Tt, {
2326
- source: t.attribute,
2327
- label: t.label,
2328
- ...t.fieldProps,
2329
- children: te
2330
- }), typeof t.type == "string") {
2331
- if (t.type === "select" && Array.isArray(t.options) && t.options.length > 0) {
2332
- const w = t.options.map((g) => ({
2333
- id: g.id,
2334
- name: g.name
2335
- }));
2336
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2337
- lt,
2338
- {
2339
- fullWidth: !0,
2340
- label: t.label,
2341
- source: t.listAttribute || t.attribute,
2342
- choices: w,
2343
- ...t.fieldProps,
2344
- onChange: (g) => {
2345
- c?.handleChange && c.handleChange(g), t.fieldProps?.onChange && t.fieldProps.onChange(g);
2346
- },
2347
- ...t.componentProps
2348
- },
2349
- o
2350
- ) });
2351
- }
2352
- if (t.type === "select" && (!t.options || t.options.length === 0))
2353
- return console.warn(`Select field "${t.attribute}" has no options defined. Skipping render.`), null;
2354
- const s = {
2355
- ...d,
2356
- ...(b.pathname.match(/\d+/g) || []).map(Number).reduce((w, g, B) => (w[B] = g, w), {})
2357
- }, h = ct(s, t.type), [p, y] = h.split("."), A = t.component || lt;
2358
- return t && t.multiple === !1 ? /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2359
- wt,
2360
- {
2361
- allowEmpty: !0,
2362
- filters: !0,
2363
- label: t.label,
2364
- source: t.listAttribute || t.attribute,
2365
- reference: p,
2366
- sort: { field: y, order: "ASC" },
2367
- ...t.componentProps,
2368
- children: /* @__PURE__ */ r(
2369
- A,
2370
- {
2371
- optionText: y,
2372
- method: e,
2373
- attribute: t,
2374
- label: t?.label || "",
2375
- ...t.fieldProps,
2376
- onChange: (w) => {
2377
- c?.handleChange && c.handleChange(w), t.fieldProps?.onChange && t.fieldProps.onChange(w);
2378
- },
2379
- resourceConfig: a
2380
- }
2381
- )
2382
- },
2383
- o
2384
- ) }) : /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2385
- Ht,
2386
- {
2387
- reference: p,
2388
- source: t.listAttribute || t.attribute,
2389
- ...t.componentProps,
2390
- children: /* @__PURE__ */ r(
2391
- gt,
2392
- {
2393
- optionText: y,
2394
- fullWidth: !0,
2395
- label: t?.label || "",
2396
- ...t.fieldProps,
2397
- onChange: (w) => {
2398
- c?.handleChange && c.handleChange(w), t.fieldProps?.onChange && t.fieldProps.onChange(w);
2399
- }
2400
- }
2401
- )
2402
- },
2403
- o
2404
- ) });
2405
- }
2406
- switch (t.type) {
2407
- case Number:
2408
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2409
- Ue,
2410
- {
2411
- fullWidth: !0,
2412
- label: t.label,
2413
- source: t.attribute,
2414
- ...t.fieldProps,
2415
- onChange: (s) => {
2416
- c?.handleChange && c.handleChange(s), t.fieldProps?.onChange && t.fieldProps.onChange(s);
2417
- }
2418
- },
2419
- o
2420
- ) });
2421
- case Boolean:
2422
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ T("div", { children: [
2423
- t?.showLabel !== !1 && /* @__PURE__ */ r(ce, { htmlFor: t.listAttribute || t.attribute, children: t.label }),
2424
- /* @__PURE__ */ r(
2425
- Ce,
2426
- {
2427
- record: m,
2428
- id: t.listAttribute || t.attribute,
2429
- label: t.label,
2430
- source: t.listAttribute || t.attribute,
2431
- ...t.fieldProps,
2432
- onChange: (s) => {
2433
- c?.handleChange && c.handleChange(s), t.fieldProps?.onChange && t.fieldProps.onChange(s);
2434
- }
2435
- },
2436
- o
2437
- )
2438
- ] }) });
2439
- case Date:
2440
- return t.fieldProps && t.fieldProps.showTime ? /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2441
- ae,
2442
- {
2443
- label: t.label,
2444
- source: t.attribute,
2445
- ...t.fieldProps
2446
- },
2447
- o
2448
- ) }) : /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2449
- Qt,
2450
- {
2451
- label: t.label,
2452
- source: t.attribute,
2453
- ...t.fieldProps,
2454
- onChange: (s) => {
2455
- c?.handleChange && c.handleChange(s), t.fieldProps?.onChange && t.fieldProps.onChange(s);
2456
- }
2457
- },
2458
- o
2459
- ) });
2460
- }
2461
- if (Ft(t.type))
2462
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2463
- lt,
2464
- {
2465
- label: t.label,
2466
- source: t.attribute,
2467
- choices: Xt(t.type),
2468
- InputProps: t.fieldOptions,
2469
- onChange: (s) => {
2470
- c?.handleChange && c.handleChange(s), t.fieldProps?.onChange && t.fieldProps.onChange(s);
2471
- }
2472
- },
2473
- o
2474
- ) });
2475
- if (t.isPassword) {
2476
- const s = {
2477
- key: o,
2478
- label: t.label,
2479
- source: t.attribute,
2480
- ...t.slotProps ? { slotProps: t.slotProps } : {}
2481
- };
2482
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(je, { ...s }) });
2483
- }
2484
- const f = {
2485
- label: t.label,
2486
- source: t.listAttribute || t.attribute,
2487
- ...t.fieldProps,
2488
- ...t.slotProps ? { slotProps: t.slotProps } : {},
2489
- onChange: (s) => {
2490
- c?.handleChange && c.handleChange(s), t.fieldProps?.onChange && t.fieldProps.onChange(s);
2491
- }
2492
- };
2493
- return /* @__PURE__ */ r(F, { index: o, method: l, input: t, children: /* @__PURE__ */ r(
2494
- At,
2495
- {
2496
- ...f
2497
- }
2498
- ) });
2499
- }, C = (e) => !e || typeof e != "string" ? !1 : /^[a-z][a-z0-9_.]*[a-z0-9]$/i.test(e) && e.includes("."), xr = () => {
2500
- const e = et(), a = z((u, l) => {
2501
- if (!u) return l || "";
2502
- if (C(u)) {
2503
- const m = e(u, { _: u });
2504
- return m === u && l ? l : m;
2505
- }
2506
- return u;
2507
- }, [e]), t = z((u) => u ? C(u) ? e(u, { _: u }) : u : "", [e]), o = z((u, l) => e(u, l), [e]), c = z((u) => C(u) ? e(u, { _: u }) !== u : !1, [e]);
2508
- return $(() => ({
2509
- translate: e,
2510
- translateLabel: a,
2511
- translateIfKey: t,
2512
- translateWithParams: o,
2513
- hasTranslation: c,
2514
- isTranslationKey: C
2515
- }), [e, a, t, o, c]);
2516
- }, Wr = (e, a, t) => {
2517
- if (!e) return t || "";
2518
- if (C(e)) {
2519
- const o = a(e, { _: e });
2520
- return o === e && t ? t : o;
2521
- }
2522
- return e;
2523
- }, lr = ({
2524
- label: e,
2525
- fallback: a = "",
2526
- className: t,
2527
- component: o = "span",
2528
- componentProps: c = {}
2529
- }) => {
2530
- const u = et();
2531
- if (!e)
2532
- return a ? /* @__PURE__ */ r(o, { className: t, ...c, children: a }) : null;
2533
- let l = e;
2534
- if (C(e)) {
2535
- const m = u(e, { _: e });
2536
- m === e && a ? l = a : l = m;
2537
- }
2538
- return /* @__PURE__ */ r(o, { className: t, ...c, children: l });
2539
- }, Vr = (e) => (a) => {
2540
- const t = et();
2541
- let o = a.label;
2542
- return a.label && C(a.label) && (o = t(a.label, { _: a.label })), /* @__PURE__ */ r(e, { ...a, label: o });
2543
- }, sr = ({
2544
- schema: e,
2545
- resourceConfig: a,
2546
- options: t
2547
- }) => {
2548
- const o = De?.defaultTabName || a.label, c = (l) => /* @__PURE__ */ r("legend", { children: /* @__PURE__ */ r(lr, { label: l, fallback: o }) }), u = t?.isDrawer === !0;
2549
- switch (t?.mode) {
2550
- case "create":
2551
- return L(e).map((l, m) => {
2552
- let b = l;
2553
- u && (b = b.filter(
2554
- (i) => i?.inDrawer !== !1
2555
- ));
2556
- const d = b.filter((i) => i?.inCreate !== !1);
2557
- return d.length ? /* @__PURE__ */ T("fieldset", { children: [
2558
- d.length > 0 && c(b[0].tab || t?.label),
2559
- d.map(
2560
- (i, n) => S.cloneElement(
2561
- k(
2562
- t.mode,
2563
- a,
2564
- i,
2565
- n,
2566
- t
2567
- ),
2568
- { key: `create-${m}-${n}` }
2569
- )
2570
- )
2571
- ] }, `auto-admin-fieldset-${m}`) : null;
2572
- });
2573
- case "edit":
2574
- return L(e).map((l, m) => {
2575
- let b = l;
2576
- u && (b = b.filter(
2577
- (i) => i?.inDrawer !== !1
2578
- ));
2579
- const d = b.filter((i) => i?.inEdit !== !1);
2580
- return d.length ? /* @__PURE__ */ T("fieldset", { children: [
2581
- d.length > 0 && c(b[0].tab || t?.label),
2582
- d.map(
2583
- (i, n) => S.cloneElement(
2584
- k(
2585
- t.mode,
2586
- a,
2587
- i,
2588
- n,
2589
- t
2590
- ),
2591
- { key: `edit-${m}-${n}` }
2592
- )
2593
- )
2594
- ] }, `auto-admin-fieldset-${m}`) : null;
2595
- });
2596
- case "view":
2597
- return L(e).map((l, m) => {
2598
- let b = l;
2599
- u && (b = b.filter(
2600
- (i) => i?.inDrawer !== !1
2601
- ));
2602
- const d = b.filter((i) => i?.inShow !== !1);
2603
- return d.length ? /* @__PURE__ */ T("fieldset", { children: [
2604
- d.length > 0 && c(b[0].tab || t?.label),
2605
- d.map(
2606
- (i, n) => S.cloneElement(
2607
- k(
2608
- t.mode,
2609
- a,
2610
- i,
2611
- n,
2612
- t
2613
- ),
2614
- { key: `view-${m}-${n}` }
2615
- )
2616
- )
2617
- ] }, `auto-admin-fieldset-${m}`) : null;
2618
- });
2619
- case "list":
2620
- return L(e).map((l, m) => {
2621
- let b = l;
2622
- u && (b = b.filter(
2623
- (i) => i?.inDrawer !== !1
2624
- ));
2625
- const d = b.filter((i) => i?.inShow !== !1);
2626
- return d.length ? /* @__PURE__ */ T("fieldset", { children: [
2627
- d.length > 0 && c(b[0].tab || t?.label),
2628
- d.map(
2629
- (i, n) => S.cloneElement(
2630
- k(
2631
- t.mode,
2632
- a,
2633
- i,
2634
- n,
2635
- t
2636
- ),
2637
- { key: `list-${m}-${n}` }
2638
- )
2639
- )
2640
- ] }, `auto-admin-fieldset-${m}`) : null;
2641
- });
2642
- }
2643
- }, nr = ({
2644
- schema: e,
2645
- resourceConfig: a,
2646
- options: t
2647
- }) => {
2648
- const o = Te(e || []), c = (l) => (o[l] ? o[l] : []).filter((b) => b?.inEdit !== !1).map(
2649
- (b, d) => k("edit", a, b, d, t)
2650
- ), u = (l) => (o[l] ? o[l] : []).filter((b) => b?.inCreate !== !1).map(
2651
- (b, d) => k("create", a, b, d, t)
2652
- );
2653
- switch (t.mode) {
2654
- case "create":
2655
- return !a?.createLayout || typeof a.createLayout != "function" ? (console.warn(
2656
- "⚠️ createLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs"
2657
- ), dt({
2658
- schema: e,
2659
- resourceConfig: a,
2660
- options: t
2661
- })) : a.createLayout(u);
2662
- case "edit":
2663
- return !a?.editLayout || typeof a.editLayout != "function" ? (console.warn(
2664
- "⚠️ createLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs"
2665
- ), dt({
2666
- schema: e,
2667
- resourceConfig: a,
2668
- options: t
2669
- })) : a.editLayout(c);
2670
- /*case "view":
2671
- case "list":
2672
- if (!resource.showLayout || typeof resource.showLayout !== "function") {
2673
- console.error("showLayout must be present and be a function in the resource definition when using formGroupMode layout, fallback to tabs");
2674
- return AutoFormTabs({
2675
- schema: schema,
2676
- resource: resource,
2677
- options: { mode: options.mode },
2678
- })
2679
- }
2680
-
2681
- return resource.createLayout(renderShow)
2682
- */
2683
- default:
2684
- return /* @__PURE__ */ r(E, { children: "mode not allowed" });
2685
- }
2686
- }, q = (e) => (a) => {
2687
- const t = {};
2688
- return e.forEach((o) => {
2689
- if (o.validate)
2690
- try {
2691
- o.validate(a[o.attribute], a);
2692
- } catch (c) {
2693
- let u = "Error";
2694
- c instanceof Error && (u = c.message), t[o.attribute] = u;
2695
- }
2696
- }), t;
2697
- }, zr = ({
2698
- resourceConfig: e,
2699
- onSubmit: a,
2700
- beforeSubmit: t,
2701
- onError: o,
2702
- //onCancel,
2703
- toolbar: c,
2704
- mode: u,
2705
- children: l
2706
- }) => {
2707
- const m = _t(), b = bt(), d = oe(), i = !1, n = async (p) => {
2708
- window.dispatchEvent(
2709
- new MessageEvent("dash-global-loader", { data: !0 })
2710
- );
2711
- try {
2712
- t && (p = t(p));
2713
- const { data: y } = await d.create(m, {
2714
- data: p
2715
- });
2716
- a && a(y);
2717
- } catch (y) {
2718
- o && o(y);
2719
- } finally {
2720
- window.dispatchEvent(
2721
- new MessageEvent("dash-global-loader", { data: !1 })
2722
- );
2723
- }
2724
- }, f = async (p) => {
2725
- window.dispatchEvent(
2726
- new MessageEvent("dash-global-loader", { data: !0 })
2727
- );
2728
- try {
2729
- t && (p = t(p));
2730
- const { data: y } = await d.update(m, {
2731
- id: b?.id,
2732
- data: p,
2733
- previousData: b
2734
- });
2735
- a && a(y);
2736
- } catch (y) {
2737
- o && o(y);
2738
- } finally {
2739
- window.dispatchEvent(
2740
- new MessageEvent("dash-global-loader", { data: !1 })
2741
- );
2742
- }
2743
- };
2744
- let s = n;
2745
- switch (u) {
2746
- case "edit":
2747
- s = f;
2748
- break;
2749
- case "create":
2750
- s = n;
2751
- break;
2752
- }
2753
- return /* @__PURE__ */ r(J, { value: { onSave: s, mode: u }, children: /* @__PURE__ */ r(N, { children: /* @__PURE__ */ r(
2754
- Y,
2755
- {
2756
- toolbar: c || /* @__PURE__ */ T(mt, { children: [
2757
- u === "edit" && /* @__PURE__ */ r(xa, { resourceConfig: e }),
2758
- u === "create" && /* @__PURE__ */ r(ht, { resourceConfig: e }),
2759
- /* @__PURE__ */ r(zt, { resourceConfig: e })
2760
- ] }),
2761
- onSubmit: s,
2762
- validate: q(e.schema),
2763
- reValidateMode: "onBlur",
2764
- children: l
2765
- }
2766
- ) }) });
2767
- }, dt = ({
2768
- schema: e,
2769
- resourceConfig: a,
2770
- options: t
2771
- }) => {
2772
- const o = t.isDrawer === !0;
2773
- t = { ...t, handleChange: (d) => {
2774
- const { name: i, value: n, type: f } = d.target;
2775
- f === "checkbox" && d.target.checked;
2776
- } };
2777
- const u = (d, i) => i.map((n, f) => /* @__PURE__ */ r("div", { children: k(d, a, n, f, t) }, `input-${f}`)), l = (d, i) => {
2778
- let n = d.filter((f) => {
2779
- switch (i) {
2780
- case "create":
2781
- return f?.inCreate !== !1;
2782
- case "edit":
2783
- return f?.inEdit !== !1;
2784
- case "view":
2785
- return f?.inShow !== !1;
2786
- default:
2787
- return !0;
2788
- }
2789
- });
2790
- return o && (n = n.filter((f) => f?.inDrawer !== !1)), n;
2791
- }, m = L(e), b = (d) => m.map((i) => ({
2792
- original: i,
2793
- filtered: l(i, d)
2794
- })).filter((i) => i.filtered.length > 0);
2795
- switch (t.mode) {
2796
- case "create": {
2797
- const d = b("create");
2798
- return d.length === 1 ? /* @__PURE__ */ r(E, { children: u("create", d[0].filtered) }) : d.map((i, n) => /* @__PURE__ */ r(
2799
- K,
2800
- {
2801
- value: n,
2802
- label: i.original[0].tab || t?.label || a?.label,
2803
- children: u("create", i.filtered)
2804
- },
2805
- `tab-${i.original[0].tab || n}`
2806
- ));
2807
- }
2808
- case "edit": {
2809
- const d = b("edit");
2810
- return d.length === 1 ? /* @__PURE__ */ r(E, { children: u("edit", d[0].filtered) }) : d.map((i, n) => /* @__PURE__ */ r(
2811
- K,
2812
- {
2813
- value: n,
2814
- label: i.original[0].tab || t?.label || a?.label,
2815
- children: u("edit", i.filtered)
2816
- },
2817
- `tab-${i.original[0].tab || n}`
2818
- ));
2819
- }
2820
- case "view": {
2821
- const d = b("view");
2822
- return d.length === 1 ? /* @__PURE__ */ r(E, { children: u("view", d[0].filtered) }) : d.map((i, n) => /* @__PURE__ */ r(
2823
- K,
2824
- {
2825
- value: n,
2826
- label: i.original[0].tab || t?.label || a?.label,
2827
- children: u("view", i.filtered)
2828
- },
2829
- `tab-${i.original[0].tab || n}`
2830
- ));
2831
- }
2832
- }
2833
- };
2834
- dt.whyDidYouRender = !0;
2835
- const ir = ({ schema: e, resourceConfig: a, options: t, isDrawer: o }) => {
2836
- const c = Wt(), [u, l] = R(0), m = (i) => {
2837
- const { name: n, value: f, type: s } = i.target;
2838
- s === "checkbox" && i.target.checked, console.log("DashAutoFormMuiTabs: dispatch method deprecated");
2839
- }, b = (i, n) => {
2840
- l(n);
2841
- };
2842
- _(() => () => {
2843
- console.log("DashAutoFormMuiTabs: dispatch method deprecated");
2844
- }, [c]);
2845
- const d = L(e);
2846
- return t?.meta?.tabs === "mui" ? /* @__PURE__ */ T(N, { sx: { width: "100%" }, children: [
2847
- /* @__PURE__ */ r(N, { sx: { borderBottom: 1, borderColor: "divider" }, children: /* @__PURE__ */ r(Ot, { value: u, onChange: b, children: d.map((i, n) => /* @__PURE__ */ r(Nt, { label: i[0].tab || t?.label || "" }, `tab-${i[0].tab || n}`)) }) }),
2848
- d.map((i, n) => {
2849
- let f = i.filter(
2850
- (s) => s?.inCreate !== !1
2851
- );
2852
- return o && (f = f.filter(
2853
- (s) => s?.inDrawer !== !1
2854
- )), /* @__PURE__ */ r(
2855
- "div",
2856
- {
2857
- role: "tabpanel",
2858
- hidden: u !== n,
2859
- style: { padding: "20px 0" },
2860
- children: f.map((s, h) => /* @__PURE__ */ r("div", { children: k("create", a, s, h, { ...t, handleChange: m }) }, `input-${h}`))
2861
- },
2862
- `panel-${n}`
2863
- );
2864
- })
2865
- ] }) : L(e).map((i, n) => {
2866
- let f = i.filter(
2867
- (s) => s?.inCreate !== !1
2868
- );
2869
- return o && (f = f.filter(
2870
- (s) => s?.inDrawer !== !1
2871
- )), f.length && /* @__PURE__ */ r(
2872
- K,
2873
- {
2874
- value: n,
2875
- label: i[0].tab || t?.label || "",
2876
- children: f.map((s, h) => /* @__PURE__ */ r("div", { children: k("create", a, s, h, { ...t, handleChange: m }) }, `input-${h}`))
2877
- },
2878
- `tab-${i[0].tab || n}`
2879
- );
2880
- });
2881
- }, cr = ({ schema: e, resourceConfig: a, options: t, isDrawer: o }) => {
2882
- const c = Wt(), [u, l] = R(0), m = (i) => {
2883
- const { name: n, value: f, type: s } = i.target;
2884
- s === "checkbox" && i.target.checked, console.log("DashAutoFormMuiTabs: dispatch method deprecated");
2885
- }, b = (i, n) => {
2886
- l(n);
2887
- };
2888
- _(() => () => {
2889
- console.log("DashAutoFormMuiTabs: dispatch method deprecated");
2890
- }, [c]);
2891
- const d = L(e);
2892
- return t?.meta?.tabs === "mui" ? /* @__PURE__ */ T(N, { sx: { width: "100%" }, children: [
2893
- /* @__PURE__ */ r(N, { sx: { borderBottom: 1, borderColor: "divider" }, children: /* @__PURE__ */ r(Ot, { value: u, onChange: b, children: d.map((i, n) => /* @__PURE__ */ r(Nt, { label: i[0].tab || t?.label || "" }, `tab-${i[0].tab || n}`)) }) }),
2894
- d.map((i, n) => {
2895
- let f = i.filter(
2896
- (s) => s?.inEdit !== !1
2897
- );
2898
- return o && (f = f.filter(
2899
- (s) => s?.inDrawer !== !1
2900
- )), /* @__PURE__ */ r(
2901
- "div",
2902
- {
2903
- role: "tabpanel",
2904
- hidden: u !== n,
2905
- style: { padding: "20px 0" },
2906
- children: f.map((s, h) => /* @__PURE__ */ r("div", { children: k("edit", a, s, h, { ...t, handleChange: m }) }, `input-${h}`))
2907
- },
2908
- `panel-${n}`
2909
- );
2910
- })
2911
- ] }) : L(e).map((i, n) => {
2912
- let f = i.filter(
2913
- (s) => s?.inEdit !== !1
2914
- );
2915
- return o && (f = f.filter(
2916
- (s) => s?.inDrawer !== !1
2917
- )), f.length && /* @__PURE__ */ r(
2918
- K,
2919
- {
2920
- value: n,
2921
- label: i[0].tab || t?.label || "",
2922
- children: f.map((s, h) => /* @__PURE__ */ r("div", { children: k("edit", a, s, h, { ...t, handleChange: m }) }, `input-${h}`))
2923
- },
2924
- `tab-${i[0].tab || n}`
2925
- );
2926
- });
2927
- }, dr = ({ schema: e, resourceConfig: a, options: t, isDrawer: o }) => {
2928
- const c = Wt(), [u, l] = R(0), m = (i) => {
2929
- const { name: n, value: f, type: s } = i.target;
2930
- s === "checkbox" && i.target.checked, console.log("DashAutoFormMuiTabs: dispatch method deprecated");
2931
- }, b = (i, n) => {
2932
- l(n);
2933
- };
2934
- _(() => () => {
2935
- console.log("DashAutoFormMuiTabs: dispatch method deprecated");
2936
- }, [c]);
2937
- const d = L(e);
2938
- return t?.meta?.tabs === "mui" ? /* @__PURE__ */ T(N, { sx: { width: "100%" }, children: [
2939
- /* @__PURE__ */ r(N, { sx: { borderBottom: 1, borderColor: "divider" }, children: /* @__PURE__ */ r(Ot, { value: u, onChange: b, children: d.map((i, n) => /* @__PURE__ */ r(Nt, { label: i[0].tab || t?.label || "" }, `tab-${i[0].tab || n}`)) }) }),
2940
- d.map((i, n) => {
2941
- let f = i.filter(
2942
- (s) => s?.inShow !== !1
2943
- );
2944
- return o && (f = f.filter(
2945
- (s) => s?.inDrawer !== !1
2946
- )), /* @__PURE__ */ r(
2947
- "div",
2948
- {
2949
- role: "tabpanel",
2950
- hidden: u !== n,
2951
- style: { padding: "20px 0" },
2952
- children: f.map((s, h) => /* @__PURE__ */ r("div", { children: k("view", a, s, h, { ...t, handleChange: m }) }, `input-${h}`))
2953
- },
2954
- `panel-${n}`
2955
- );
2956
- })
2957
- ] }) : L(e).map((i, n) => {
2958
- let f = i.filter(
2959
- (s) => s?.inShow !== !1
2960
- );
2961
- return o && (f = f.filter(
2962
- (s) => s?.inDrawer !== !1
2963
- )), f.length && /* @__PURE__ */ r(
2964
- K,
2965
- {
2966
- value: n,
2967
- label: i[0].tab || t?.label || "",
2968
- children: f.map((s, h) => /* @__PURE__ */ r("div", { children: k("view", a, s, h, { ...t, handleChange: m }) }, `input-${h}`))
2969
- },
2970
- `tab-${i[0].tab || n}`
2971
- );
2972
- });
2973
- }, Cr = ({
2974
- schema: e,
2975
- resourceConfig: a,
2976
- options: t
2977
- }) => {
2978
- const o = t.isDrawer === !0;
2979
- t?.meta;
2980
- const c = {
2981
- schema: e,
2982
- resourceConfig: a,
2983
- options: t,
2984
- isDrawer: o
2985
- };
2986
- switch (t.mode) {
2987
- case "create":
2988
- return /* @__PURE__ */ r(ir, { ...c });
2989
- case "edit":
2990
- return /* @__PURE__ */ r(cr, { ...c });
2991
- case "view":
2992
- return /* @__PURE__ */ r(dr, { ...c });
2993
- default:
2994
- return null;
2995
- }
2996
- }, ur = (e) => {
2997
- const a = e.type ? e.type : "ReferenceManyField";
2998
- return /* @__PURE__ */ T(se, { label: e.tab || e.reference, children: [
2999
- a === "ReferenceManyField" && /* @__PURE__ */ r(
3000
- Je,
3001
- {
3002
- fullWidth: !0,
3003
- reference: e.reference,
3004
- target: e.target,
3005
- pagination: /* @__PURE__ */ r(St, {}),
3006
- children: /* @__PURE__ */ r(
3007
- Lt,
3008
- {
3009
- schema: e?.schema,
3010
- bulkActions: e?.BulkActions
3011
- }
3012
- )
3013
- }
3014
- ),
3015
- a === "ReferenceArrayField" && /* @__PURE__ */ r(
3016
- vt,
3017
- {
3018
- fullWidth: !0,
3019
- reference: e.reference,
3020
- source: e.target,
3021
- pagination: /* @__PURE__ */ r(St, {}),
3022
- children: /* @__PURE__ */ r(
3023
- Lt,
3024
- {
3025
- schema: e.schema,
3026
- bulkActions: e?.BulkActions
3027
- }
3028
- )
3029
- }
3030
- )
3031
- ] }, e.reference);
3032
- }, Z = (e) => ur(e);
3033
- function br(e) {
3034
- return typeof e == "function" && !!e.prototype.isReactComponent;
3035
- }
3036
- function mr(e) {
3037
- return typeof e == "function" && String(e).includes("return React.createElement");
3038
- }
3039
- function Ur(e) {
3040
- return br(e) || mr(e);
3041
- }
3042
- const hr = la.system.URL_PREFIX, jr = ({
3043
- method: e,
3044
- resourceConfig: a,
3045
- stateHashPattern: t = hr,
3046
- drawerMethod: o = "edit",
3047
- ...c
3048
- }) => {
3049
- const u = $t(), l = re(), m = a?.idParamName || "id";
3050
- return _(() => {
3051
- let b = t.replace(
3052
- `:${m}`,
3053
- u[m]
3054
- );
3055
- b = b.replace(":method", o), l(
3056
- e,
3057
- a.model,
3058
- e === "edit" ? u.id : null,
3059
- null,
3060
- { hash: b }
3061
- );
3062
- }, []), /* @__PURE__ */ r(le, {});
3063
- }, Hr = (e, a = {}) => {
3064
- const {
3065
- useAxios: t,
3066
- storage: o,
3067
- authPersistence: c,
3068
- syncToDeviceStore: u,
3069
- syncFromDeviceStore: l,
3070
- setAuthEvent: m,
3071
- logoutFromStorage: b,
3072
- getAuthEndpoint: d,
3073
- guestRole: i = { name: "guest" },
3074
- enableTenantImpersonation: n = !1
3075
- } = e, f = {
3076
- login: async ({ username: s, password: h }) => {
3077
- await l();
3078
- const p = t();
3079
- if (!(s && h))
3080
- return Promise.reject();
3081
- try {
3082
- const y = await p.post("/login", {
3083
- email: s,
3084
- password: h
3085
- });
3086
- if (y.status >= 200 && y.status <= 299) {
3087
- const A = y.data.redirectTo;
3088
- y.data !== "" && o.setItem("token", y.data.token);
3089
- try {
3090
- const { data: w } = await p.get(d());
3091
- return c.saveAuth(w), o.setItem("authenticated", "true"), o.setItem("user", JSON.stringify(w.user)), o.setItem(
3092
- "roles",
3093
- w.user?.roles ? JSON.stringify(w.user.roles) : JSON.stringify(i)
3094
- ), m && m({
3095
- authenticated: !0,
3096
- user: w.user,
3097
- auth: w.auth,
3098
- token: y.data.token,
3099
- roles: w.user?.roles
3100
- }), await u(), A ? Promise.resolve({ redirectTo: A }) : Promise.resolve(w);
3101
- } catch (w) {
3102
- return console.error("Error getting user auth data"), await b("login get auth error"), Promise.reject(w);
3103
- }
3104
- }
3105
- } catch (y) {
3106
- return console.error(y), await b("login error logout"), Promise.reject(y);
3107
- }
3108
- return await b("login default error logout"), Promise.reject();
3109
- },
3110
- logout: async (s) => (await b("logout"), Promise.resolve("/login")),
3111
- getIdentity: async () => {
3112
- const s = t();
3113
- if (!o.getItem("token"))
3114
- return Promise.reject("No token present");
3115
- try {
3116
- const { data: p } = await s.get(d());
3117
- return o.setItem(
3118
- "roles",
3119
- p.user?.roles ? JSON.stringify(p.user.roles) : JSON.stringify(i)
3120
- ), o.setItem("authenticated", "true"), o.setItem("user", JSON.stringify(p.user)), n && p.user?.tenant_id && (o.setItem("tenant_id", p.user?.tenant_id), o.setItem("user_id", p.user?.id)), await Promise.resolve(p);
3121
- } catch (p) {
3122
- return await b("get identity error logout"), Promise.reject(p);
3123
- } finally {
3124
- await u();
3125
- }
3126
- },
3127
- checkAuth: async () => {
3128
- const s = JSON.parse(o.getItem("authenticated") || "false"), h = JSON.parse(o.getItem("user") || "null");
3129
- return s && h?.id && c.getAuth() ? Promise.resolve() : Promise.reject();
3130
- },
3131
- checkError: (s) => {
3132
- const h = s?.response?.status;
3133
- if (window.dispatchEvent(
3134
- new MessageEvent("dash-global-loader", { data: !1 })
3135
- ), h) {
3136
- const p = {};
3137
- switch (h) {
3138
- case 400:
3139
- case 401:
3140
- case 403:
3141
- case 500:
3142
- return window.dispatchEvent(
3143
- new MessageEvent("GlobalError", {
3144
- data: { error: s.response.data || s }
3145
- })
3146
- ), Promise.resolve();
3147
- case 422:
3148
- case 409:
3149
- return p.error = "An undefined error occurred, please try again later", s.response.data?.errors ? Object.keys(s.response.data?.errors).forEach((y) => {
3150
- p[y] = s.response.data?.errors[y].join(" , ");
3151
- }) : s.response.data?.message && (p.error = s.response.data?.message), window.dispatchEvent(
3152
- new MessageEvent("GlobalError", { data: { error: p } })
3153
- ), Promise.resolve();
3154
- default:
3155
- return window.dispatchEvent(
3156
- new MessageEvent("GlobalError", {
3157
- data: { error: s.response.data || s }
3158
- })
3159
- ), Promise.resolve();
3160
- }
3161
- } else
3162
- return Object.keys(s).forEach((p) => {
3163
- Array.isArray(s[p]) ? s[p].join(" , ") : s[p];
3164
- }), Promise.resolve();
3165
- }
3166
- };
3167
- return {
3168
- ...f,
3169
- ...a,
3170
- // Ensure required methods are always present
3171
- login: a.login || f.login,
3172
- logout: a.logout || f.logout,
3173
- checkAuth: a.checkAuth || f.checkAuth,
3174
- checkError: a.checkError || f.checkError,
3175
- getIdentity: a.getIdentity || f.getIdentity
3176
- };
3177
- }, fr = (e, a, t) => a, pr = (e, a) => {
3178
- const t = new FormData();
3179
- return Object.keys(a).forEach((o) => {
3180
- a[o] !== void 0 && a[o] !== null && (a[o] instanceof File ? t.append(o, a[o]) : typeof a[o] == "object" ? t.append(o, JSON.stringify(a[o])) : t.append(o, String(a[o])));
3181
- }), t;
3182
- }, Jr = (e, a = {}) => {
3183
- const {
3184
- useAxios: t,
3185
- storage: o,
3186
- getCacheHash: c = () => null,
3187
- getResourceConfig: u = () => {
3188
- },
3189
- processPostData: l = fr,
3190
- processFormData: m = pr,
3191
- processAxiosError: b = (i) => {
3192
- throw i;
3193
- }
3194
- } = e;
3195
- return {
3196
- ...{
3197
- getList: async (i, n) => {
3198
- const f = o.getItem("tenant_id"), s = t();
3199
- let h = l(
3200
- i,
3201
- { ...n.filter, tenant_id: f },
3202
- "getList"
3203
- );
3204
- const p = n.filter && n.filter.pagination ? n.filter.pagination : n.pagination ? n.pagination : !1;
3205
- p ? h = { ...h, pagination: !0, ...p } : h = { ...h, pagination: !1 }, h = { ...h, ...n.meta }, n.sort && n.sort.field && n.sort.order && !n.meta?.removeSortFilters && (h = {
3206
- ...h,
3207
- ...n.sort,
3208
- order: n.sort.order.toLowerCase()
3209
- });
3210
- const A = c(i);
3211
- A && (h = { ...h, hash: A });
3212
- const w = Q.stringify(h, { arrayFormat: "bracket" });
3213
- let g = `${i}?${w}`;
3214
- const B = g.includes("forSelect") ? "forSelect" : g.includes("getMany") ? "getMany" : "getList";
3215
- window.dispatchEvent(
3216
- new MessageEvent("auto-admin-loading-state", {
3217
- data: !0,
3218
- origin: B,
3219
- lastEventId: g
3220
- })
3221
- );
3222
- try {
3223
- const v = await s.get(g);
3224
- let D;
3225
- return typeof v.data?.data?.total < "u" ? D = v.data.data : v?.data?.data && Array.isArray(v.data.data) ? D = { data: v.data.data, total: v.data.total || v.data.data.length } : v?.data && Array.isArray(v.data) ? D = { data: v.data, total: v.data.length } : D = { data: [], total: 0 }, window.dispatchEvent(
3226
- new MessageEvent("auto-admin-loading-state", {
3227
- data: !1,
3228
- origin: B,
3229
- lastEventId: g
3230
- })
3231
- ), D;
3232
- } catch (v) {
3233
- return window.dispatchEvent(new MessageEvent("DASHGlobalError", { data: { error: v, config: { dialog: !0 } } })), { data: [], total: 0 };
3234
- } finally {
3235
- window.dispatchEvent(
3236
- new MessageEvent("auto-admin-loading-state", {
3237
- data: !1,
3238
- origin: B,
3239
- lastEventId: g
3240
- })
3241
- );
3242
- }
3243
- },
3244
- getOne: async (i, n) => {
3245
- const f = t();
3246
- try {
3247
- return { data: (await f.get(
3248
- `${i}/${n.id}`,
3249
- n.meta ? { params: n.meta } : {}
3250
- )).data };
3251
- } catch (s) {
3252
- throw s;
3253
- }
3254
- },
3255
- getMany: async (i, n) => {
3256
- const f = t(), s = Array.isArray(n.ids) && n.ids.length > 0 && Array.isArray(n.ids[0]) ? n.ids[0] : n.ids;
3257
- let h = {
3258
- ids: Array.isArray(s) && s.length > 0 && s[0]?.id ? s.map((w) => w.id) : s
3259
- };
3260
- h = { ...h, pagination: !1 };
3261
- const p = c(i);
3262
- p && (h = { ...h, hash: p });
3263
- const y = Q.stringify(h, { arrayFormat: "bracket" }), A = `${i}/getMany?${y}`;
3264
- try {
3265
- const w = await f.get(A), g = w.data;
3266
- return {
3267
- data: g.data,
3268
- total: g.data && g.data.total ? g.data.total : parseInt(w.headers["content-range"]) || 0
3269
- };
3270
- } catch (w) {
3271
- throw w;
3272
- }
3273
- },
3274
- getManyReference: async (i, n) => {
3275
- const f = o.getItem("tenant_id"), s = t(), h = n.filter && n.filter.pagination ? n.filter.pagination : !1;
3276
- let p = {
3277
- ...n.filter,
3278
- [n.target]: n.id,
3279
- tenant_id: f
3280
- };
3281
- h ? p = { ...p, pagination: !0, ...h } : p = { ...p, pagination: !1 };
3282
- const y = `${i}/getManyReference?${Q.stringify(p, { arrayFormat: "bracket" })}`;
3283
- try {
3284
- const A = await s.get(y), w = A.data;
3285
- return {
3286
- data: w,
3287
- total: w.data && w.data.total ? w.data.total : parseInt(A.headers["content-range"]) || 0
3288
- };
3289
- } catch (A) {
3290
- throw A;
3291
- }
3292
- },
3293
- update: async (i, n) => {
3294
- const f = t(), h = u(i)?.isFormData === !0 || n.data?.isFormData === !0 || n.meta?.isFormData === !0, p = n && n.data && n.data.tenant_id ? n.data.tenant_id : o.getItem("tenant_id"), y = /\/\d+(?:\/[^\/]*)?$/.test(i) ? i : n.id ? `${i}/${n.id}` : i, A = l(
3295
- y,
3296
- { ...n.data, tenant_id: p },
3297
- "update"
3298
- );
3299
- let w = n.meta?.method || "PUT";
3300
- w = A?.axiosMethod || w, delete A.axiosMethod, w === "PUT" && (A._method = "PUT");
3301
- try {
3302
- if (h) {
3303
- const B = m(i, A);
3304
- return await f.post(y, B, {
3305
- headers: { "Content-Type": "multipart/form-data" }
3306
- });
3307
- }
3308
- return await f.post(y, A);
3309
- } catch (g) {
3310
- throw b(g, i, "update");
3311
- }
3312
- },
3313
- create: async (i, n) => {
3314
- const f = t(), h = u(i)?.isFormData === !0 || n.data?.isFormData === !0 || n.meta?.isFormData === !0, p = /\/[\w-]+$/.test(i) ? i : n.meta?.id ? `${i}/${n.meta.id}` : i;
3315
- let y = n.data?.tenant_id;
3316
- i !== "system/user" && !y && (y = o.getItem("tenant_id"));
3317
- const w = (n.meta?.method || "POST") === "POST" ? f.post : f.put, g = l(
3318
- p,
3319
- {
3320
- ...n.data,
3321
- ...y ? { tenant_id: y } : {}
3322
- },
3323
- "create"
3324
- );
3325
- try {
3326
- if (h) {
3327
- const B = m(i, g);
3328
- return await w(p, B, {
3329
- headers: { "Content-Type": "multipart/form-data" }
3330
- });
3331
- }
3332
- return await w(p, g);
3333
- } catch (B) {
3334
- throw b(B, i, "create");
3335
- }
3336
- },
3337
- updateMany: async (i, n) => {
3338
- const f = o.getItem("tenant_id"), s = t(), h = {
3339
- filter: JSON.stringify({ ids: n.ids }),
3340
- tenant_id: f
3341
- }, y = (n.meta?.method || "POST") === "POST" ? s.post : s.put;
3342
- try {
3343
- return await y(
3344
- `${i}/updateMany?${Q.stringify(h, { arrayFormat: "bracket" })}`,
3345
- n.data
3346
- );
3347
- } catch (A) {
3348
- throw window.dispatchEvent(
3349
- new MessageEvent("dash-global-loader", { data: !1 })
3350
- ), A;
3351
- }
3352
- },
3353
- delete: async (i, n) => {
3354
- const f = o.getItem("tenant_id"), s = t(), { data: h } = await s.delete(`${i}/${n.id}`, {
3355
- data: { tenant_id: f }
3356
- });
3357
- return { data: h };
3358
- },
3359
- deleteMany: async (i, n) => {
3360
- const f = o.getItem("tenant_id"), s = t(), h = {
3361
- ids: n.ids || [],
3362
- tenant_id: f
3363
- };
3364
- return await s.post(
3365
- `${i}/deleteMany?${Q.stringify(h, { arrayFormat: "bracket" })}`
3366
- );
3367
- }
3368
- },
3369
- ...a
3370
- };
3371
- }, De = {
1
+ import { default as default2 } from "./DashAutoList";
2
+ import { default as default3 } from "./DashAutoDrawer";
3
+ import { default as default4 } from "./DashAutoCreate";
4
+ import { default as default5 } from "./DashAutoEdit";
5
+ import { default as default6 } from "./DashAutoFormGroups";
6
+ import { default as default7 } from "./DashAutoFormLayout";
7
+ import { default as default8 } from "./DashAutoAdminForm";
8
+ import { default as default9 } from "./DashAutoFormTabs";
9
+ import { default as default10 } from "./DashAutoFormMuiTabs";
10
+ import { default as default11 } from "./DashAutoReferenceTab";
11
+ import { default as default12 } from "./DashAutoTabs";
12
+ import { default as default13 } from "./DashAutoLayout";
13
+ import { default as default14 } from "./DashAutoAdminSaveButton";
14
+ import {
15
+ DashAutoAdminFormProvider,
16
+ useDashAutoAdminForm
17
+ } from "./context/DashAutoAdminFormContext";
18
+ import { default as default15 } from "./common/DashAutoTitle";
19
+ import { default as default16 } from "./utils/isComponent";
20
+ import { default as default17 } from "./utils/isFC";
21
+ import { default as default18 } from "./utils/isEnum";
22
+ import { default as default19 } from "./utils/invertMap";
23
+ import { default as default20 } from "./utils/enumToChoices";
24
+ import { default as default21 } from "./utils/groupByTabs";
25
+ import { default as default22 } from "./utils/validate";
26
+ import {
27
+ useAutoAdminTranslate,
28
+ isTranslationKey,
29
+ translateLabelSync
30
+ } from "./hooks/useAutoAdminTranslate";
31
+ import { TranslatedLabel, withTranslatedLabel } from "./common/components/TranslatedLabel";
32
+ import { default as default23 } from "./DashRedirect";
33
+ import { default as default24 } from "./utils/evalActionPermission";
34
+ import {
35
+ ComponentRegistryProvider,
36
+ useComponentRegistry
37
+ } from "./DashAutoAdminComponentRegistry";
38
+ const AutoAdminSettings = {
3372
39
  library: "mui",
3373
40
  defaultTabName: "Data"
3374
41
  };
42
+ import {
43
+ createDashAuthProvider,
44
+ createDashDataProvider
45
+ } from "./providers";
3375
46
  export {
3376
- De as AutoAdminSettings,
3377
- $r as ComponentRegistryProvider,
3378
- zr as DashAutoAdminForm,
3379
- J as DashAutoAdminFormProvider,
3380
- j as DashAutoAdminSaveButton,
3381
- Ja as DashAutoCreate,
3382
- Nr as DashAutoDrawer,
3383
- Xa as DashAutoEdit,
3384
- sr as DashAutoFormGroups,
3385
- nr as DashAutoFormLayout,
3386
- Cr as DashAutoFormMuiTabs,
3387
- dt as DashAutoFormTabs,
3388
- Za as DashAutoLayout,
3389
- Rr as DashAutoList,
3390
- Z as DashAutoReferenceTab,
3391
- kt as DashAutoTabs,
3392
- V as DashAutoTitle,
3393
- jr as DashRedirect,
3394
- lr as TranslatedLabel,
3395
- Hr as createDashAuthProvider,
3396
- Jr as createDashDataProvider,
3397
- Xt as enumToChoices,
3398
- Ha as evalActionPermission,
3399
- L as groupByTabs,
3400
- Pa as invertMap,
3401
- Ur as isComponent,
3402
- Ft as isEnum,
3403
- Da as isFC,
3404
- C as isTranslationKey,
3405
- Wr as translateLabelSync,
3406
- xr as useAutoAdminTranslate,
3407
- pe as useComponentRegistry,
3408
- Or as useDashAutoAdminForm,
3409
- q as validate,
3410
- Vr as withTranslatedLabel
47
+ AutoAdminSettings,
48
+ ComponentRegistryProvider,
49
+ default8 as DashAutoAdminForm,
50
+ DashAutoAdminFormProvider,
51
+ default14 as DashAutoAdminSaveButton,
52
+ default4 as DashAutoCreate,
53
+ default3 as DashAutoDrawer,
54
+ default5 as DashAutoEdit,
55
+ default6 as DashAutoFormGroups,
56
+ default7 as DashAutoFormLayout,
57
+ default10 as DashAutoFormMuiTabs,
58
+ default9 as DashAutoFormTabs,
59
+ default13 as DashAutoLayout,
60
+ default2 as DashAutoList,
61
+ default11 as DashAutoReferenceTab,
62
+ default12 as DashAutoTabs,
63
+ default15 as DashAutoTitle,
64
+ default23 as DashRedirect,
65
+ TranslatedLabel,
66
+ createDashAuthProvider,
67
+ createDashDataProvider,
68
+ default20 as enumToChoices,
69
+ default24 as evalActionPermission,
70
+ default21 as groupByTabs,
71
+ default19 as invertMap,
72
+ default16 as isComponent,
73
+ default18 as isEnum,
74
+ default17 as isFC,
75
+ isTranslationKey,
76
+ translateLabelSync,
77
+ useAutoAdminTranslate,
78
+ useComponentRegistry,
79
+ useDashAutoAdminForm,
80
+ default22 as validate,
81
+ withTranslatedLabel
3411
82
  };