muffin-admin 6.1.3 → 6.2.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.
@@ -19,6 +19,10 @@ export function MuffinResource(_a) {
19
19
  const opts = adminOpts === null || adminOpts === void 0 ? void 0 : adminOpts.resources.find((r) => r.name == name);
20
20
  if (!opts)
21
21
  return null;
22
- return (_jsx(Resource, Object.assign({ name: name, icon: findIcon(opts.icon), create: findBuilder(["create", name]), edit: findBuilder(["edit", name]), list: findBuilder(["list", name]), show: findBuilder(["show", name]) }, props), name));
22
+ const Create = findBuilder(["create", name]);
23
+ const Edit = findBuilder(["edit", name]);
24
+ const List = findBuilder(["list", name]);
25
+ const Show = findBuilder(["show", name]);
26
+ return (_jsx(Resource, Object.assign({ name: name, icon: findIcon(opts.icon), create: Create, edit: Edit, list: List, show: Show }, props), name));
23
27
  }
24
28
  setupAdmin(["resource"], MuffinResource);
@@ -1,4 +1,6 @@
1
1
  import { PropsWithChildren } from "react";
2
2
  export declare function MuffinEdit({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
3
+ export declare function MuffinEditFormToolbar(): import("react/jsx-runtime").JSX.Element;
4
+ export declare function MuffinEditInputs(): import("react/jsx-runtime").JSX.Element;
3
5
  export declare function MuffinEditToolbar({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
4
6
  export declare function MuffinEditActions({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
@@ -3,20 +3,34 @@ import { DeleteButton, Edit, ListButton, SaveButton, ShowButton, SimpleForm, Too
3
3
  import { buildRA } from "./buildRA";
4
4
  import { ActionButton } from "./buttons";
5
5
  import { useMuffinAdminOpts, useMuffinResourceOpts } from "./hooks";
6
- import { buildAdmin, findBuilder, setupAdmin } from "./utils";
6
+ import { findBuilder, setupAdmin } from "./utils";
7
7
  export function MuffinEdit({ children }) {
8
8
  const { adminProps: { mutationMode = "optimistic" }, } = useMuffinAdminOpts();
9
9
  const { edit, name } = useMuffinResourceOpts();
10
10
  if (!edit)
11
11
  return null;
12
- const { inputs, remove } = edit;
13
- const ActionsToolbar = findBuilder(["edit-toolbar", name]);
14
- return (_jsxs(Edit, { actions: _jsx(ActionsToolbar, {}), mutationMode: mutationMode, children: [children, _jsx(SimpleForm, { toolbar: _jsxs(Toolbar, { children: [_jsx(SaveButton, {}), remove && (_jsx(DeleteButton, { sx: {
15
- marginLeft: "auto",
16
- } }))] }), children: buildAdmin(["edit-inputs", name], inputs) })] }));
12
+ const Actions = findBuilder(["edit-toolbar", name]);
13
+ const Inputs = findBuilder(["edit-inputs", name]);
14
+ const FormToolbar = findBuilder(["edit-form-toolbar", name]);
15
+ return (_jsxs(Edit, { actions: _jsx(Actions, {}), mutationMode: mutationMode, children: [children, _jsx(SimpleForm, { toolbar: _jsx(FormToolbar, {}), children: _jsx(Inputs, {}) })] }));
17
16
  }
18
17
  setupAdmin(["edit"], MuffinEdit);
19
- setupAdmin(["edit-inputs"], buildRA);
18
+ export function MuffinEditFormToolbar() {
19
+ const { edit } = useMuffinResourceOpts();
20
+ if (!edit)
21
+ return null;
22
+ const { remove } = edit;
23
+ return (_jsxs(Toolbar, { children: [_jsx(SaveButton, {}), remove && _jsx(DeleteButton, { sx: { marginLeft: "auto" } })] }));
24
+ }
25
+ setupAdmin(["edit-form-toolbar"], MuffinEditFormToolbar);
26
+ export function MuffinEditInputs() {
27
+ const { edit } = useMuffinResourceOpts();
28
+ if (!edit)
29
+ return null;
30
+ const { inputs } = edit;
31
+ return _jsx(_Fragment, { children: buildRA(inputs) });
32
+ }
33
+ setupAdmin(["edit-inputs"], MuffinEditInputs);
20
34
  export function MuffinEditToolbar({ children }) {
21
35
  const resource = useResourceContext();
22
36
  const Actions = findBuilder(["edit-actions", resource]);
@@ -7,10 +7,10 @@ import { useMuffinResourceOpts } from "./hooks";
7
7
  import { buildAdmin, findBuilder, setupAdmin } from "./utils";
8
8
  export function MuffinShow({ children }) {
9
9
  const { show, name } = useMuffinResourceOpts();
10
- const ActionsToolbar = findBuilder(["show-toolbar", name]);
11
- return (_jsxs(Show, { actions: _jsx(ActionsToolbar, {}), children: [children, _jsx(SimpleShowLayout, { children: buildAdmin(["show-fields", name], show) })] }));
10
+ const ShowToolbar = findBuilder(["show-toolbar", name]);
11
+ return (_jsxs(Show, { actions: _jsx(ShowToolbar, {}), children: [children, _jsx(SimpleShowLayout, { children: buildAdmin(["show-fields", name], show) })] }));
12
12
  }
13
- setupAdmin(["show"], (props) => _jsx(MuffinShow, Object.assign({}, props)));
13
+ setupAdmin(["show"], MuffinShow);
14
14
  setupAdmin(["show-fields"], ({ fields }) => buildRA(fields));
15
15
  export function MuffinShowToolbar({ children }) {
16
16
  const { show, name } = useMuffinResourceOpts();