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.
- package/dist/MuffinResource.js +5 -1
- package/dist/MuffinResourceEdit.d.ts +2 -0
- package/dist/MuffinResourceEdit.js +21 -7
- package/dist/MuffinResourceShow.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/MuffinResource.tsx +9 -4
- package/src/MuffinResourceEdit.tsx +33 -20
- package/src/MuffinResourceShow.tsx +3 -3
- package/src/types.ts +1 -0
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type TID = string | number;
|
|
|
2
2
|
export type TProps = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
};
|
|
5
|
-
export type TAdminType = "action-form" | "admin" | "appbar" | "auth-provider" | "auth-storage-get" | "auth-storage-set" | "create" | "create-toolbar" | "create-inputs" | "dashboard" | "dashboard-actions" | "dashboard-content" | "data-provider" | "edit" | "edit-actions" | "edit-toolbar" | "edit-inputs" | "layout" | "list" | "list-actions" | "list-toolbar" | "list-grid" | "list-grid-buttons" | "list-filters" | "list-fields" | "locale" | "loginpage" | "resource" | "show" | "show-actions" | "show-toolbar" | "show-fields" | "show-links";
|
|
5
|
+
export type TAdminType = "action-form" | "admin" | "appbar" | "auth-provider" | "auth-storage-get" | "auth-storage-set" | "create" | "create-toolbar" | "create-inputs" | "dashboard" | "dashboard-actions" | "dashboard-content" | "data-provider" | "edit" | "edit-actions" | "edit-toolbar" | "edit-form-toolbar" | "edit-inputs" | "layout" | "list" | "list-actions" | "list-toolbar" | "list-grid" | "list-grid-buttons" | "list-filters" | "list-fields" | "locale" | "loginpage" | "resource" | "show" | "show-actions" | "show-toolbar" | "show-fields" | "show-links";
|
|
6
6
|
export type TAdminPath = [type: TAdminType, ...ids: string[]];
|
|
7
7
|
export type AdminAction = {
|
|
8
8
|
view?: ("show" | "edit" | "list" | "bulk")[];
|
package/package.json
CHANGED
package/src/MuffinResource.tsx
CHANGED
|
@@ -7,15 +7,20 @@ export function MuffinResource({ name, ...props }: ResourceProps) {
|
|
|
7
7
|
const opts = adminOpts?.resources.find((r) => r.name == name)
|
|
8
8
|
if (!opts) return null
|
|
9
9
|
|
|
10
|
+
const Create = findBuilder(["create", name])
|
|
11
|
+
const Edit = findBuilder(["edit", name])
|
|
12
|
+
const List = findBuilder(["list", name])
|
|
13
|
+
const Show = findBuilder(["show", name])
|
|
14
|
+
|
|
10
15
|
return (
|
|
11
16
|
<Resource
|
|
12
17
|
key={name}
|
|
13
18
|
name={name}
|
|
14
19
|
icon={findIcon(opts.icon)}
|
|
15
|
-
create={
|
|
16
|
-
edit={
|
|
17
|
-
list={
|
|
18
|
-
show={
|
|
20
|
+
create={Create}
|
|
21
|
+
edit={Edit}
|
|
22
|
+
list={List}
|
|
23
|
+
show={Show}
|
|
19
24
|
{...props}
|
|
20
25
|
/>
|
|
21
26
|
)
|
|
@@ -13,43 +13,56 @@ import {
|
|
|
13
13
|
import { buildRA } from "./buildRA"
|
|
14
14
|
import { ActionButton } from "./buttons"
|
|
15
15
|
import { useMuffinAdminOpts, useMuffinResourceOpts } from "./hooks"
|
|
16
|
-
import {
|
|
16
|
+
import { findBuilder, setupAdmin } from "./utils"
|
|
17
17
|
|
|
18
18
|
export function MuffinEdit({ children }: PropsWithChildren) {
|
|
19
19
|
const {
|
|
20
20
|
adminProps: { mutationMode = "optimistic" },
|
|
21
21
|
} = useMuffinAdminOpts()
|
|
22
|
+
|
|
22
23
|
const { edit, name } = useMuffinResourceOpts()
|
|
23
24
|
if (!edit) return null
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
-
const
|
|
26
|
+
const Actions = findBuilder(["edit-toolbar", name])
|
|
27
|
+
const Inputs = findBuilder(["edit-inputs", name])
|
|
28
|
+
const FormToolbar = findBuilder(["edit-form-toolbar", name])
|
|
27
29
|
|
|
28
30
|
return (
|
|
29
|
-
<Edit actions={<
|
|
31
|
+
<Edit actions={<Actions />} mutationMode={mutationMode}>
|
|
30
32
|
{children}
|
|
31
|
-
<SimpleForm
|
|
32
|
-
|
|
33
|
-
<Toolbar>
|
|
34
|
-
<SaveButton />
|
|
35
|
-
{remove && (
|
|
36
|
-
<DeleteButton
|
|
37
|
-
sx={{
|
|
38
|
-
marginLeft: "auto",
|
|
39
|
-
}}
|
|
40
|
-
/>
|
|
41
|
-
)}
|
|
42
|
-
</Toolbar>
|
|
43
|
-
}
|
|
44
|
-
>
|
|
45
|
-
{buildAdmin(["edit-inputs", name], inputs)}
|
|
33
|
+
<SimpleForm toolbar={<FormToolbar />}>
|
|
34
|
+
<Inputs />
|
|
46
35
|
</SimpleForm>
|
|
47
36
|
</Edit>
|
|
48
37
|
)
|
|
49
38
|
}
|
|
50
39
|
|
|
51
40
|
setupAdmin(["edit"], MuffinEdit)
|
|
52
|
-
|
|
41
|
+
|
|
42
|
+
export function MuffinEditFormToolbar() {
|
|
43
|
+
const { edit } = useMuffinResourceOpts()
|
|
44
|
+
if (!edit) return null
|
|
45
|
+
|
|
46
|
+
const { remove } = edit
|
|
47
|
+
return (
|
|
48
|
+
<Toolbar>
|
|
49
|
+
<SaveButton />
|
|
50
|
+
{remove && <DeleteButton sx={{ marginLeft: "auto" }} />}
|
|
51
|
+
</Toolbar>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setupAdmin(["edit-form-toolbar"], MuffinEditFormToolbar)
|
|
56
|
+
|
|
57
|
+
export function MuffinEditInputs() {
|
|
58
|
+
const { edit } = useMuffinResourceOpts()
|
|
59
|
+
if (!edit) return null
|
|
60
|
+
|
|
61
|
+
const { inputs } = edit
|
|
62
|
+
|
|
63
|
+
return <>{buildRA(inputs)}</>
|
|
64
|
+
}
|
|
65
|
+
setupAdmin(["edit-inputs"], MuffinEditInputs)
|
|
53
66
|
|
|
54
67
|
export function MuffinEditToolbar({ children }: PropsWithChildren) {
|
|
55
68
|
const resource = useResourceContext()
|
|
@@ -8,17 +8,17 @@ import { buildAdmin, findBuilder, setupAdmin } from "./utils"
|
|
|
8
8
|
|
|
9
9
|
export function MuffinShow({ children }: PropsWithChildren) {
|
|
10
10
|
const { show, name } = useMuffinResourceOpts()
|
|
11
|
-
const
|
|
11
|
+
const ShowToolbar = findBuilder(["show-toolbar", name])
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<Show actions={<
|
|
14
|
+
<Show actions={<ShowToolbar />}>
|
|
15
15
|
{children}
|
|
16
16
|
<SimpleShowLayout>{buildAdmin(["show-fields", name], show)}</SimpleShowLayout>
|
|
17
17
|
</Show>
|
|
18
18
|
)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
setupAdmin(["show"],
|
|
21
|
+
setupAdmin(["show"], MuffinShow)
|
|
22
22
|
setupAdmin(["show-fields"], ({ fields }) => buildRA(fields))
|
|
23
23
|
|
|
24
24
|
export function MuffinShowToolbar({ children }: PropsWithChildren) {
|