@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,310 @@
1
- import D from"query-string";const F=(p,f,g)=>f,_=(p,f)=>{const g=new FormData;return Object.keys(f).forEach(d=>{f[d]!==void 0&&f[d]!==null&&(f[d]instanceof File?g.append(d,f[d]):typeof f[d]=="object"?g.append(d,JSON.stringify(f[d])):g.append(d,String(f[d])))}),g},$=(p,f={})=>{const{useAxios:g,storage:d,getCacheHash:w=()=>null,getResourceConfig:v=()=>{},processPostData:P=F,processFormData:m=_,processAxiosError:M=a=>{throw a}}=p;return{...{getList:async(a,t)=>{const r=d.getItem("tenant_id"),n=g();let e=P(a,{...t.filter,tenant_id:r},"getList");const i=t.filter&&t.filter.pagination?t.filter.pagination:t.pagination?t.pagination:!1;i?e={...e,pagination:!0,...i}:e={...e,pagination:!1},e={...e,...t.meta},t.sort&&t.sort.field&&t.sort.order&&!t.meta?.removeSortFilters&&(e={...e,...t.sort,order:t.sort.order.toLowerCase()});const s=w(a);s&&(e={...e,hash:s});const o=D.stringify(e,{arrayFormat:"bracket"});let c=`${a}?${o}`;const u=c.includes("forSelect")?"forSelect":c.includes("getMany")?"getMany":"getList";window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:!0,origin:u,lastEventId:c}));try{const y=await n.get(c);let h;return typeof y.data?.data?.total<"u"?h=y.data.data:y?.data?.data&&Array.isArray(y.data.data)?h={data:y.data.data,total:y.data.total||y.data.data.length}:y?.data&&Array.isArray(y.data)?h={data:y.data,total:y.data.length}:h={data:[],total:0},window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:!1,origin:u,lastEventId:c})),h}catch(y){return window.dispatchEvent(new MessageEvent("DASHGlobalError",{data:{error:y,config:{dialog:!0}}})),{data:[],total:0}}finally{window.dispatchEvent(new MessageEvent("auto-admin-loading-state",{data:!1,origin:u,lastEventId:c}))}},getOne:async(a,t)=>{const r=g();try{return{data:(await r.get(`${a}/${t.id}`,t.meta?{params:t.meta}:{})).data}}catch(n){throw n}},getMany:async(a,t)=>{const r=g(),n=Array.isArray(t.ids)&&t.ids.length>0&&Array.isArray(t.ids[0])?t.ids[0]:t.ids;let e={ids:Array.isArray(n)&&n.length>0&&n[0]?.id?n.map(o=>o.id):n};e={...e,pagination:!1};const i=w(a);i&&(e={...e,hash:i});const l=D.stringify(e,{arrayFormat:"bracket"}),s=`${a}/getMany?${l}`;try{const o=await r.get(s),c=o.data;return{data:c.data,total:c.data&&c.data.total?c.data.total:parseInt(o.headers["content-range"])||0}}catch(o){throw o}},getManyReference:async(a,t)=>{const r=d.getItem("tenant_id"),n=g(),e=t.filter&&t.filter.pagination?t.filter.pagination:!1;let i={...t.filter,[t.target]:t.id,tenant_id:r};e?i={...i,pagination:!0,...e}:i={...i,pagination:!1};const l=`${a}/getManyReference?${D.stringify(i,{arrayFormat:"bracket"})}`;try{const s=await n.get(l),o=s.data;return{data:o,total:o.data&&o.data.total?o.data.total:parseInt(s.headers["content-range"])||0}}catch(s){throw s}},update:async(a,t)=>{const r=g(),e=v(a)?.isFormData===!0||t.data?.isFormData===!0||t.meta?.isFormData===!0,i=t&&t.data&&t.data.tenant_id?t.data.tenant_id:d.getItem("tenant_id"),l=/\/\d+(?:\/[^\/]*)?$/.test(a)?a:t.id?`${a}/${t.id}`:a,s=P(l,{...t.data,tenant_id:i},"update");let o=t.meta?.method||"PUT";o=s?.axiosMethod||o,delete s.axiosMethod,o==="PUT"&&(s._method="PUT");try{if(e){const u=m(a,s);return await r.post(l,u,{headers:{"Content-Type":"multipart/form-data"}})}return await r.post(l,s)}catch(c){throw M(c,a,"update")}},create:async(a,t)=>{const r=g(),e=v(a)?.isFormData===!0||t.data?.isFormData===!0||t.meta?.isFormData===!0,i=/\/[\w-]+$/.test(a)?a:t.meta?.id?`${a}/${t.meta.id}`:a;let l=t.data?.tenant_id;a!=="system/user"&&!l&&(l=d.getItem("tenant_id"));const o=(t.meta?.method||"POST")==="POST"?r.post:r.put,c=P(i,{...t.data,...l?{tenant_id:l}:{}},"create");try{if(e){const u=m(a,c);return await o(i,u,{headers:{"Content-Type":"multipart/form-data"}})}return await o(i,c)}catch(u){throw M(u,a,"create")}},updateMany:async(a,t)=>{const r=d.getItem("tenant_id"),n=g(),e={filter:JSON.stringify({ids:t.ids}),tenant_id:r},l=(t.meta?.method||"POST")==="POST"?n.post:n.put;try{return await l(`${a}/updateMany?${D.stringify(e,{arrayFormat:"bracket"})}`,t.data)}catch(s){throw window.dispatchEvent(new MessageEvent("dash-global-loader",{data:!1})),s}},delete:async(a,t)=>{const r=d.getItem("tenant_id"),n=g(),{data:e}=await n.delete(`${a}/${t.id}`,{data:{tenant_id:r}});return{data:e}},deleteMany:async(a,t)=>{const r=d.getItem("tenant_id"),n=g(),e={ids:t.ids||[],tenant_id:r};return await n.post(`${a}/deleteMany?${D.stringify(e,{arrayFormat:"bracket"})}`)}},...f}};var S=$;export{$ as createDashDataProvider,S as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import queryString from "query-string";
41
+ const defaultProcessPostData = (resource, data, operation) => data;
42
+ const defaultProcessFormData = (resource, data) => {
43
+ const formData = new FormData();
44
+ Object.keys(data).forEach((key) => {
45
+ if (data[key] !== void 0 && data[key] !== null) {
46
+ if (data[key] instanceof File) {
47
+ formData.append(key, data[key]);
48
+ } else if (typeof data[key] === "object") {
49
+ formData.append(key, JSON.stringify(data[key]));
50
+ } else {
51
+ formData.append(key, String(data[key]));
52
+ }
53
+ }
54
+ });
55
+ return formData;
56
+ };
57
+ const createDashDataProvider = (config, overrides = {}) => {
58
+ const {
59
+ useAxios,
60
+ storage,
61
+ getCacheHash = () => null,
62
+ getResourceConfig = () => void 0,
63
+ processPostData = defaultProcessPostData,
64
+ processFormData = defaultProcessFormData,
65
+ processAxiosError = (error) => {
66
+ throw error;
67
+ }
68
+ } = config;
69
+ const defaultProvider = {
70
+ getList: (resource, params) => __async(null, null, function* () {
71
+ var _a, _b, _c, _d;
72
+ const tenant_id = storage.getItem("tenant_id");
73
+ const axios = useAxios();
74
+ let payload = processPostData(
75
+ resource,
76
+ __spreadProps(__spreadValues({}, params.filter), { tenant_id }),
77
+ "getList"
78
+ );
79
+ const pagination = params.filter && !!params.filter.pagination ? params.filter.pagination : params.pagination ? params.pagination : false;
80
+ if (pagination) {
81
+ payload = __spreadValues(__spreadProps(__spreadValues({}, payload), { pagination: true }), pagination);
82
+ } else {
83
+ payload = __spreadProps(__spreadValues({}, payload), { pagination: false });
84
+ }
85
+ payload = __spreadValues(__spreadValues({}, payload), params.meta);
86
+ const hasSort = params.sort && params.sort.field && params.sort.order;
87
+ if (hasSort && !((_a = params.meta) == null ? void 0 : _a.removeSortFilters)) {
88
+ payload = __spreadValues(__spreadValues({}, payload), __spreadProps(__spreadValues({}, params.sort), { order: params.sort.order.toLowerCase() }));
89
+ }
90
+ const hash = getCacheHash(resource);
91
+ if (hash) {
92
+ payload = __spreadProps(__spreadValues({}, payload), { hash });
93
+ }
94
+ const processedQuery = queryString.stringify(payload, { arrayFormat: "bracket" });
95
+ let url = `${resource}?${processedQuery}`;
96
+ const origin = url.includes("forSelect") ? "forSelect" : url.includes("getMany") ? "getMany" : "getList";
97
+ window.dispatchEvent(
98
+ new MessageEvent("auto-admin-loading-state", {
99
+ data: true,
100
+ origin,
101
+ lastEventId: url
102
+ })
103
+ );
104
+ try {
105
+ const response = yield axios.get(url);
106
+ let results;
107
+ if (typeof ((_c = (_b = response.data) == null ? void 0 : _b.data) == null ? void 0 : _c.total) !== "undefined") {
108
+ results = response.data.data;
109
+ } else if (((_d = response == null ? void 0 : response.data) == null ? void 0 : _d.data) && Array.isArray(response.data.data)) {
110
+ results = { data: response.data.data, total: response.data.total || response.data.data.length };
111
+ } else if ((response == null ? void 0 : response.data) && Array.isArray(response.data)) {
112
+ results = { data: response.data, total: response.data.length };
113
+ } else {
114
+ results = { data: [], total: 0 };
115
+ }
116
+ window.dispatchEvent(
117
+ new MessageEvent("auto-admin-loading-state", {
118
+ data: false,
119
+ origin,
120
+ lastEventId: url
121
+ })
122
+ );
123
+ return results;
124
+ } catch (e) {
125
+ window.dispatchEvent(new MessageEvent("DASHGlobalError", { data: { error: e, config: { dialog: true } } }));
126
+ return { data: [], total: 0 };
127
+ } finally {
128
+ window.dispatchEvent(
129
+ new MessageEvent("auto-admin-loading-state", {
130
+ data: false,
131
+ origin,
132
+ lastEventId: url
133
+ })
134
+ );
135
+ }
136
+ }),
137
+ getOne: (resource, params) => __async(null, null, function* () {
138
+ const axios = useAxios();
139
+ try {
140
+ const response = yield axios.get(
141
+ `${resource}/${params.id}`,
142
+ params.meta ? { params: params.meta } : {}
143
+ );
144
+ return { data: response.data };
145
+ } catch (e) {
146
+ throw e;
147
+ }
148
+ }),
149
+ getMany: (resource, params) => __async(null, null, function* () {
150
+ var _a;
151
+ const axios = useAxios();
152
+ const paramsIds = Array.isArray(params.ids) && params.ids.length > 0 && Array.isArray(params.ids[0]) ? params.ids[0] : params.ids;
153
+ let query = {
154
+ ids: Array.isArray(paramsIds) && paramsIds.length > 0 && ((_a = paramsIds[0]) == null ? void 0 : _a.id) ? paramsIds.map((object) => object.id) : paramsIds
155
+ };
156
+ query = __spreadProps(__spreadValues({}, query), { pagination: false });
157
+ const hash = getCacheHash(resource);
158
+ if (hash) {
159
+ query = __spreadProps(__spreadValues({}, query), { hash });
160
+ }
161
+ const _query = queryString.stringify(query, { arrayFormat: "bracket" });
162
+ const url = `${resource}/getMany?${_query}`;
163
+ try {
164
+ const response = yield axios.get(url);
165
+ const results = response.data;
166
+ return {
167
+ data: results.data,
168
+ total: results.data && results.data.total ? results.data.total : parseInt(response.headers["content-range"]) || 0
169
+ };
170
+ } catch (e) {
171
+ throw e;
172
+ }
173
+ }),
174
+ getManyReference: (resource, params) => __async(null, null, function* () {
175
+ const tenant_id = storage.getItem("tenant_id");
176
+ const axios = useAxios();
177
+ const pagination = params.filter && params.filter.pagination ? params.filter.pagination : false;
178
+ let query = __spreadProps(__spreadValues({}, params.filter), {
179
+ [params.target]: params.id,
180
+ tenant_id
181
+ });
182
+ if (pagination) {
183
+ query = __spreadValues(__spreadProps(__spreadValues({}, query), { pagination: true }), pagination);
184
+ } else {
185
+ query = __spreadProps(__spreadValues({}, query), { pagination: false });
186
+ }
187
+ const url = `${resource}/getManyReference?${queryString.stringify(query, { arrayFormat: "bracket" })}`;
188
+ try {
189
+ const response = yield axios.get(url);
190
+ const results = response.data;
191
+ return {
192
+ data: results,
193
+ total: results.data && results.data.total ? results.data.total : parseInt(response.headers["content-range"]) || 0
194
+ };
195
+ } catch (e) {
196
+ throw e;
197
+ }
198
+ }),
199
+ update: (resource, params) => __async(null, null, function* () {
200
+ var _a, _b, _c;
201
+ const axios = useAxios();
202
+ const resourceConfig = getResourceConfig(resource);
203
+ const isFormData = (resourceConfig == null ? void 0 : resourceConfig.isFormData) === true || ((_a = params.data) == null ? void 0 : _a.isFormData) === true || ((_b = params.meta) == null ? void 0 : _b.isFormData) === true;
204
+ const tenant_id = params && params.data && params.data.tenant_id ? params.data.tenant_id : storage.getItem("tenant_id");
205
+ const resourcePath = /\/\d+(?:\/[^\/]*)?$/.test(resource) ? resource : params.id ? `${resource}/${params.id}` : resource;
206
+ const postData = processPostData(
207
+ resourcePath,
208
+ __spreadValues(__spreadValues({}, params.data), { tenant_id }),
209
+ "update"
210
+ );
211
+ let method = ((_c = params.meta) == null ? void 0 : _c.method) || "PUT";
212
+ method = (postData == null ? void 0 : postData.axiosMethod) || method;
213
+ delete postData.axiosMethod;
214
+ if (method === "PUT") {
215
+ postData._method = "PUT";
216
+ }
217
+ try {
218
+ if (isFormData) {
219
+ const form = processFormData(resource, postData);
220
+ const response2 = yield axios.post(resourcePath, form, {
221
+ headers: { "Content-Type": "multipart/form-data" }
222
+ });
223
+ return response2;
224
+ }
225
+ const response = yield axios.post(resourcePath, postData);
226
+ return response;
227
+ } catch (e) {
228
+ throw processAxiosError(e, resource, "update");
229
+ }
230
+ }),
231
+ create: (resource, params) => __async(null, null, function* () {
232
+ var _a, _b, _c, _d, _e;
233
+ const axios = useAxios();
234
+ const resourceConfig = getResourceConfig(resource);
235
+ const isFormData = (resourceConfig == null ? void 0 : resourceConfig.isFormData) === true || ((_a = params.data) == null ? void 0 : _a.isFormData) === true || ((_b = params.meta) == null ? void 0 : _b.isFormData) === true;
236
+ const resourcePath = /\/[\w-]+$/.test(resource) ? resource : ((_c = params.meta) == null ? void 0 : _c.id) ? `${resource}/${params.meta.id}` : resource;
237
+ let tenant_id = (_d = params.data) == null ? void 0 : _d.tenant_id;
238
+ if (resource !== "system/user" && !tenant_id) {
239
+ tenant_id = storage.getItem("tenant_id");
240
+ }
241
+ const method = ((_e = params.meta) == null ? void 0 : _e.method) || "POST";
242
+ const action = method === "POST" ? axios.post : axios.put;
243
+ const postData = processPostData(
244
+ resourcePath,
245
+ __spreadValues(__spreadValues({}, params.data), tenant_id ? { tenant_id } : {}),
246
+ "create"
247
+ );
248
+ try {
249
+ if (isFormData) {
250
+ const form = processFormData(resource, postData);
251
+ return yield action(resourcePath, form, {
252
+ headers: { "Content-Type": "multipart/form-data" }
253
+ });
254
+ }
255
+ return yield action(resourcePath, postData);
256
+ } catch (e) {
257
+ throw processAxiosError(e, resource, "create");
258
+ }
259
+ }),
260
+ updateMany: (resource, params) => __async(null, null, function* () {
261
+ var _a;
262
+ const tenant_id = storage.getItem("tenant_id");
263
+ const axios = useAxios();
264
+ const query = {
265
+ filter: JSON.stringify({ ids: params.ids }),
266
+ tenant_id
267
+ };
268
+ const method = ((_a = params.meta) == null ? void 0 : _a.method) || "POST";
269
+ const action = method === "POST" ? axios.post : axios.put;
270
+ try {
271
+ const response = yield action(
272
+ `${resource}/updateMany?${queryString.stringify(query, { arrayFormat: "bracket" })}`,
273
+ params.data
274
+ );
275
+ return response;
276
+ } catch (e) {
277
+ window.dispatchEvent(
278
+ new MessageEvent("dash-global-loader", { data: false })
279
+ );
280
+ throw e;
281
+ }
282
+ }),
283
+ delete: (resource, params) => __async(null, null, function* () {
284
+ const tenant_id = storage.getItem("tenant_id");
285
+ const axios = useAxios();
286
+ const { data } = yield axios.delete(`${resource}/${params.id}`, {
287
+ data: { tenant_id }
288
+ });
289
+ return { data };
290
+ }),
291
+ deleteMany: (resource, params) => __async(null, null, function* () {
292
+ const tenant_id = storage.getItem("tenant_id");
293
+ const axios = useAxios();
294
+ const query = {
295
+ ids: params.ids || [],
296
+ tenant_id
297
+ };
298
+ const data = yield axios.post(
299
+ `${resource}/deleteMany?${queryString.stringify(query, { arrayFormat: "bracket" })}`
300
+ );
301
+ return data;
302
+ })
303
+ };
304
+ return __spreadValues(__spreadValues({}, defaultProvider), overrides);
305
+ };
306
+ var DashDataProvider_default = createDashDataProvider;
307
+ export {
308
+ createDashDataProvider,
309
+ DashDataProvider_default as default
310
+ };
@@ -1 +1,10 @@
1
- import{createDashAuthProvider as a}from"./DashAuthProvider";import{createDashDataProvider as o}from"./DashDataProvider";export{a as createDashAuthProvider,o as createDashDataProvider};
1
+ import {
2
+ createDashAuthProvider
3
+ } from "./DashAuthProvider";
4
+ import {
5
+ createDashDataProvider
6
+ } from "./DashDataProvider";
7
+ export {
8
+ createDashAuthProvider,
9
+ createDashDataProvider
10
+ };
File without changes
@@ -1 +1,65 @@
1
- import{jsx as t}from"react/jsx-runtime";import{DeleteButton as n}from"react-admin";import l from"../../DashAutoAdminSaveButton";import{DeleteWithConfirmButton as u}from"react-admin";import{WithRecord as a}from"react-admin";const v=r=>{const{resourceConfig:o}=r;if(!o)return t(l,{resourceConfig:o});if(o.bottomToolbarSaveButton)if(o.bottomToolbarSaveButton?.enabled){const e={resourceConfig:o,...o.bottomToolbarSaveButton?.props||{},alwaysEnable:o?.saveButtonAlwaysEnabled===!0};return o.bottomToolbarSaveButton?.component?t(o.bottomToolbarSaveButton.component,{...e}):t(l,{...e})}else return null;return t(l,{resourceConfig:o})},C=r=>{const{resourceConfig:o}=r;return o?o?.delete!==!1&&o?.bottomToolbarDeleteButton?t(n,{}):o?.bottomToolbarDeleteButton&&o?.bottomToolbarDeleteButton.enabled!==!1?o.bottomToolbarDeleteButton?.props&&o.bottomToolbarDeleteButton.props?.confirm?t(a,{render:e=>t(u,{record:e})}):o.bottomToolbarDeleteButton?.component?t(o.bottomToolbarDeleteButton.component,{...o.bottomToolbarDeleteButton?.props||{}}):t(n,{...o.bottomToolbarDeleteButton?.props||{}}):null:t(n,{})};export{C as BottomToolbarDeleteButton,v as BottomToolbarSaveButton};
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { jsx } from "react/jsx-runtime";
21
+ import { DeleteButton } from "react-admin";
22
+ import DashAutoAdminSaveButton from "../../DashAutoAdminSaveButton";
23
+ import { DeleteWithConfirmButton } from "react-admin";
24
+ import { WithRecord } from "react-admin";
25
+ const BottomToolbarSaveButton = (props) => {
26
+ var _a, _b, _c;
27
+ const { resourceConfig } = props;
28
+ if (!resourceConfig) return /* @__PURE__ */ jsx(DashAutoAdminSaveButton, { resourceConfig });
29
+ if (resourceConfig.bottomToolbarSaveButton) {
30
+ if ((_a = resourceConfig.bottomToolbarSaveButton) == null ? void 0 : _a.enabled) {
31
+ const buttonProps = __spreadProps(__spreadValues({
32
+ resourceConfig
33
+ }, ((_b = resourceConfig.bottomToolbarSaveButton) == null ? void 0 : _b.props) || {}), {
34
+ alwaysEnable: (resourceConfig == null ? void 0 : resourceConfig.saveButtonAlwaysEnabled) === true ? true : false
35
+ });
36
+ return ((_c = resourceConfig.bottomToolbarSaveButton) == null ? void 0 : _c.component) ? /* @__PURE__ */ jsx(resourceConfig.bottomToolbarSaveButton.component, __spreadValues({}, buttonProps)) : /* @__PURE__ */ jsx(DashAutoAdminSaveButton, __spreadValues({}, buttonProps));
37
+ } else {
38
+ return null;
39
+ }
40
+ }
41
+ return /* @__PURE__ */ jsx(DashAutoAdminSaveButton, { resourceConfig });
42
+ };
43
+ const BottomToolbarDeleteButton = (props) => {
44
+ var _a, _b, _c, _d, _e;
45
+ const { resourceConfig } = props;
46
+ if (!resourceConfig) return /* @__PURE__ */ jsx(DeleteButton, {});
47
+ if (!!((resourceConfig == null ? void 0 : resourceConfig.delete) !== false) && !!(resourceConfig == null ? void 0 : resourceConfig.bottomToolbarDeleteButton)) {
48
+ return /* @__PURE__ */ jsx(DeleteButton, {});
49
+ } else if (!!(resourceConfig == null ? void 0 : resourceConfig.bottomToolbarDeleteButton) && !!((resourceConfig == null ? void 0 : resourceConfig.bottomToolbarDeleteButton.enabled) !== false)) {
50
+ if (!!((_a = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _a.props) && ((_b = resourceConfig.bottomToolbarDeleteButton.props) == null ? void 0 : _b.confirm)) {
51
+ return /* @__PURE__ */ jsx(
52
+ WithRecord,
53
+ {
54
+ render: (record) => /* @__PURE__ */ jsx(DeleteWithConfirmButton, { record })
55
+ }
56
+ );
57
+ }
58
+ return ((_c = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _c.component) ? /* @__PURE__ */ jsx(resourceConfig.bottomToolbarDeleteButton.component, __spreadValues({}, ((_d = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _d.props) || {})) : /* @__PURE__ */ jsx(DeleteButton, __spreadValues({}, ((_e = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _e.props) || {}));
59
+ }
60
+ return null;
61
+ };
62
+ export {
63
+ BottomToolbarDeleteButton,
64
+ BottomToolbarSaveButton
65
+ };
@@ -1 +1,181 @@
1
- import{jsx as i}from"react/jsx-runtime";import*as A from"react";import{memo as D}from"react";import n from"prop-types";import{DASHAppConstants as _}from"@dashadmin/dash-constants";import{useResourceContext as z,useRecordContext as M,useRedirect as P}from"react-admin";import O from"../../hooks/useVirtualHash";import{IconButton as W,Tooltip as y}from"@mui/material";import{Add as X,Edit as $,Visibility as F}from"@mui/icons-material";import{DeleteWithConfirmButton as H}from"react-admin";const L=_.system.URL_PREFIX,C={true:{_scrollToTop:!0},false:{}},ne=e=>e.includes("create")?"create":e.includes("edit")?"edit":"show",I=e=>{const o=P(),T=e.children?.type||W,d={...e,...e.children?.props};let{navigate:u,scrollToTop:g,mode:t,size:c,navigation:l,resourceConfig:a,record:B,resource:S,showIcon:w=!0,title:U,icon:b,...v}=d;const m=S||z(),h=B||M();c||(c="small"),l||(l=a?.drawer?t==="edit"&&a.drawerOptions?.edit===!1||t==="show"&&a.drawerOptions?.show===!1||t==="create"&&a.drawerOptions?.create===!1?"redirect":"virtualhash":"redirect"),u||(u=r=>`${L}${m}/${l==="virtualhash"?"inline":""}${t==="edit"?"/"+r.id+"/edit":t==="show"?"/"+r.id+"/show":t==="create"?"/create":""}`);const{setVirtualHash:k}=O(),f=r=>{if(r.preventDefault(),r.stopPropagation(),d.onClick){d.onClick(r);return}if(l==="virtualhash"){const s=u(h);k(s)}l==="redirect"&&(t==="create"?o(t,m):o(t,m,h.id))},x=c==="small"?{"& .MuiButton-startIcon":{margin:0},"& .MuiButton-text":{paddingLeft:"4px"},borderRadius:"50% !important",padding:0,minWidth:"30px",width:"30px",height:"30px",overflow:"hidden"}:{},E=c==="small"?"":e?.label;if(t==="destroy")return i(y,{title:e?.label,children:i(H,{label:E,sx:{...x},size:c,record:h})});if(t==="custom"){const{title:r,...s}=v;return i(y,{title:e?.label,children:i(T,{onClick:R=>f(R),state:C[String(g)],size:c,...s})})}else{if(!w&&e.children)return A.cloneElement(e.children,{onClick:p=>f(p),...e.children.props});const{title:r,...s}=v,R=i(T,{onClick:p=>f(p),state:C[String(g)],size:c,title:e.children?void 0:r,...s,children:w&&(b||(t==="edit"?i($,{}):t==="show"?i(F,{}):t==="create"?i(X,{}):t))});return i(y,{title:e?.label||"",children:R})}};I.propTypes={icon:n.element,label:n.string,record:n.any,scrollToTop:n.bool,navigate:n.func,navigation:n.string,children:n.element,showIcon:n.bool};var ce=D(I,(e,o)=>e.resource===o.resource&&(e.record&&o.record?e.record.id===o.record.id:e.record==o.record)&&e.label===o.label&&e.showIcon===o.showIcon&&e.icon===o.icon);export{ce as default};
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ import { jsx } from "react/jsx-runtime";
33
+ import * as React from "react";
34
+ import { memo } from "react";
35
+ import PropTypes from "prop-types";
36
+ import { DASHAppConstants } from "dash-constants";
37
+ import {
38
+ useResourceContext,
39
+ useRecordContext,
40
+ useRedirect
41
+ } from "react-admin";
42
+ import useVirtualHash from "../../hooks/useVirtualHash";
43
+ import { IconButton, Tooltip } from "@mui/material";
44
+ import { Add, Edit, Visibility } from "@mui/icons-material";
45
+ import { DeleteWithConfirmButton } from "react-admin";
46
+ const URL_PREFIX = DASHAppConstants.system.URL_PREFIX;
47
+ const scrollStates = {
48
+ true: { _scrollToTop: true },
49
+ false: {}
50
+ };
51
+ const inferModeFromUrl = (url) => {
52
+ if (url.includes("create")) return "create";
53
+ if (url.includes("edit")) return "edit";
54
+ return "show";
55
+ };
56
+ const DashResourceButton = (props) => {
57
+ var _a, _b, _d, _e, _f;
58
+ const redirect = useRedirect();
59
+ const ComponentType = ((_a = props.children) == null ? void 0 : _a.type) || IconButton;
60
+ const componentProps = __spreadValues(__spreadValues({}, props), (_b = props.children) == null ? void 0 : _b.props);
61
+ let _c = componentProps, {
62
+ navigate,
63
+ scrollToTop,
64
+ mode,
65
+ size,
66
+ navigation,
67
+ resourceConfig,
68
+ record: _inputRecord,
69
+ resource: _inputResource,
70
+ showIcon = true,
71
+ title,
72
+ icon
73
+ } = _c, rest = __objRest(_c, [
74
+ "navigate",
75
+ "scrollToTop",
76
+ "mode",
77
+ "size",
78
+ "navigation",
79
+ "resourceConfig",
80
+ "record",
81
+ "resource",
82
+ "showIcon",
83
+ "title",
84
+ "icon"
85
+ ]);
86
+ const resource = _inputResource || useResourceContext();
87
+ const record = _inputRecord || useRecordContext();
88
+ if (!size) {
89
+ size = "small";
90
+ }
91
+ if (!navigation) {
92
+ navigation = (resourceConfig == null ? void 0 : resourceConfig.drawer) ? mode === "edit" && ((_d = resourceConfig.drawerOptions) == null ? void 0 : _d.edit) === false ? "redirect" : mode === "show" && ((_e = resourceConfig.drawerOptions) == null ? void 0 : _e.show) === false ? "redirect" : mode === "create" && ((_f = resourceConfig.drawerOptions) == null ? void 0 : _f.create) === false ? "redirect" : "virtualhash" : "redirect";
93
+ }
94
+ if (!navigate) {
95
+ navigate = (_record) => {
96
+ const url = `${URL_PREFIX}${resource}/${navigation === "virtualhash" ? "inline" : ""}${mode === "edit" ? "/" + _record.id + "/edit" : mode === "show" ? "/" + _record.id + "/show" : mode === "create" ? "/create" : ""}`;
97
+ return url;
98
+ };
99
+ }
100
+ const { setVirtualHash } = useVirtualHash();
101
+ const handleOnClick = (e) => {
102
+ e.preventDefault();
103
+ e.stopPropagation();
104
+ if (componentProps.onClick) {
105
+ componentProps.onClick(e);
106
+ return;
107
+ }
108
+ if (navigation === "virtualhash") {
109
+ const vhash = navigate(record);
110
+ setVirtualHash(vhash);
111
+ }
112
+ if (navigation === "redirect") {
113
+ if (mode === "create") {
114
+ redirect(mode, resource);
115
+ } else {
116
+ redirect(mode, resource, record.id);
117
+ }
118
+ }
119
+ };
120
+ const _styles = size === "small" ? {
121
+ "& .MuiButton-startIcon": { margin: 0 },
122
+ "& .MuiButton-text": { paddingLeft: "4px" },
123
+ borderRadius: "50% !important",
124
+ padding: 0,
125
+ minWidth: "30px",
126
+ width: "30px",
127
+ height: "30px",
128
+ overflow: "hidden"
129
+ } : {};
130
+ const _label = size === "small" ? "" : props == null ? void 0 : props.label;
131
+ if (mode === "destroy") {
132
+ return /* @__PURE__ */ jsx(Tooltip, { title: props == null ? void 0 : props.label, children: /* @__PURE__ */ jsx(DeleteWithConfirmButton, { label: _label, sx: __spreadValues({}, _styles), size, record }) });
133
+ } else if (mode === "custom") {
134
+ const _g = rest, { title: title2 } = _g, restWithoutTitle = __objRest(_g, ["title"]);
135
+ return /* @__PURE__ */ jsx(Tooltip, { title: props == null ? void 0 : props.label, children: /* @__PURE__ */ jsx(
136
+ ComponentType,
137
+ __spreadValues({
138
+ onClick: (e) => handleOnClick(e),
139
+ state: scrollStates[String(scrollToTop)],
140
+ size
141
+ }, restWithoutTitle)
142
+ ) });
143
+ } else {
144
+ if (!showIcon && props.children) {
145
+ return React.cloneElement(props.children, __spreadValues({
146
+ onClick: (e) => handleOnClick(e)
147
+ }, props.children.props));
148
+ }
149
+ const _h = rest, { title: title2 } = _h, restWithoutTitle = __objRest(_h, ["title"]);
150
+ const button = /* @__PURE__ */ jsx(
151
+ ComponentType,
152
+ __spreadProps(__spreadValues({
153
+ onClick: (e) => handleOnClick(e),
154
+ state: scrollStates[String(scrollToTop)],
155
+ size,
156
+ title: props.children ? void 0 : title2
157
+ }, restWithoutTitle), {
158
+ children: showIcon && (icon ? icon : mode === "edit" ? /* @__PURE__ */ jsx(Edit, {}) : mode === "show" ? /* @__PURE__ */ jsx(Visibility, {}) : mode === "create" ? /* @__PURE__ */ jsx(Add, {}) : mode)
159
+ })
160
+ );
161
+ return /* @__PURE__ */ jsx(Tooltip, { title: (props == null ? void 0 : props.label) || "", children: button });
162
+ }
163
+ };
164
+ DashResourceButton.propTypes = {
165
+ icon: PropTypes.element,
166
+ label: PropTypes.string,
167
+ record: PropTypes.any,
168
+ scrollToTop: PropTypes.bool,
169
+ navigate: PropTypes.func,
170
+ navigation: PropTypes.string,
171
+ children: PropTypes.element,
172
+ showIcon: PropTypes.bool
173
+ };
174
+ var DashResourceButton_default = memo(
175
+ DashResourceButton,
176
+ (props, nextProps) => props.resource === nextProps.resource && (props.record && nextProps.record ? props.record.id === nextProps.record.id : props.record == nextProps.record) && // eslint-disable-line eqeqeq
177
+ props.label === nextProps.label && props.showIcon === nextProps.showIcon && props.icon === nextProps.icon
178
+ );
179
+ export {
180
+ DashResourceButton_default as default
181
+ };
@@ -1 +1,80 @@
1
- import{Fragment as s,jsx as o}from"react/jsx-runtime";import{EditButton as l}from"react-admin";import{DeleteButton as u}from"react-admin";import{ShowButton as f}from"react-admin";import n from"./DashResourceButton";const z=i=>{const{resourceConfig:t}=i;let e=f;if(!t)return o(e,{});if(t.listViewButton){if(t.listViewButton.component&&(e=t.listViewButton.component),t.listViewButton.enabled===!1||t?.view===!1)return o(s,{});t.listViewButton?.size||(t.listViewButton.size="small")}const r={mode:"show",resourceConfig:t,...t.listViewButton?.props||{}};return o(n,{...r,resourceConfig:t,...t.listDeleteButton?.props||{}})},E=i=>{const{resourceConfig:t}=i;let e=l;if(!t)return o(e,{});if(t.listEditButton){if(t.listEditButton.component&&(e=t.listEditButton.component),t.listEditButton.enabled===!1||t?.edit===!1)return o(s,{});t.listViewButton&&!t.listViewButton?.size&&(t.listViewButton.size="small")}return o(n,{mode:"edit",resourceConfig:t,...t.listViewButton?.props||{}})},h=i=>{const{resourceConfig:t}=i;let e=u;if(!t)return o(e,{});if(t.listDeleteButton){if(t.listDeleteButton.component&&(e=t.listDeleteButton.component),t.listDeleteButton.enabled===!1||t?.delete===!1)return o(s,{});t.listViewButton?.size||(t.listViewButton.size="small")}return o(n,{mode:"destroy",resourceConfig:t,...t.listDeleteButton?.props||{}})};export{h as ListDeleteButton,E as ListEditButton,z as ListViewButton};
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { Fragment, jsx } from "react/jsx-runtime";
21
+ import { EditButton } from "react-admin";
22
+ import { DeleteButton } from "react-admin";
23
+ import { ShowButton } from "react-admin";
24
+ import DashResourceButton from "./DashResourceButton";
25
+ const ListViewButton = (props) => {
26
+ var _a, _b, _c;
27
+ const { resourceConfig } = props;
28
+ let Component = ShowButton;
29
+ if (!resourceConfig) return /* @__PURE__ */ jsx(Component, {});
30
+ if (resourceConfig.listViewButton) {
31
+ if (resourceConfig.listViewButton.component) Component = resourceConfig.listViewButton.component;
32
+ if (resourceConfig.listViewButton.enabled === false || (resourceConfig == null ? void 0 : resourceConfig.view) === false) return /* @__PURE__ */ jsx(Fragment, {});
33
+ if (!((_a = resourceConfig.listViewButton) == null ? void 0 : _a.size)) {
34
+ resourceConfig.listViewButton.size = "small";
35
+ }
36
+ ;
37
+ }
38
+ const btnProps = __spreadValues({
39
+ mode: "show",
40
+ resourceConfig
41
+ }, ((_b = resourceConfig.listViewButton) == null ? void 0 : _b.props) || {});
42
+ return /* @__PURE__ */ jsx(DashResourceButton, __spreadValues(__spreadProps(__spreadValues({}, btnProps), { resourceConfig }), ((_c = resourceConfig.listDeleteButton) == null ? void 0 : _c.props) || {}));
43
+ };
44
+ const ListEditButton = (props) => {
45
+ var _a, _b;
46
+ const { resourceConfig } = props;
47
+ let Component = EditButton;
48
+ if (!resourceConfig) {
49
+ return /* @__PURE__ */ jsx(Component, {});
50
+ }
51
+ if (resourceConfig.listEditButton) {
52
+ if (resourceConfig.listEditButton.component) Component = resourceConfig.listEditButton.component;
53
+ if (resourceConfig.listEditButton.enabled === false || (resourceConfig == null ? void 0 : resourceConfig.edit) === false) return /* @__PURE__ */ jsx(Fragment, {});
54
+ if (resourceConfig.listViewButton && !((_a = resourceConfig.listViewButton) == null ? void 0 : _a.size)) {
55
+ resourceConfig.listViewButton.size = "small";
56
+ }
57
+ ;
58
+ }
59
+ return /* @__PURE__ */ jsx(DashResourceButton, __spreadValues({ mode: "edit", resourceConfig }, ((_b = resourceConfig.listViewButton) == null ? void 0 : _b.props) || {}));
60
+ };
61
+ const ListDeleteButton = (props) => {
62
+ var _a, _b;
63
+ const { resourceConfig } = props;
64
+ let Component = DeleteButton;
65
+ if (!resourceConfig) return /* @__PURE__ */ jsx(Component, {});
66
+ if (resourceConfig.listDeleteButton) {
67
+ if (resourceConfig.listDeleteButton.component) Component = resourceConfig.listDeleteButton.component;
68
+ if (resourceConfig.listDeleteButton.enabled === false || (resourceConfig == null ? void 0 : resourceConfig.delete) === false) return /* @__PURE__ */ jsx(Fragment, {});
69
+ if (!((_a = resourceConfig.listViewButton) == null ? void 0 : _a.size)) {
70
+ resourceConfig.listViewButton.size = "small";
71
+ }
72
+ ;
73
+ }
74
+ return /* @__PURE__ */ jsx(DashResourceButton, __spreadValues({ mode: "destroy", resourceConfig }, ((_b = resourceConfig.listDeleteButton) == null ? void 0 : _b.props) || {}));
75
+ };
76
+ export {
77
+ ListDeleteButton,
78
+ ListEditButton,
79
+ ListViewButton
80
+ };