@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
@@ -1 +1,576 @@
1
- import{Fragment as F,jsx as a,jsxs as R}from"react/jsx-runtime";import{createElement as m}from"react";import{InputLabel as L}from"@mui/material";import{ImageInput as S,FileInput as $,DateTimeInput as v,ArrayField as E,BooleanField as g,ChipField as I,Datagrid as M,DateField as U,NumberField as q,ImageField as z,ReferenceArrayField as W,ReferenceField as G,SingleFieldList as B,TextField as D,FileField as H,FunctionField as h}from"react-admin";import{UserAction as J}from"../wrappers";import K from"./components/ListStringField";import Q from"../utils/isEnum";import _ from"../utils/replaceParams";import{useParams as V}from"react-router";import{useComponentRegistry as X}from"../DashAutoAdminComponentRegistry";const Y=(o,s,e,l,i,Z,t)=>{const{components:T}=X(),C=V(),r=e.sortable===!0,N=b=>{const c=T[b];return c?{custom:!0,type:"component",component:c}:{custom:!0,type:"component",component:()=>R(F,{children:["No component for ",b]})}},A=s?.fieldWrapper&&typeof s.fieldWrapper=="function"?s.fieldWrapper:({_record:b,_method:c,_attribute:y,_resourceConfig:f,children:d})=>d;if(t=i?.record?i.record:t,i&&i.useReadOnlyInputAsTextField===!0&&e.readOnly)return a(A,{label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,...t&&{record:t},method:o,attribute:e,resourceConfig:s,children:m(D,{...t&&{record:t},sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},key:l,label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps,editable:!1,InputProps:{readOnly:!0},disabled:!0})},l);if(i&&i.readOnlyComponent&&e.readOnly)return m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},a(i.readOnlyComponent,{...t&&{record:t},sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},input:e,label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps,editable:!1,InputProps:{readOnly:!0}},l));if(typeof e.type=="string"&&!e.type.includes(".")&&!Array.isArray(e.type))switch(e.type){case"string":case"text":case"String":e.type=String;break;case"number":case"Number":case"integer":e.type=Number;break;case"boolean":case"Boolean":e.type=Boolean;break;case"date":case"Date":e.type=Date;break;default:e.custom=!0,typeof e?.component=="string"&&(e={...e,...N(e.component)});break}if(e.custom&&e.component||e.type==="component"&&e.component)return a(h,{label:e.label,sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},render:b=>m(A,{...b&&{record:b},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},a(J,{...b&&{record:b},method:o,attribute:e,resourceConfig:s,options:i},`custom_component_${l}`))},`function_field_${l}`);if(Array.isArray(e.type)&&e.type.length>0){const b=e.type[0];if(e.label||(e.label=e.attribute),Q(b))return m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},a(K,{label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,map:b},l));if(typeof b=="string"){const c={...C,...(location.hash.match(/\d+/g)||[]).map(Number).reduce((P,u,k)=>(P[k]=u,P),{})},y=_(c,b),[f,d]=y.split(".");return m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},a(F,{children:a(W,{sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,reference:f,...e.componentProps,children:a(B,{...e.fieldProps,children:a(I,{source:d})})},l)}))}else{const c=e.type;return m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s,...e.componentProps},a(F,{children:a(E,{sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps,children:a(M,{children:c.map((y,f)=>Y(o,s,y,f,i))})},l)}))}}if(typeof e.type=="string"){const b={...C,...(location.hash.match(/\d+/g)||[]).map(Number).reduce((u,k,w)=>(u[w]=k,u),{})},c=_(b,e.type),[y,f]=c.split(".");if(e&&e.multiple===!1){const u={...t&&{record:t},method:o,attribute:e,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},k={...t&&{record:t},sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},label:e.label,link:"show",source:e.listAttribute?e.listAttribute:e.attribute,reference:y,...e.componentProps};return a(A,{...u,children:a(G,{...k})})}const d={...t&&{record:t},method:o,attribute:e,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},P={...t&&{record:t},sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,reference:y};return a(A,{...d,children:a(W,{...P,children:a(B,{...e.fieldProps,children:a(I,{source:f})})})})}switch(e.type){case Number:return m(h,{label:e.label,sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},key:`function_field_${l}`,render:b=>m(A,{...b&&{record:b},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},a(q,{label:e.label,...t&&{record:t},sortable:e.sortable===!0,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps},`number_field_${l}`))});case Boolean:return t?R(F,{children:[e?.showLabel!==!1&&m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},a(L,{htmlFor:e.listAttribute?e.listAttribute:e.attribute,children:e.label})),m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},m(g,{sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},record:t,key:l,id:e.listAttribute?e.listAttribute:e.attribute,label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps}))]}):a(h,{label:e.label,sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},render:b=>a(F,{children:m(A,{...b&&{record:b},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},a(g,{record:t,id:e.listAttribute?e.listAttribute:e.attribute,label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps},l))})});case v:case Date:return m(A,{...t&&{record:t},method:o,attribute:e,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,key:l,resourceConfig:s},m(U,{...t&&{record:t},key:l,sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},label:e.label,showTime:e.fieldProps&&e.fieldProps.showTime||!1,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps}));case S:return m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},m(z,{...t&&{record:t},sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},key:l,source:e.attribute,label:e.label}));case $:return m(A,{...t&&{record:t},method:o,attribute:e,key:l,label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,resourceConfig:s},m(H,{...t&&{record:t},sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},key:l,source:e.listAttribute??e.attribute,title:e.listAttribute,download:!0}))}const O={...t&&{record:t},sortable:r,...r&&{sortBy:e.listAttribute||e.attribute},label:e.label,source:e.listAttribute?e.listAttribute:e.attribute,...e.fieldProps,...e.slotProps?{slotProps:e.slotProps}:{}};return a(A,{label:e.label,sortable:r,source:e.listAttribute?e.listAttribute:e.attribute,...t&&{record:t},method:o,attribute:e,resourceConfig:s,children:a(D,{...O})})};export{Y as AttributeToField};
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
+ import { createElement } from "react";
22
+ import { InputLabel } from "@mui/material";
23
+ import {
24
+ ImageInput,
25
+ FileInput,
26
+ DateTimeInput,
27
+ ArrayField,
28
+ BooleanField,
29
+ ChipField,
30
+ Datagrid,
31
+ DateField,
32
+ NumberField,
33
+ ImageField,
34
+ ReferenceArrayField,
35
+ ReferenceField,
36
+ SingleFieldList,
37
+ TextField,
38
+ FileField,
39
+ FunctionField
40
+ } from "react-admin";
41
+ import { UserAction } from "../wrappers";
42
+ import ListStringsField from "./components/ListStringField";
43
+ import isEnum from "../utils/isEnum";
44
+ import replaceParams from "../utils/replaceParams";
45
+ import { useParams } from "react-router";
46
+ import { useComponentRegistry } from "../DashAutoAdminComponentRegistry";
47
+ const AttributeToField = (method, resourceConfig, input, index, options, resource, record) => {
48
+ var _a;
49
+ const { components } = useComponentRegistry();
50
+ const params = useParams();
51
+ const sortableField = input.sortable === true ? true : false;
52
+ const typeComponentMapper = (type) => {
53
+ const component = components[type];
54
+ if (component) {
55
+ return { custom: true, type: "component", component };
56
+ }
57
+ return { custom: true, type: "component", component: () => /* @__PURE__ */ jsxs(Fragment, { children: [
58
+ "No component for ",
59
+ type
60
+ ] }) };
61
+ };
62
+ const ComponentWrapper = (resourceConfig == null ? void 0 : resourceConfig.fieldWrapper) && typeof resourceConfig.fieldWrapper === "function" ? resourceConfig.fieldWrapper : ({
63
+ _record,
64
+ _method,
65
+ _attribute,
66
+ _resourceConfig,
67
+ children
68
+ }) => {
69
+ return children;
70
+ };
71
+ record = (options == null ? void 0 : options.record) ? options.record : record;
72
+ if (options && options.useReadOnlyInputAsTextField === true && input.readOnly) {
73
+ return /* @__PURE__ */ jsx(
74
+ ComponentWrapper,
75
+ __spreadProps(__spreadValues({
76
+ label: input.label,
77
+ sortable: sortableField,
78
+ source: input.listAttribute ? input.listAttribute : input.attribute
79
+ }, record && { record }), {
80
+ method,
81
+ attribute: input,
82
+ resourceConfig,
83
+ children: /* @__PURE__ */ createElement(
84
+ TextField,
85
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
86
+ sortable: sortableField
87
+ }), sortableField && {
88
+ sortBy: input.listAttribute || input.attribute
89
+ }), {
90
+ key: index,
91
+ label: input.label,
92
+ source: input.listAttribute ? input.listAttribute : input.attribute
93
+ }), __spreadProps(__spreadValues({}, input.fieldProps), {
94
+ editable: false,
95
+ InputProps: { readOnly: true }
96
+ })), {
97
+ disabled: true
98
+ })
99
+ )
100
+ }),
101
+ index
102
+ );
103
+ } else if (options && options.readOnlyComponent && input.readOnly) {
104
+ return /* @__PURE__ */ createElement(
105
+ ComponentWrapper,
106
+ __spreadProps(__spreadValues({}, record && { record }), {
107
+ method,
108
+ attribute: input,
109
+ key: index,
110
+ label: input.label,
111
+ sortable: sortableField,
112
+ source: input.listAttribute ? input.listAttribute : input.attribute,
113
+ resourceConfig
114
+ }),
115
+ /* @__PURE__ */ jsx(
116
+ options.readOnlyComponent,
117
+ __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
118
+ sortable: sortableField
119
+ }), sortableField && {
120
+ sortBy: input.listAttribute || input.attribute
121
+ }), {
122
+ input,
123
+ label: input.label,
124
+ source: input.listAttribute ? input.listAttribute : input.attribute
125
+ }), __spreadProps(__spreadValues({}, input.fieldProps), {
126
+ editable: false,
127
+ InputProps: { readOnly: true }
128
+ })),
129
+ index
130
+ )
131
+ );
132
+ }
133
+ if (typeof input.type === "string" && !input.type.includes(".") && !Array.isArray(input.type)) {
134
+ switch (input.type) {
135
+ case "string":
136
+ case "text":
137
+ case "String":
138
+ input.type = String;
139
+ break;
140
+ case "number":
141
+ case "Number":
142
+ case "integer":
143
+ input.type = Number;
144
+ break;
145
+ case "boolean":
146
+ case "Boolean":
147
+ input.type = Boolean;
148
+ break;
149
+ case "date":
150
+ case "Date":
151
+ input.type = Date;
152
+ break;
153
+ case "custom":
154
+ default:
155
+ input.custom = true;
156
+ if (typeof (input == null ? void 0 : input.component) === "string") {
157
+ input = __spreadValues(__spreadValues({}, input), typeComponentMapper(input.component));
158
+ }
159
+ break;
160
+ }
161
+ }
162
+ if (input.custom && input.component || input.type === "component" && input.component) {
163
+ return /* @__PURE__ */ jsx(
164
+ FunctionField,
165
+ __spreadProps(__spreadValues({
166
+ label: input.label,
167
+ sortable: sortableField
168
+ }, sortableField && {
169
+ sortBy: input.listAttribute || input.attribute
170
+ }), {
171
+ render: (r) => {
172
+ return /* @__PURE__ */ createElement(
173
+ ComponentWrapper,
174
+ __spreadProps(__spreadValues({}, r && { record: r }), {
175
+ method,
176
+ attribute: input,
177
+ key: index,
178
+ label: input.label,
179
+ sortable: sortableField,
180
+ source: input.listAttribute ? input.listAttribute : input.attribute,
181
+ resourceConfig
182
+ }),
183
+ /* @__PURE__ */ jsx(
184
+ UserAction,
185
+ __spreadProps(__spreadValues({}, r && { record: r }), {
186
+ method,
187
+ attribute: input,
188
+ resourceConfig,
189
+ options
190
+ }),
191
+ `custom_component_${index}`
192
+ )
193
+ );
194
+ }
195
+ }),
196
+ `function_field_${index}`
197
+ );
198
+ }
199
+ if (Array.isArray(input.type) && input.type.length > 0) {
200
+ const inputType = input.type[0];
201
+ if (!input.label) {
202
+ input.label = input.attribute;
203
+ }
204
+ if (isEnum(inputType)) {
205
+ return /* @__PURE__ */ createElement(
206
+ ComponentWrapper,
207
+ __spreadProps(__spreadValues({}, record && { record }), {
208
+ method,
209
+ attribute: input,
210
+ key: index,
211
+ label: input.label,
212
+ sortable: sortableField,
213
+ source: input.listAttribute ? input.listAttribute : input.attribute,
214
+ resourceConfig
215
+ }),
216
+ /* @__PURE__ */ jsx(
217
+ ListStringsField,
218
+ {
219
+ label: input.label,
220
+ source: input.listAttribute ? input.listAttribute : input.attribute,
221
+ map: inputType
222
+ },
223
+ index
224
+ )
225
+ );
226
+ }
227
+ if (typeof inputType === "string") {
228
+ const _params = __spreadValues(__spreadValues({}, params), (location.hash.match(/\d+/g) || []).map(Number).reduce((acc, curr, index2) => {
229
+ acc[index2] = curr;
230
+ return acc;
231
+ }, {}));
232
+ const _inputType = replaceParams(_params, inputType);
233
+ const [reference, sourceName] = _inputType.split(".");
234
+ return /* @__PURE__ */ createElement(
235
+ ComponentWrapper,
236
+ __spreadProps(__spreadValues({}, record && { record }), {
237
+ method,
238
+ attribute: input,
239
+ key: index,
240
+ label: input.label,
241
+ sortable: sortableField,
242
+ source: input.listAttribute ? input.listAttribute : input.attribute,
243
+ resourceConfig
244
+ }),
245
+ /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
246
+ ReferenceArrayField,
247
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({
248
+ sortable: sortableField
249
+ }, sortableField && {
250
+ sortBy: input.listAttribute || input.attribute
251
+ }), {
252
+ label: input.label,
253
+ source: input.listAttribute ? input.listAttribute : input.attribute,
254
+ reference
255
+ }), input.componentProps), {
256
+ children: /* @__PURE__ */ jsx(SingleFieldList, __spreadProps(__spreadValues({}, input.fieldProps), { children: /* @__PURE__ */ jsx(ChipField, { source: sourceName }) }))
257
+ }),
258
+ index
259
+ ) })
260
+ );
261
+ } else {
262
+ const inputTypeArray = input.type;
263
+ return /* @__PURE__ */ createElement(
264
+ ComponentWrapper,
265
+ __spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
266
+ method,
267
+ attribute: input,
268
+ key: index,
269
+ label: input.label,
270
+ sortable: sortableField,
271
+ source: input.listAttribute ? input.listAttribute : input.attribute,
272
+ resourceConfig
273
+ }), input.componentProps),
274
+ /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
275
+ ArrayField,
276
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({
277
+ sortable: sortableField
278
+ }, sortableField && {
279
+ sortBy: input.listAttribute || input.attribute
280
+ }), {
281
+ label: input.label,
282
+ source: input.listAttribute ? input.listAttribute : input.attribute
283
+ }), input.fieldProps), {
284
+ children: /* @__PURE__ */ jsx(Datagrid, { children: inputTypeArray.map(
285
+ (attribute, idx) => AttributeToField(
286
+ method,
287
+ resourceConfig,
288
+ attribute,
289
+ idx,
290
+ options
291
+ )
292
+ ) })
293
+ }),
294
+ index
295
+ ) })
296
+ );
297
+ }
298
+ }
299
+ if (typeof input.type === "string") {
300
+ const _params = __spreadValues(__spreadValues({}, params), (location.hash.match(/\d+/g) || []).map(Number).reduce((acc, curr, index2) => {
301
+ acc[index2] = curr;
302
+ return acc;
303
+ }, {}));
304
+ const _inputType = replaceParams(_params, input.type);
305
+ const [reference, sourceName] = _inputType.split(".");
306
+ if (input && input.multiple === false) {
307
+ const componentWrapperProps2 = __spreadProps(__spreadValues({}, record && { record }), {
308
+ method,
309
+ attribute: input,
310
+ label: input.label,
311
+ sortable: sortableField,
312
+ source: input.listAttribute ? input.listAttribute : input.attribute,
313
+ resourceConfig
314
+ });
315
+ const componentProps2 = __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
316
+ sortable: sortableField
317
+ }), sortableField && {
318
+ sortBy: input.listAttribute || input.attribute
319
+ }), {
320
+ label: input.label,
321
+ link: "show",
322
+ source: input.listAttribute ? input.listAttribute : input.attribute,
323
+ reference
324
+ }), input.componentProps);
325
+ return /* @__PURE__ */ jsx(
326
+ ComponentWrapper,
327
+ __spreadProps(__spreadValues({}, componentWrapperProps2), {
328
+ children: /* @__PURE__ */ jsx(
329
+ ReferenceField,
330
+ __spreadValues({}, componentProps2)
331
+ )
332
+ })
333
+ );
334
+ }
335
+ const componentWrapperProps = __spreadProps(__spreadValues({}, record && { record }), {
336
+ method,
337
+ attribute: input,
338
+ label: input.label,
339
+ sortable: sortableField,
340
+ source: input.listAttribute ? input.listAttribute : input.attribute,
341
+ resourceConfig
342
+ });
343
+ const componentProps = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
344
+ sortable: sortableField
345
+ }), sortableField && {
346
+ sortBy: input.listAttribute || input.attribute
347
+ }), {
348
+ label: input.label,
349
+ source: input.listAttribute ? input.listAttribute : input.attribute,
350
+ reference
351
+ });
352
+ return /* @__PURE__ */ jsx(ComponentWrapper, __spreadProps(__spreadValues({}, componentWrapperProps), { children: /* @__PURE__ */ jsx(ReferenceArrayField, __spreadProps(__spreadValues({}, componentProps), { children: /* @__PURE__ */ jsx(SingleFieldList, __spreadProps(__spreadValues({}, input.fieldProps), { children: /* @__PURE__ */ jsx(ChipField, { source: sourceName }) })) })) }));
353
+ }
354
+ switch (input.type) {
355
+ case Number:
356
+ return /* @__PURE__ */ createElement(
357
+ FunctionField,
358
+ __spreadProps(__spreadValues({
359
+ label: input.label,
360
+ sortable: sortableField
361
+ }, sortableField && {
362
+ sortBy: input.listAttribute || input.attribute
363
+ }), {
364
+ key: `function_field_${index}`,
365
+ render: (r) => {
366
+ return /* @__PURE__ */ createElement(
367
+ ComponentWrapper,
368
+ __spreadProps(__spreadValues({}, r && { record: r }), {
369
+ method,
370
+ attribute: input,
371
+ key: index,
372
+ label: input.label,
373
+ sortable: sortableField,
374
+ source: input.listAttribute ? input.listAttribute : input.attribute,
375
+ resourceConfig
376
+ }),
377
+ /* @__PURE__ */ jsx(
378
+ NumberField,
379
+ __spreadValues(__spreadProps(__spreadValues({
380
+ label: input.label
381
+ }, record && { record }), {
382
+ sortable: input.sortable === true ? true : false,
383
+ source: input.listAttribute ? input.listAttribute : input.attribute
384
+ }), input.fieldProps),
385
+ `number_field_${index}`
386
+ )
387
+ );
388
+ }
389
+ })
390
+ );
391
+ case Boolean:
392
+ return record ? /* @__PURE__ */ jsxs(Fragment, { children: [
393
+ (input == null ? void 0 : input.showLabel) !== false && /* @__PURE__ */ createElement(
394
+ ComponentWrapper,
395
+ __spreadProps(__spreadValues({}, record && { record }), {
396
+ method,
397
+ attribute: input,
398
+ key: index,
399
+ label: input.label,
400
+ sortable: sortableField,
401
+ source: input.listAttribute ? input.listAttribute : input.attribute,
402
+ resourceConfig
403
+ }),
404
+ /* @__PURE__ */ jsx(
405
+ InputLabel,
406
+ {
407
+ htmlFor: input.listAttribute ? input.listAttribute : input.attribute,
408
+ children: input.label
409
+ }
410
+ )
411
+ ),
412
+ /* @__PURE__ */ createElement(
413
+ ComponentWrapper,
414
+ __spreadProps(__spreadValues({}, record && { record }), {
415
+ method,
416
+ attribute: input,
417
+ key: index,
418
+ label: input.label,
419
+ sortable: sortableField,
420
+ source: input.listAttribute ? input.listAttribute : input.attribute,
421
+ resourceConfig
422
+ }),
423
+ /* @__PURE__ */ createElement(
424
+ BooleanField,
425
+ __spreadValues(__spreadProps(__spreadValues({
426
+ sortable: sortableField
427
+ }, sortableField && {
428
+ sortBy: input.listAttribute || input.attribute
429
+ }), {
430
+ record,
431
+ key: index,
432
+ id: input.listAttribute ? input.listAttribute : input.attribute,
433
+ label: input.label,
434
+ source: input.listAttribute ? input.listAttribute : input.attribute
435
+ }), input.fieldProps)
436
+ )
437
+ )
438
+ ] }) : /* @__PURE__ */ jsx(
439
+ FunctionField,
440
+ __spreadProps(__spreadValues({
441
+ label: input.label,
442
+ sortable: sortableField
443
+ }, sortableField && {
444
+ sortBy: input.listAttribute || input.attribute
445
+ }), {
446
+ render: (r) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ createElement(
447
+ ComponentWrapper,
448
+ __spreadProps(__spreadValues({}, r && { record: r }), {
449
+ method,
450
+ attribute: input,
451
+ key: index,
452
+ label: input.label,
453
+ sortable: sortableField,
454
+ source: input.listAttribute ? input.listAttribute : input.attribute,
455
+ resourceConfig
456
+ }),
457
+ /* @__PURE__ */ jsx(
458
+ BooleanField,
459
+ __spreadValues({
460
+ record,
461
+ id: input.listAttribute ? input.listAttribute : input.attribute,
462
+ label: input.label,
463
+ source: input.listAttribute ? input.listAttribute : input.attribute
464
+ }, input.fieldProps),
465
+ index
466
+ )
467
+ ) })
468
+ })
469
+ );
470
+ case DateTimeInput:
471
+ case Date:
472
+ return /* @__PURE__ */ createElement(
473
+ ComponentWrapper,
474
+ __spreadProps(__spreadValues({}, record && { record }), {
475
+ method,
476
+ attribute: input,
477
+ label: input.label,
478
+ sortable: sortableField,
479
+ source: input.listAttribute ? input.listAttribute : input.attribute,
480
+ key: index,
481
+ resourceConfig
482
+ }),
483
+ /* @__PURE__ */ createElement(
484
+ DateField,
485
+ __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
486
+ key: index,
487
+ sortable: sortableField
488
+ }), sortableField && {
489
+ sortBy: input.listAttribute || input.attribute
490
+ }), {
491
+ label: input.label,
492
+ showTime: input.fieldProps && input.fieldProps.showTime || false,
493
+ source: input.listAttribute ? input.listAttribute : input.attribute
494
+ }), input.fieldProps)
495
+ )
496
+ );
497
+ case ImageInput:
498
+ return /* @__PURE__ */ createElement(
499
+ ComponentWrapper,
500
+ __spreadProps(__spreadValues({}, record && { record }), {
501
+ method,
502
+ attribute: input,
503
+ key: index,
504
+ label: input.label,
505
+ sortable: sortableField,
506
+ source: input.listAttribute ? input.listAttribute : input.attribute,
507
+ resourceConfig
508
+ }),
509
+ /* @__PURE__ */ createElement(
510
+ ImageField,
511
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
512
+ sortable: sortableField
513
+ }), sortableField && {
514
+ sortBy: input.listAttribute || input.attribute
515
+ }), {
516
+ key: index,
517
+ source: input.attribute,
518
+ label: input.label
519
+ })
520
+ )
521
+ );
522
+ case FileInput:
523
+ return /* @__PURE__ */ createElement(
524
+ ComponentWrapper,
525
+ __spreadProps(__spreadValues({}, record && { record }), {
526
+ method,
527
+ attribute: input,
528
+ key: index,
529
+ label: input.label,
530
+ sortable: sortableField,
531
+ source: input.listAttribute ? input.listAttribute : input.attribute,
532
+ resourceConfig
533
+ }),
534
+ /* @__PURE__ */ createElement(
535
+ FileField,
536
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
537
+ sortable: sortableField
538
+ }), sortableField && {
539
+ sortBy: input.listAttribute || input.attribute
540
+ }), {
541
+ key: index,
542
+ source: (_a = input.listAttribute) != null ? _a : input.attribute,
543
+ title: input.listAttribute,
544
+ download: true
545
+ })
546
+ )
547
+ );
548
+ }
549
+ const textFieldProps = __spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, record && { record }), {
550
+ sortable: sortableField
551
+ }), sortableField && {
552
+ sortBy: input.listAttribute || input.attribute
553
+ }), {
554
+ label: input.label,
555
+ source: input.listAttribute ? input.listAttribute : input.attribute
556
+ }), input.fieldProps), input.slotProps ? { slotProps: input.slotProps } : {});
557
+ return /* @__PURE__ */ jsx(
558
+ ComponentWrapper,
559
+ __spreadProps(__spreadValues({
560
+ label: input.label,
561
+ sortable: sortableField,
562
+ source: input.listAttribute ? input.listAttribute : input.attribute
563
+ }, record && { record }), {
564
+ method,
565
+ attribute: input,
566
+ resourceConfig,
567
+ children: /* @__PURE__ */ jsx(
568
+ TextField,
569
+ __spreadValues({}, textFieldProps)
570
+ )
571
+ })
572
+ );
573
+ };
574
+ export {
575
+ AttributeToField
576
+ };