muffin-admin 1.44.4 → 1.45.1

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 (142) hide show
  1. package/dist/MuffinAdmin.d.ts +2 -0
  2. package/dist/MuffinAdmin.js +25 -0
  3. package/dist/MuffinDashboard.d.ts +2 -0
  4. package/dist/MuffinDashboard.js +16 -0
  5. package/dist/MuffinResource.d.ts +2 -0
  6. package/dist/MuffinResource.js +19 -0
  7. package/dist/MuffinResourceCreate.d.ts +4 -0
  8. package/dist/MuffinResourceCreate.js +11 -0
  9. package/dist/MuffinResourceEdit.d.ts +2 -0
  10. package/dist/MuffinResourceEdit.js +26 -0
  11. package/dist/MuffinResourceList.d.ts +2 -0
  12. package/dist/MuffinResourceList.js +16 -0
  13. package/dist/MuffinResourceShow.d.ts +2 -0
  14. package/dist/MuffinResourceShow.js +13 -0
  15. package/dist/actions/LinkAction.d.ts +4 -0
  16. package/dist/actions/LinkAction.js +10 -0
  17. package/dist/actions/index.d.ts +1 -0
  18. package/dist/actions/index.js +1 -0
  19. package/dist/authprovider.d.ts +9 -0
  20. package/dist/authprovider.js +80 -0
  21. package/dist/buildRA.d.ts +2 -0
  22. package/dist/buildRA.js +63 -0
  23. package/dist/buttons/ActionButton.d.ts +7 -0
  24. package/dist/buttons/ActionButton.js +51 -0
  25. package/dist/buttons/LinkButton.d.ts +6 -0
  26. package/dist/buttons/LinkButton.js +12 -0
  27. package/dist/buttons/index.d.ts +2 -0
  28. package/dist/buttons/index.js +2 -0
  29. package/dist/dataprovider.d.ts +59 -0
  30. package/dist/dataprovider.js +106 -0
  31. package/dist/fields/AvatarField.d.ts +13 -0
  32. package/dist/fields/AvatarField.js +33 -0
  33. package/dist/fields/EditableBooleanField.d.ts +3 -0
  34. package/dist/fields/EditableBooleanField.js +5 -0
  35. package/dist/fields/FKField.d.ts +14 -0
  36. package/dist/fields/FKField.js +21 -0
  37. package/dist/fields/JsonField.d.ts +4 -0
  38. package/dist/fields/JsonField.js +11 -0
  39. package/dist/fields/index.d.ts +4 -0
  40. package/dist/fields/index.js +4 -0
  41. package/dist/hooks/useAction.d.ts +5 -0
  42. package/dist/hooks/useAction.js +6 -0
  43. package/dist/index.d.ts +14 -0
  44. package/dist/index.js +35 -0
  45. package/dist/inputs/FKInput.d.ts +8 -0
  46. package/dist/inputs/FKInput.js +27 -0
  47. package/dist/inputs/JsonInput.d.ts +19 -0
  48. package/dist/inputs/JsonInput.js +69 -0
  49. package/dist/inputs/index.d.ts +2 -0
  50. package/dist/inputs/index.js +2 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -0
  52. package/dist/types.d.ts +76 -0
  53. package/dist/types.js +1 -0
  54. package/dist/utils.d.ts +28 -0
  55. package/dist/utils.js +57 -0
  56. package/dist/web.d.ts +1 -0
  57. package/dist/web.js +3 -0
  58. package/package.json +31 -14
  59. package/src/MuffinAdmin.tsx +73 -0
  60. package/src/MuffinDashboard.tsx +52 -0
  61. package/src/MuffinResource.tsx +27 -0
  62. package/src/MuffinResourceCreate.tsx +24 -0
  63. package/src/MuffinResourceEdit.tsx +42 -0
  64. package/src/MuffinResourceList.tsx +46 -0
  65. package/src/MuffinResourceShow.tsx +39 -0
  66. package/src/actions/LinkAction.tsx +10 -0
  67. package/src/actions/index.ts +1 -0
  68. package/src/{authprovider.js → authprovider.ts} +27 -22
  69. package/src/{ui.jsx → buildRA.tsx} +30 -35
  70. package/src/buttons/{ActionButton.jsx → ActionButton.tsx} +18 -30
  71. package/src/buttons/{LinkButton.jsx → LinkButton.tsx} +11 -6
  72. package/src/buttons/index.ts +2 -0
  73. package/src/{dataprovider.js → dataprovider.ts} +8 -6
  74. package/src/fields/{AvatarField.jsx → AvatarField.tsx} +3 -7
  75. package/src/fields/EditableBooleanField.tsx +5 -0
  76. package/src/fields/{FKField.jsx → FKField.tsx} +2 -10
  77. package/src/fields/{JsonField.jsx → JsonField.tsx} +2 -3
  78. package/src/fields/index.ts +4 -0
  79. package/src/hooks/{useAction.js → useAction.ts} +2 -2
  80. package/src/index.tsx +25 -0
  81. package/src/inputs/FKInput.tsx +27 -0
  82. package/src/inputs/{JsonInput.jsx → JsonInput.tsx} +3 -4
  83. package/src/inputs/index.ts +2 -0
  84. package/src/types.ts +73 -0
  85. package/src/utils.tsx +69 -0
  86. package/src/web.ts +4 -0
  87. package/dist/cjs/admin.js +0 -80
  88. package/dist/cjs/authprovider.js +0 -214
  89. package/dist/cjs/buttons/ActionButton.js +0 -96
  90. package/dist/cjs/buttons/LinkButton.js +0 -34
  91. package/dist/cjs/dashboard.js +0 -63
  92. package/dist/cjs/dataprovider.js +0 -304
  93. package/dist/cjs/fields/AvatarField.js +0 -37
  94. package/dist/cjs/fields/EditableBooleanField.js +0 -25
  95. package/dist/cjs/fields/FKField.js +0 -35
  96. package/dist/cjs/fields/JsonField.js +0 -38
  97. package/dist/cjs/hooks/useAction.js +0 -14
  98. package/dist/cjs/index.js +0 -76
  99. package/dist/cjs/inputs/FKInput.js +0 -41
  100. package/dist/cjs/inputs/JsonInput.js +0 -70
  101. package/dist/cjs/resources.js +0 -52
  102. package/dist/cjs/ui.js +0 -76
  103. package/dist/cjs/utils.js +0 -49
  104. package/dist/cjs/views/create.js +0 -18
  105. package/dist/cjs/views/edit.js +0 -31
  106. package/dist/cjs/views/list.js +0 -67
  107. package/dist/cjs/views/show.js +0 -37
  108. package/dist/cjs/web.js +0 -4
  109. package/dist/esm/admin.js +0 -74
  110. package/dist/esm/authprovider.js +0 -206
  111. package/dist/esm/buttons/ActionButton.js +0 -83
  112. package/dist/esm/buttons/LinkButton.js +0 -23
  113. package/dist/esm/dashboard.js +0 -60
  114. package/dist/esm/dataprovider.js +0 -296
  115. package/dist/esm/fields/AvatarField.js +0 -29
  116. package/dist/esm/fields/EditableBooleanField.js +0 -17
  117. package/dist/esm/fields/FKField.js +0 -27
  118. package/dist/esm/fields/JsonField.js +0 -28
  119. package/dist/esm/hooks/useAction.js +0 -8
  120. package/dist/esm/index.js +0 -42
  121. package/dist/esm/inputs/FKInput.js +0 -33
  122. package/dist/esm/inputs/JsonInput.js +0 -63
  123. package/dist/esm/resources.js +0 -47
  124. package/dist/esm/ui.js +0 -70
  125. package/dist/esm/utils.js +0 -38
  126. package/dist/esm/views/create.js +0 -16
  127. package/dist/esm/views/edit.js +0 -29
  128. package/dist/esm/views/list.js +0 -64
  129. package/dist/esm/views/show.js +0 -35
  130. package/dist/esm/web.js +0 -2
  131. package/src/admin.jsx +0 -78
  132. package/src/dashboard.jsx +0 -74
  133. package/src/fields/EditableBooleanField.jsx +0 -11
  134. package/src/index.js +0 -16
  135. package/src/inputs/FKInput.jsx +0 -42
  136. package/src/resources.jsx +0 -39
  137. package/src/utils.js +0 -38
  138. package/src/views/create.jsx +0 -30
  139. package/src/views/edit.jsx +0 -48
  140. package/src/views/list.jsx +0 -86
  141. package/src/views/show.jsx +0 -51
  142. package/src/web.js +0 -3
@@ -1,83 +0,0 @@
1
- import React from "react";
2
- import { Button, useRefresh, useUnselectAll, useNotify, useRecordContext } from "react-admin";
3
- import * as icons from "@mui/icons-material";
4
- import useAction from "../hooks/useAction";
5
- export var BulkActionButton = function BulkActionButton(_ref) {
6
- var label = _ref.label,
7
- icon = _ref.icon,
8
- title = _ref.title,
9
- action = _ref.action,
10
- resource = _ref.resource,
11
- selectedIds = _ref.selectedIds;
12
- var refresh = useRefresh(),
13
- unselectAll = useUnselectAll(resource),
14
- notify = useNotify(),
15
- Icon = icons[icon];
16
- var mutation = useAction(resource, action);
17
- var onClick = function onClick() {
18
- mutation.mutate({
19
- action: action,
20
- ids: selectedIds
21
- }, {
22
- onSuccess: function onSuccess(_ref2) {
23
- var data = _ref2.data;
24
- if (data && data.message) notify(data.message, {
25
- type: "success"
26
- });
27
- refresh();
28
- unselectAll();
29
- },
30
- onError: function onError(err) {
31
- notify(typeof err === "string" ? err : err.message, {
32
- type: "error"
33
- });
34
- }
35
- });
36
- };
37
- return /*#__PURE__*/React.createElement(Button, {
38
- label: label,
39
- title: title,
40
- onClick: onClick,
41
- disabled: mutation.isLoading
42
- }, Icon && /*#__PURE__*/React.createElement(Icon, null));
43
- };
44
- export var ActionButton = function ActionButton(props) {
45
- var icon = props.icon,
46
- label = props.label,
47
- title = props.title,
48
- resource = props.resource,
49
- action = props.action;
50
- var record = useRecordContext();
51
- var _useAction = useAction(resource, action),
52
- mutate = _useAction.mutate,
53
- isLoading = _useAction.isLoading;
54
- var refresh = useRefresh(),
55
- notify = useNotify(),
56
- Icon = icons[icon];
57
- var onClick = function onClick() {
58
- mutate({
59
- record: record
60
- }, {
61
- onSuccess: function onSuccess(_ref3) {
62
- var data = _ref3.data;
63
- refresh();
64
- if (data && data.redirectTo) window.location = data.redirectTo;
65
- if (data && data.message) notify(data.message, {
66
- type: "success"
67
- });
68
- },
69
- onError: function onError(error) {
70
- notify(typeof error === "string" ? error : error.message, {
71
- type: "error"
72
- });
73
- }
74
- });
75
- };
76
- return /*#__PURE__*/React.createElement(Button, {
77
- label: label,
78
- title: title,
79
- onClick: onClick,
80
- disabled: isLoading
81
- }, Icon && /*#__PURE__*/React.createElement(Icon, null));
82
- };
83
- export default ActionButton;
@@ -1,23 +0,0 @@
1
- import React from "react";
2
- import { Button } from "react-admin";
3
- import { Link } from "react-router-dom";
4
- import * as icons from "@mui/icons-material";
5
- var LinkButton = function LinkButton(_ref) {
6
- var label = _ref.label,
7
- icon = _ref.icon,
8
- title = _ref.title,
9
- resource = _ref.resource,
10
- filters = _ref.filters;
11
- var Icon = icons[icon] || icon;
12
- var linkParams = {
13
- pathname: "/".concat(resource),
14
- search: filters ? "filter=".concat(JSON.stringify(filters)) : undefined
15
- };
16
- return /*#__PURE__*/React.createElement(Button, {
17
- label: label,
18
- title: title,
19
- component: Link,
20
- to: linkParams
21
- }, Icon && /*#__PURE__*/React.createElement(Icon, null));
22
- };
23
- export default LinkButton;
@@ -1,60 +0,0 @@
1
- import React from "react";
2
- import { Grid, Card, CardContent, Typography, Table, TableBody, TableRow, TableCell } from "@mui/material";
3
- import { setupAdmin } from "./utils";
4
- var AdminTableView = function AdminTableView(_ref) {
5
- var src = _ref.src;
6
- return /*#__PURE__*/React.createElement(Table, null, /*#__PURE__*/React.createElement(TableBody, null, src.map(function (row, idx) {
7
- return /*#__PURE__*/React.createElement(TableRow, {
8
- key: idx,
9
- hover: true
10
- }, row.map(function (cell, idx) {
11
- return /*#__PURE__*/React.createElement(TableCell, {
12
- key: idx
13
- }, cell);
14
- }));
15
- })));
16
- };
17
- var AdminCard = function AdminCard(_ref2) {
18
- var src = _ref2.src;
19
- if (Array.isArray(src)) {
20
- return /*#__PURE__*/React.createElement(Grid, {
21
- container: true,
22
- item: true,
23
- spacing: 2
24
- }, src.map(function (card, idx) {
25
- return /*#__PURE__*/React.createElement(AdminCard, {
26
- key: idx,
27
- src: card
28
- });
29
- }));
30
- }
31
- var title = src.title,
32
- value = src.value;
33
- return /*#__PURE__*/React.createElement(Grid, {
34
- item: true,
35
- xs: true
36
- }, /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(Typography, {
37
- variant: "h5",
38
- component: "h2",
39
- m: 2,
40
- style: {
41
- textAlign: "center"
42
- }
43
- }, title), Array.isArray(value) && /*#__PURE__*/React.createElement(AdminTableView, {
44
- src: value
45
- }) || /*#__PURE__*/React.createElement("pre", null, JSON.stringify(value, null, 2)))));
46
- };
47
-
48
- // Process dashboard
49
- setupAdmin("dashboard", function (props) {
50
- if (!props) return;
51
- var Dashboard = function Dashboard() {
52
- return /*#__PURE__*/React.createElement(Grid, {
53
- container: true,
54
- spacing: 1
55
- }, /*#__PURE__*/React.createElement(AdminCard, {
56
- src: props
57
- }));
58
- };
59
- return Dashboard;
60
- });
@@ -1,296 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- var _excluded = ["target", "id", "filter"];
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
- import { makeRequest } from "./utils";
9
- export default (function (apiUrl) {
10
- var methods = {
11
- getList: function () {
12
- var _getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resource, _ref) {
13
- var filter, pagination, sort, query, page, limit, field, order, _yield$makeRequest, headers, json;
14
- return _regeneratorRuntime.wrap(function _callee$(_context) {
15
- while (1) switch (_context.prev = _context.next) {
16
- case 0:
17
- filter = _ref.filter, pagination = _ref.pagination, sort = _ref.sort;
18
- query = {};
19
- if (filter) query.where = JSON.stringify(filter);
20
- if (pagination) {
21
- page = pagination.page, limit = pagination.perPage;
22
- query.limit = limit;
23
- query.offset = limit * (page - 1);
24
- }
25
- if (sort) {
26
- field = sort.field, order = sort.order;
27
- query.sort = order == "ASC" ? field : "-".concat(field);
28
- }
29
- _context.next = 7;
30
- return makeRequest("".concat(apiUrl, "/").concat(resource), {
31
- query: query
32
- });
33
- case 7:
34
- _yield$makeRequest = _context.sent;
35
- headers = _yield$makeRequest.headers;
36
- json = _yield$makeRequest.json;
37
- return _context.abrupt("return", {
38
- data: json,
39
- total: parseInt(headers.get("x-total"), 10)
40
- });
41
- case 11:
42
- case "end":
43
- return _context.stop();
44
- }
45
- }, _callee);
46
- }));
47
- function getList(_x, _x2) {
48
- return _getList.apply(this, arguments);
49
- }
50
- return getList;
51
- }(),
52
- getOne: function () {
53
- var _getOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource, _ref2) {
54
- var id, _yield$makeRequest2, json;
55
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
56
- while (1) switch (_context2.prev = _context2.next) {
57
- case 0:
58
- id = _ref2.id;
59
- _context2.next = 3;
60
- return makeRequest("".concat(apiUrl, "/").concat(resource, "/").concat(id));
61
- case 3:
62
- _yield$makeRequest2 = _context2.sent;
63
- json = _yield$makeRequest2.json;
64
- return _context2.abrupt("return", {
65
- data: json
66
- });
67
- case 6:
68
- case "end":
69
- return _context2.stop();
70
- }
71
- }, _callee2);
72
- }));
73
- function getOne(_x3, _x4) {
74
- return _getOne.apply(this, arguments);
75
- }
76
- return getOne;
77
- }(),
78
- create: function () {
79
- var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resource, _ref3) {
80
- var data, _yield$makeRequest3, json;
81
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
82
- while (1) switch (_context3.prev = _context3.next) {
83
- case 0:
84
- data = _ref3.data;
85
- _context3.next = 3;
86
- return makeRequest("".concat(apiUrl, "/").concat(resource), {
87
- data: data,
88
- method: "POST"
89
- });
90
- case 3:
91
- _yield$makeRequest3 = _context3.sent;
92
- json = _yield$makeRequest3.json;
93
- return _context3.abrupt("return", {
94
- data: json
95
- });
96
- case 6:
97
- case "end":
98
- return _context3.stop();
99
- }
100
- }, _callee3);
101
- }));
102
- function create(_x5, _x6) {
103
- return _create.apply(this, arguments);
104
- }
105
- return create;
106
- }(),
107
- update: function () {
108
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(resource, _ref4) {
109
- var id, data, _yield$makeRequest4, json;
110
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
111
- while (1) switch (_context4.prev = _context4.next) {
112
- case 0:
113
- id = _ref4.id, data = _ref4.data;
114
- _context4.next = 3;
115
- return makeRequest("".concat(apiUrl, "/").concat(resource, "/").concat(id), {
116
- data: data,
117
- method: "PUT"
118
- });
119
- case 3:
120
- _yield$makeRequest4 = _context4.sent;
121
- json = _yield$makeRequest4.json;
122
- return _context4.abrupt("return", {
123
- data: json
124
- });
125
- case 6:
126
- case "end":
127
- return _context4.stop();
128
- }
129
- }, _callee4);
130
- }));
131
- function update(_x7, _x8) {
132
- return _update.apply(this, arguments);
133
- }
134
- return update;
135
- }(),
136
- updateMany: function () {
137
- var _updateMany = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(resource, _ref5) {
138
- var ids, data;
139
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
140
- while (1) switch (_context5.prev = _context5.next) {
141
- case 0:
142
- ids = _ref5.ids, data = _ref5.data;
143
- _context5.next = 3;
144
- return Promise.all(ids.map(function (id) {
145
- return methods.update(resource, {
146
- id: id,
147
- data: data
148
- });
149
- }));
150
- case 3:
151
- return _context5.abrupt("return", {
152
- data: ids
153
- });
154
- case 4:
155
- case "end":
156
- return _context5.stop();
157
- }
158
- }, _callee5);
159
- }));
160
- function updateMany(_x9, _x10) {
161
- return _updateMany.apply(this, arguments);
162
- }
163
- return updateMany;
164
- }(),
165
- "delete": function () {
166
- var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(resource, _ref6) {
167
- var id;
168
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
169
- while (1) switch (_context6.prev = _context6.next) {
170
- case 0:
171
- id = _ref6.id;
172
- _context6.next = 3;
173
- return makeRequest("".concat(apiUrl, "/").concat(resource, "/").concat(id), {
174
- method: "DELETE"
175
- });
176
- case 3:
177
- return _context6.abrupt("return", {
178
- data: {
179
- id: id
180
- }
181
- });
182
- case 4:
183
- case "end":
184
- return _context6.stop();
185
- }
186
- }, _callee6);
187
- }));
188
- function _delete(_x11, _x12) {
189
- return _delete2.apply(this, arguments);
190
- }
191
- return _delete;
192
- }(),
193
- deleteMany: function () {
194
- var _deleteMany = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(resource, _ref7) {
195
- var ids;
196
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
197
- while (1) switch (_context7.prev = _context7.next) {
198
- case 0:
199
- ids = _ref7.ids;
200
- _context7.next = 3;
201
- return makeRequest("".concat(apiUrl, "/").concat(resource), {
202
- data: ids,
203
- method: "DELETE"
204
- });
205
- case 3:
206
- return _context7.abrupt("return", {
207
- data: ids
208
- });
209
- case 4:
210
- case "end":
211
- return _context7.stop();
212
- }
213
- }, _callee7);
214
- }));
215
- function deleteMany(_x13, _x14) {
216
- return _deleteMany.apply(this, arguments);
217
- }
218
- return deleteMany;
219
- }(),
220
- getMany: function getMany(resource, _ref8) {
221
- var ids = _ref8.ids;
222
- return methods.getList(resource, {
223
- filter: {
224
- id: {
225
- $in: ids
226
- }
227
- }
228
- });
229
- },
230
- getManyReference: function () {
231
- var _getManyReference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(resource, _ref9) {
232
- var target, id, filter, opts;
233
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
234
- while (1) switch (_context8.prev = _context8.next) {
235
- case 0:
236
- target = _ref9.target, id = _ref9.id, filter = _ref9.filter, opts = _objectWithoutProperties(_ref9, _excluded);
237
- filter = filter || {};
238
- filter[target] = id;
239
- _context8.next = 5;
240
- return methods.getList(resource, _objectSpread({
241
- filter: filter
242
- }, opts));
243
- case 5:
244
- return _context8.abrupt("return", _context8.sent);
245
- case 6:
246
- case "end":
247
- return _context8.stop();
248
- }
249
- }, _callee8);
250
- }));
251
- function getManyReference(_x15, _x16) {
252
- return _getManyReference.apply(this, arguments);
253
- }
254
- return getManyReference;
255
- }(),
256
- runAction: function () {
257
- var _runAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(resource, action, props) {
258
- var payload, ids, record, _yield$makeRequest5, json;
259
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
260
- while (1) switch (_context9.prev = _context9.next) {
261
- case 0:
262
- payload = props.payload, ids = props.ids, record = props.record;
263
- action = action.replace(/^\/+/, "");
264
- if (record) {
265
- action = action.replace(/\{([^}]+)\}/, function (_, field) {
266
- return record[field];
267
- });
268
- }
269
- _context9.next = 5;
270
- return makeRequest("".concat(apiUrl, "/").concat(action), {
271
- query: {
272
- ids: ids
273
- },
274
- method: "POST",
275
- data: payload
276
- });
277
- case 5:
278
- _yield$makeRequest5 = _context9.sent;
279
- json = _yield$makeRequest5.json;
280
- return _context9.abrupt("return", {
281
- data: json
282
- });
283
- case 8:
284
- case "end":
285
- return _context9.stop();
286
- }
287
- }, _callee9);
288
- }));
289
- function runAction(_x17, _x18, _x19) {
290
- return _runAction.apply(this, arguments);
291
- }
292
- return runAction;
293
- }()
294
- };
295
- return methods;
296
- });
@@ -1,29 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- var _excluded = ["source", "alt", "style", "nameProp"];
3
- import React from "react";
4
- import get from "lodash/get";
5
- import { useRecordContext } from "ra-core";
6
- import Avatar from "@mui/material/Avatar";
7
- var AvatarField = function AvatarField(_ref) {
8
- var source = _ref.source,
9
- alt = _ref.alt,
10
- style = _ref.style,
11
- nameProp = _ref.nameProp,
12
- props = _objectWithoutProperties(_ref, _excluded);
13
- var record = useRecordContext(props);
14
- var value = get(record, source),
15
- name = record[nameProp];
16
- var letters = name ? name.trim(" ").split(/\s+/).slice(0, 2).map(function (n) {
17
- return n[0].toUpperCase();
18
- }).join("") : "";
19
- return /*#__PURE__*/React.createElement(Avatar, {
20
- src: value,
21
- alt: alt,
22
- style: style
23
- }, letters);
24
- };
25
- AvatarField.displayName = "AvatarField";
26
- AvatarField.defaultProps = {
27
- addLabel: true
28
- };
29
- export default AvatarField;
@@ -1,17 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- var _excluded = ["source", "alt", "style", "nameProp"];
3
- import React from "react";
4
- import { useRecordContext } from "ra-core";
5
- import { BooleanInput } from "ra-ui-materialui";
6
- var EditableBooleanField = function EditableBooleanField(_ref) {
7
- var source = _ref.source,
8
- alt = _ref.alt,
9
- style = _ref.style,
10
- nameProp = _ref.nameProp,
11
- props = _objectWithoutProperties(_ref, _excluded);
12
- var record = useRecordContext(props);
13
- return /*#__PURE__*/React.createElement(BooleanInput, {
14
- source: source
15
- });
16
- };
17
- export default EditableBooleanField;
@@ -1,27 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["refSource", "refID", "link", "reference", "source"];
4
- import React from "react";
5
- import { ReferenceField, TextField } from "react-admin";
6
- var FKField = function FKField(_ref) {
7
- var refSource = _ref.refSource,
8
- refID = _ref.refID,
9
- link = _ref.link,
10
- reference = _ref.reference,
11
- source = _ref.source,
12
- props = _objectWithoutProperties(_ref, _excluded);
13
- return /*#__PURE__*/React.createElement(ReferenceField, _extends({
14
- link: link || "show",
15
- reference: reference,
16
- source: source
17
- }, props), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, {
18
- source: refSource
19
- }), " (#", /*#__PURE__*/React.createElement(TextField, {
20
- source: refID || "id"
21
- }), ")"));
22
- };
23
- FKField.displayName = "FKField";
24
- FKField.defaultProps = {
25
- addLabel: true
26
- };
27
- export default FKField;
@@ -1,28 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import get from "lodash/get";
3
- import React, { useState } from "react";
4
- import { Button, FunctionField, useRecordContext } from "react-admin";
5
- export default function JsonField(_ref) {
6
- var label = _ref.label,
7
- source = _ref.source;
8
- var _useState = useState(false),
9
- _useState2 = _slicedToArray(_useState, 2),
10
- expand = _useState2[0],
11
- setExpand = _useState2[1];
12
- var record = useRecordContext();
13
- var src = JSON.stringify(get(record, source), null, 2);
14
- var retval = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null), label, /*#__PURE__*/React.createElement(Button, {
15
- variant: "contained",
16
- color: "primary",
17
- size: "small",
18
- label: expand ? "colapse" : "expand",
19
- onClick: function onClick() {
20
- return setExpand(!expand);
21
- }
22
- }), /*#__PURE__*/React.createElement("p", null, expand && /*#__PURE__*/React.createElement("pre", null, src)));
23
- return /*#__PURE__*/React.createElement(FunctionField, {
24
- render: function render() {
25
- return retval;
26
- }
27
- });
28
- }
@@ -1,8 +0,0 @@
1
- import { useDataProvider } from "react-admin";
2
- import { useMutation } from "react-query";
3
- export default function useAction(resource, action) {
4
- var dataProvider = useDataProvider();
5
- return useMutation(function (params) {
6
- return dataProvider.runAction(resource, action, params);
7
- });
8
- }
package/dist/esm/index.js DELETED
@@ -1,42 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { createRoot } from "react-dom/client";
4
- import "./admin";
5
- import { processAdmin } from "./utils";
6
- export * from "./utils";
7
- export { buildRAComponent } from "./ui";
8
- export { ActionButton } from "./buttons/ActionButton";
9
- export function initAdmin() {
10
- return _initAdmin.apply(this, arguments);
11
- }
12
- function _initAdmin() {
13
- _initAdmin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
14
- var prefix,
15
- response,
16
- props,
17
- container,
18
- root,
19
- _args = arguments;
20
- return _regeneratorRuntime.wrap(function _callee$(_context) {
21
- while (1) switch (_context.prev = _context.next) {
22
- case 0:
23
- prefix = _args.length > 0 && _args[0] !== undefined ? _args[0] : "";
24
- _context.next = 3;
25
- return fetch("".concat(prefix, "/ra.json"));
26
- case 3:
27
- response = _context.sent;
28
- _context.next = 6;
29
- return response.json();
30
- case 6:
31
- props = _context.sent;
32
- container = document.getElementById("root");
33
- root = createRoot(container);
34
- root.render(processAdmin("admin", props));
35
- case 10:
36
- case "end":
37
- return _context.stop();
38
- }
39
- }, _callee);
40
- }));
41
- return _initAdmin.apply(this, arguments);
42
- }
@@ -1,33 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["refProp", "refSource", "fullWidth", "reference", "source"];
4
- import React from "react";
5
- import { ReferenceInput, AutocompleteInput } from "react-admin";
6
- var FKInput = function FKInput(_ref) {
7
- var refProp = _ref.refProp,
8
- refSource = _ref.refSource,
9
- fullWidth = _ref.fullWidth,
10
- reference = _ref.reference,
11
- source = _ref.source,
12
- props = _objectWithoutProperties(_ref, _excluded);
13
- var filterToQuery = function filterToQuery(search) {
14
- var filters = {};
15
- filters[refProp] = search;
16
- return filters;
17
- };
18
- refSource = refSource || "id";
19
- var renderText = function renderText(record) {
20
- var pk = record[refSource];
21
- return pk && "".concat(record[refProp], " (#").concat(pk, ")") || "";
22
- };
23
- return /*#__PURE__*/React.createElement(ReferenceInput, _extends({
24
- reference: reference,
25
- source: source,
26
- filterToQuery: filterToQuery
27
- }, props), /*#__PURE__*/React.createElement(AutocompleteInput, _extends({
28
- source: refSource,
29
- optionText: renderText,
30
- fullWidth: fullWidth
31
- }, props)));
32
- };
33
- export default FKInput;