muffin-admin 3.20.0 → 5.0.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/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-payload" | "admin" | "appbar" | "auth-provider" | "auth-storage-get" | "auth-storage-set" | "create" | "create-inputs" | "create-toolbar" | "dashboard" | "dashboard-actions" | "dashboard-content" | "data-provider" | "edit" | "edit-actions" | "edit-inputs" | "edit-toolbar" | "layout" | "list" | "list-toolbar" | "list-grid" | "list-grid-buttons" | "list-filters" | "list-fields" | "list-bulk-actions" | "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-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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "3.20.0",
3
+ "version": "5.0.0",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -50,7 +50,7 @@ setupAdmin(["list-filters"], buildRA)
50
50
  function MuffinListDatagrid() {
51
51
  const { name, list } = useMuffinResourceOpts()
52
52
  const { fields, edit, show } = list
53
- const BulkActions = findBuilder(["list-bulk-actions", name])
53
+ const BulkActions = findBuilder(["list-actions", name])
54
54
  return (
55
55
  <DatagridConfigurable
56
56
  rowClick={show ? "show" : edit ? "edit" : false}
@@ -113,4 +113,4 @@ function MuffinListBulkActions() {
113
113
  )
114
114
  }
115
115
 
116
- setupAdmin(["list-bulk-actions"], MuffinListBulkActions)
116
+ setupAdmin(["list-actions"], MuffinListBulkActions)
@@ -100,31 +100,32 @@ function ActionButtonBase({
100
100
  const resource = useResourceContext()
101
101
  const [payloadActive, setPayloadActive] = useState(false)
102
102
 
103
- const PayloadBuilder = findBuilder(["action-payload", id, resource]) || (schema && CommonPayload)
103
+ const PayloadForm = findBuilder(["action-form", id, resource]) || (schema && CommonPayload)
104
+ if (!PayloadForm)
105
+ return (
106
+ <Button label={label} title={title} onClick={onHandle} disabled={isPending}>
107
+ {buildIcon(icon)}
108
+ </Button>
109
+ )
104
110
 
105
111
  return (
106
112
  <>
107
113
  <Button
108
114
  label={label}
109
115
  title={title}
110
- onClick={() => {
111
- if (PayloadBuilder) setPayloadActive(true)
112
- else onHandle()
113
- }}
116
+ onClick={() => setPayloadActive(true)}
114
117
  disabled={isPending}
115
118
  >
116
119
  {buildIcon(icon)}
117
120
  </Button>
118
- {PayloadBuilder && (
119
- <PayloadBuilder
120
- active={payloadActive}
121
- onHandle={onHandle}
122
- onClose={() => setPayloadActive(false)}
123
- title={title || label}
124
- schema={schema}
125
- help={help}
126
- />
127
- )}
121
+ <PayloadForm
122
+ active={payloadActive}
123
+ onHandle={onHandle}
124
+ onClose={() => setPayloadActive(false)}
125
+ title={title || label}
126
+ schema={schema}
127
+ help={help}
128
+ />
128
129
  </>
129
130
  )
130
131
  }
@@ -159,11 +160,11 @@ export function CommonPayload({
159
160
  title={
160
161
  help
161
162
  ? ((
162
- <Stack alignItems="flex-start">
163
- <span>{translate(title, { _: title })}</span>
164
- <HelpLink href={help} style={{ alignSelf: "flex-end" }} />
165
- </Stack>
166
- ) as any)
163
+ <Stack alignItems="flex-start">
164
+ <span>{translate(title, { _: title })}</span>
165
+ <HelpLink href={help} style={{ alignSelf: "flex-end" }} />
166
+ </Stack>
167
+ ) as any)
167
168
  : translate(title, { _: title })
168
169
  }
169
170
  actions={
package/src/types.ts CHANGED
@@ -5,31 +5,31 @@ export type TProps = {
5
5
  }
6
6
 
7
7
  export type TAdminType =
8
- | "action-payload"
8
+ | "action-form"
9
9
  | "admin"
10
10
  | "appbar"
11
11
  | "auth-provider"
12
12
  | "auth-storage-get"
13
13
  | "auth-storage-set"
14
14
  | "create"
15
- | "create-inputs"
16
15
  | "create-toolbar"
16
+ | "create-inputs"
17
17
  | "dashboard"
18
18
  | "dashboard-actions"
19
19
  | "dashboard-content"
20
20
  | "data-provider"
21
21
  | "edit"
22
22
  | "edit-actions"
23
- | "edit-inputs"
24
23
  | "edit-toolbar"
24
+ | "edit-inputs"
25
25
  | "layout"
26
26
  | "list"
27
+ | "list-actions"
27
28
  | "list-toolbar"
28
29
  | "list-grid"
29
30
  | "list-grid-buttons"
30
31
  | "list-filters"
31
32
  | "list-fields"
32
- | "list-bulk-actions"
33
33
  | "locale"
34
34
  | "loginpage"
35
35
  | "resource"
@@ -54,7 +54,7 @@ export type AdminAction = {
54
54
  }
55
55
 
56
56
  export type AdminField = [string, { source: string }]
57
- export type AdminInput = [string, { required: boolean; source: string; [key: string]: any }]
57
+ export type AdminInput = [string, { required: boolean; source: string;[key: string]: any }]
58
58
 
59
59
  export type AdminShowLink = {
60
60
  label: string
@@ -85,11 +85,11 @@ export type AdminResourceProps = {
85
85
  actions: AdminAction[]
86
86
  create: AdminInput[] | false
87
87
  edit:
88
- | {
89
- inputs: AdminInput[]
90
- remove?: boolean
91
- }
92
- | false
88
+ | {
89
+ inputs: AdminInput[]
90
+ remove?: boolean
91
+ }
92
+ | false
93
93
  list: {
94
94
  limit: number
95
95
  limitMax: number