muffin-admin 1.42.0 → 1.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/admin.js CHANGED
@@ -64,7 +64,10 @@ var darkTheme = (0, _material.createTheme)({
64
64
  appBar: appBar
65
65
  }, props));
66
66
  }
67
- }, adminProps), (0, _utils.processAdmin)("resources", resources));
67
+ }, adminProps), (0, _utils.processAdmin)("resources", {
68
+ resources: resources,
69
+ adminProps: adminProps
70
+ }));
68
71
  });
69
72
 
70
73
  // Initialize authentication and data providers
@@ -12,32 +12,41 @@ require("./views/list");
12
12
  require("./views/show");
13
13
  require("./views/edit");
14
14
  require("./views/create");
15
- var _excluded = ["create", "edit", "icon", "list", "name", "show"];
15
+ var _excluded = ["create", "edit", "icon", "list", "show"];
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
18
  // Initialize Resources Components
19
- (0, _utils.setupAdmin)("resources", function (resources) {
20
- return resources.map(function (res) {
21
- return (0, _utils.processAdmin)("resource", res, res.name);
19
+ (0, _utils.setupAdmin)("resources", function (_ref) {
20
+ var resources = _ref.resources,
21
+ adminProps = _ref.adminProps;
22
+ return resources.map(function (resource) {
23
+ return (0, _utils.processAdmin)("resource", {
24
+ resource: resource,
25
+ adminProps: adminProps
26
+ }, resource.name);
22
27
  });
23
28
  });
24
29
 
25
30
  // Initialize a resource's component
26
- (0, _utils.setupAdmin)("resource", (0, _utils.checkParams)(function (props, res) {
27
- var create = props.create,
28
- edit = props.edit,
29
- icon = props.icon,
30
- list = props.list,
31
- name = props.name,
32
- show = props.show,
33
- resProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
31
+ (0, _utils.setupAdmin)("resource", (0, _utils.checkParams)(function (props, name) {
32
+ var resource = props.resource,
33
+ adminProps = props.adminProps;
34
+ var create = resource.create,
35
+ edit = resource.edit,
36
+ icon = resource.icon,
37
+ list = resource.list,
38
+ show = resource.show,
39
+ resProps = (0, _objectWithoutProperties2["default"])(resource, _excluded);
34
40
  return /*#__PURE__*/_react["default"].createElement(_reactAdmin.Resource, (0, _extends2["default"])({
35
41
  key: name,
36
42
  name: name,
37
43
  icon: icons[icon],
38
- create: (0, _utils.processAdmin)("create", create, res),
39
- edit: (0, _utils.processAdmin)("edit", edit, res),
40
- list: (0, _utils.processAdmin)("list", list, res),
41
- show: (0, _utils.processAdmin)("show", show, res)
44
+ create: (0, _utils.processAdmin)("create", create, name),
45
+ edit: (0, _utils.processAdmin)("edit", {
46
+ edit: edit,
47
+ adminProps: adminProps
48
+ }, name),
49
+ list: (0, _utils.processAdmin)("list", list, name),
50
+ show: (0, _utils.processAdmin)("show", show, name)
42
51
  }, resProps));
43
52
  }));
@@ -13,14 +13,16 @@ var _excluded = ["basePath", "resource"];
13
13
  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; }
14
14
  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) { (0, _defineProperty2["default"])(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; }
15
15
  // Initialize an edit component
16
- (0, _utils.setupAdmin)("edit", (0, _utils.checkParams)(function (_ref, res) {
17
- var actions = _ref.actions,
18
- inputs = _ref.inputs;
19
- return function MAEdit(props) {
20
- var Actions = function Actions(_ref2) {
21
- var basePath = _ref2.basePath,
22
- resource = _ref2.resource,
23
- baseProps = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
16
+ (0, _utils.setupAdmin)("edit", (0, _utils.checkParams)(function (props, name) {
17
+ var edit = props.edit,
18
+ adminProps = props.adminProps;
19
+ var actions = edit.actions,
20
+ inputs = edit.inputs;
21
+ function MAEdit(props) {
22
+ var Actions = function Actions(_ref) {
23
+ var basePath = _ref.basePath,
24
+ resource = _ref.resource,
25
+ baseProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
24
26
  return /*#__PURE__*/_react["default"].createElement(_reactAdmin.TopToolbar, null, actions.map(function (props, idx) {
25
27
  var aProps = _objectSpread(_objectSpread({
26
28
  resource: resource,
@@ -33,8 +35,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
33
35
  };
34
36
  return /*#__PURE__*/_react["default"].createElement(_reactAdmin.Edit, (0, _extends2["default"])({
35
37
  actions: /*#__PURE__*/_react["default"].createElement(Actions, null),
36
- mutationMode: "optimistic"
37
- }, props), /*#__PURE__*/_react["default"].createElement(_reactAdmin.SimpleForm, null, (0, _utils.processAdmin)("edit-inputs", inputs, res)));
38
- };
38
+ mutationMode: adminProps.mutationMode || "optimistic"
39
+ }, props), /*#__PURE__*/_react["default"].createElement(_reactAdmin.SimpleForm, null, (0, _utils.processAdmin)("edit-inputs", inputs, name)));
40
+ }
41
+ return MAEdit;
39
42
  }));
40
43
  (0, _utils.setupAdmin)("edit-inputs", _ui["default"]);
package/dist/esm/admin.js CHANGED
@@ -58,7 +58,10 @@ setupAdmin("admin", function (props) {
58
58
  appBar: appBar
59
59
  }, props));
60
60
  }
61
- }, adminProps), processAdmin("resources", resources));
61
+ }, adminProps), processAdmin("resources", {
62
+ resources: resources,
63
+ adminProps: adminProps
64
+ }));
62
65
  });
63
66
 
64
67
  // Initialize authentication and data providers
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["create", "edit", "icon", "list", "name", "show"];
3
+ var _excluded = ["create", "edit", "icon", "list", "show"];
4
4
  import React from "react";
5
5
  import { Resource } from "react-admin";
6
6
  import * as icons from "@mui/icons-material";
@@ -11,28 +11,37 @@ import "./views/edit";
11
11
  import "./views/create";
12
12
 
13
13
  // Initialize Resources Components
14
- setupAdmin("resources", function (resources) {
15
- return resources.map(function (res) {
16
- return processAdmin("resource", res, res.name);
14
+ setupAdmin("resources", function (_ref) {
15
+ var resources = _ref.resources,
16
+ adminProps = _ref.adminProps;
17
+ return resources.map(function (resource) {
18
+ return processAdmin("resource", {
19
+ resource: resource,
20
+ adminProps: adminProps
21
+ }, resource.name);
17
22
  });
18
23
  });
19
24
 
20
25
  // Initialize a resource's component
21
- setupAdmin("resource", checkParams(function (props, res) {
22
- var create = props.create,
23
- edit = props.edit,
24
- icon = props.icon,
25
- list = props.list,
26
- name = props.name,
27
- show = props.show,
28
- resProps = _objectWithoutProperties(props, _excluded);
26
+ setupAdmin("resource", checkParams(function (props, name) {
27
+ var resource = props.resource,
28
+ adminProps = props.adminProps;
29
+ var create = resource.create,
30
+ edit = resource.edit,
31
+ icon = resource.icon,
32
+ list = resource.list,
33
+ show = resource.show,
34
+ resProps = _objectWithoutProperties(resource, _excluded);
29
35
  return /*#__PURE__*/React.createElement(Resource, _extends({
30
36
  key: name,
31
37
  name: name,
32
38
  icon: icons[icon],
33
- create: processAdmin("create", create, res),
34
- edit: processAdmin("edit", edit, res),
35
- list: processAdmin("list", list, res),
36
- show: processAdmin("show", show, res)
39
+ create: processAdmin("create", create, name),
40
+ edit: processAdmin("edit", {
41
+ edit: edit,
42
+ adminProps: adminProps
43
+ }, name),
44
+ list: processAdmin("list", list, name),
45
+ show: processAdmin("show", show, name)
37
46
  }, resProps));
38
47
  }));
@@ -11,14 +11,16 @@ import { checkParams, processAdmin, setupAdmin } from "../utils";
11
11
  import { ActionButton } from "../buttons/ActionButton";
12
12
 
13
13
  // Initialize an edit component
14
- setupAdmin("edit", checkParams(function (_ref, res) {
15
- var actions = _ref.actions,
16
- inputs = _ref.inputs;
17
- return function MAEdit(props) {
18
- var Actions = function Actions(_ref2) {
19
- var basePath = _ref2.basePath,
20
- resource = _ref2.resource,
21
- baseProps = _objectWithoutProperties(_ref2, _excluded);
14
+ setupAdmin("edit", checkParams(function (props, name) {
15
+ var edit = props.edit,
16
+ adminProps = props.adminProps;
17
+ var actions = edit.actions,
18
+ inputs = edit.inputs;
19
+ function MAEdit(props) {
20
+ var Actions = function Actions(_ref) {
21
+ var basePath = _ref.basePath,
22
+ resource = _ref.resource,
23
+ baseProps = _objectWithoutProperties(_ref, _excluded);
22
24
  return /*#__PURE__*/React.createElement(TopToolbar, null, actions.map(function (props, idx) {
23
25
  var aProps = _objectSpread(_objectSpread({
24
26
  resource: resource,
@@ -31,8 +33,9 @@ setupAdmin("edit", checkParams(function (_ref, res) {
31
33
  };
32
34
  return /*#__PURE__*/React.createElement(Edit, _extends({
33
35
  actions: /*#__PURE__*/React.createElement(Actions, null),
34
- mutationMode: "optimistic"
35
- }, props), /*#__PURE__*/React.createElement(SimpleForm, null, processAdmin("edit-inputs", inputs, res)));
36
- };
36
+ mutationMode: adminProps.mutationMode || "optimistic"
37
+ }, props), /*#__PURE__*/React.createElement(SimpleForm, null, processAdmin("edit-inputs", inputs, name)));
38
+ }
39
+ return MAEdit;
37
40
  }));
38
41
  setupAdmin("edit-inputs", initRAItems);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "1.42.0",
3
+ "version": "1.43.0",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
package/src/admin.jsx CHANGED
@@ -65,7 +65,7 @@ setupAdmin("admin", (props) => {
65
65
  layout={(props) => <Layout appBar={appBar} {...props} />}
66
66
  {...adminProps}
67
67
  >
68
- {processAdmin("resources", resources)}
68
+ {processAdmin("resources", { resources, adminProps })}
69
69
  </Admin>
70
70
  )
71
71
  })
package/src/resources.jsx CHANGED
@@ -10,25 +10,28 @@ import "./views/edit"
10
10
  import "./views/create"
11
11
 
12
12
  // Initialize Resources Components
13
- setupAdmin("resources", (resources) =>
14
- resources.map((res) => processAdmin("resource", res, res.name))
13
+ setupAdmin("resources", ({ resources, adminProps }) =>
14
+ resources.map((resource) =>
15
+ processAdmin("resource", { resource, adminProps }, resource.name)
16
+ )
15
17
  )
16
18
 
17
19
  // Initialize a resource's component
18
20
  setupAdmin(
19
21
  "resource",
20
- checkParams((props, res) => {
21
- let { create, edit, icon, list, name, show, ...resProps } = props
22
+ checkParams((props, name) => {
23
+ let { resource, adminProps } = props
24
+ let { create, edit, icon, list, show, ...resProps } = resource
22
25
 
23
26
  return (
24
27
  <Resource
25
28
  key={name}
26
29
  name={name}
27
30
  icon={icons[icon]}
28
- create={processAdmin("create", create, res)}
29
- edit={processAdmin("edit", edit, res)}
30
- list={processAdmin("list", list, res)}
31
- show={processAdmin("show", show, res)}
31
+ create={processAdmin("create", create, name)}
32
+ edit={processAdmin("edit", { edit, adminProps }, name)}
33
+ list={processAdmin("list", list, name)}
34
+ show={processAdmin("show", show, name)}
32
35
  {...resProps}
33
36
  />
34
37
  )
@@ -15,27 +15,35 @@ import { ActionButton } from "../buttons/ActionButton"
15
15
  // Initialize an edit component
16
16
  setupAdmin(
17
17
  "edit",
18
- checkParams(
19
- ({ actions, inputs }, res) =>
20
- function MAEdit(props) {
21
- const Actions = ({ basePath, resource, ...baseProps }) => (
22
- <TopToolbar>
23
- {actions.map((props, idx) => {
24
- let aProps = { resource, basePath, ...baseProps, ...props }
25
- return <ActionButton key={idx} {...aProps} />
26
- })}
27
- <ListButton />
28
- <ShowButton />
29
- </TopToolbar>
30
- )
18
+ checkParams((props, name) => {
19
+ let { edit, adminProps } = props
20
+ let { actions, inputs } = edit
31
21
 
32
- return (
33
- <Edit actions={<Actions />} mutationMode="optimistic" {...props}>
34
- <SimpleForm>{processAdmin("edit-inputs", inputs, res)}</SimpleForm>
35
- </Edit>
36
- )
37
- }
38
- )
22
+ function MAEdit(props) {
23
+ const Actions = ({ basePath, resource, ...baseProps }) => (
24
+ <TopToolbar>
25
+ {actions.map((props, idx) => {
26
+ let aProps = { resource, basePath, ...baseProps, ...props }
27
+ return <ActionButton key={idx} {...aProps} />
28
+ })}
29
+ <ListButton />
30
+ <ShowButton />
31
+ </TopToolbar>
32
+ )
33
+
34
+ return (
35
+ <Edit
36
+ actions={<Actions />}
37
+ mutationMode={adminProps.mutationMode || "optimistic"}
38
+ {...props}
39
+ >
40
+ <SimpleForm>{processAdmin("edit-inputs", inputs, name)}</SimpleForm>
41
+ </Edit>
42
+ )
43
+ }
44
+
45
+ return MAEdit
46
+ })
39
47
  )
40
48
 
41
49
  setupAdmin("edit-inputs", initRAItems)