muffin-admin 4.0.0 → 6.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/MuffinResourceList.js +9 -6
- package/dist/dataprovider.d.ts +12 -0
- package/dist/dataprovider.js +8 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/MuffinResourceList.tsx +20 -5
- package/src/dataprovider.ts +8 -1
- package/src/types.ts +10 -9
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-
|
|
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")[];
|
|
@@ -57,6 +57,7 @@ export type AdminResourceProps = {
|
|
|
57
57
|
list: {
|
|
58
58
|
limit: number;
|
|
59
59
|
limitMax: number;
|
|
60
|
+
limitTotal: boolean;
|
|
60
61
|
create: boolean;
|
|
61
62
|
filters: AdminInput[];
|
|
62
63
|
fields: AdminField[];
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
EditButton,
|
|
10
10
|
ExportButton,
|
|
11
11
|
FilterButton,
|
|
12
|
+
InfiniteList,
|
|
12
13
|
List,
|
|
13
14
|
Pagination,
|
|
14
15
|
SelectColumnsButton,
|
|
@@ -22,12 +23,12 @@ import { buildAdmin, findBuilder, setupAdmin } from "./utils"
|
|
|
22
23
|
|
|
23
24
|
export function MuffinList({ children }: PropsWithChildren) {
|
|
24
25
|
const { name, list } = useMuffinResourceOpts()
|
|
25
|
-
const { limit, limitMax, filters, sort } = list
|
|
26
|
+
const { limit, limitMax, limitTotal, filters, sort } = list
|
|
26
27
|
|
|
27
28
|
const DataGrid = findBuilder(["list-grid", name])
|
|
28
29
|
const Toolbar = findBuilder(["list-toolbar", name])
|
|
29
30
|
|
|
30
|
-
return (
|
|
31
|
+
return limitTotal ? (
|
|
31
32
|
<List
|
|
32
33
|
sort={sort}
|
|
33
34
|
perPage={limit}
|
|
@@ -40,6 +41,16 @@ export function MuffinList({ children }: PropsWithChildren) {
|
|
|
40
41
|
{children}
|
|
41
42
|
<DataGrid />
|
|
42
43
|
</List>
|
|
44
|
+
) : (
|
|
45
|
+
<InfiniteList
|
|
46
|
+
sort={sort}
|
|
47
|
+
perPage={limit}
|
|
48
|
+
actions={<Toolbar />}
|
|
49
|
+
filters={buildAdmin(["list-filters", name], filters)}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
<DataGrid />
|
|
53
|
+
</InfiniteList>
|
|
43
54
|
)
|
|
44
55
|
}
|
|
45
56
|
|
|
@@ -50,7 +61,7 @@ setupAdmin(["list-filters"], buildRA)
|
|
|
50
61
|
function MuffinListDatagrid() {
|
|
51
62
|
const { name, list } = useMuffinResourceOpts()
|
|
52
63
|
const { fields, edit, show } = list
|
|
53
|
-
const BulkActions = findBuilder(["list-
|
|
64
|
+
const BulkActions = findBuilder(["list-actions", name])
|
|
54
65
|
return (
|
|
55
66
|
<DatagridConfigurable
|
|
56
67
|
rowClick={show ? "show" : edit ? "edit" : false}
|
|
@@ -96,7 +107,7 @@ function MuffinListToolbar() {
|
|
|
96
107
|
}
|
|
97
108
|
setupAdmin(["list-toolbar"], MuffinListToolbar)
|
|
98
109
|
|
|
99
|
-
function
|
|
110
|
+
function MuffinListActions() {
|
|
100
111
|
const {
|
|
101
112
|
actions: baseActions = [],
|
|
102
113
|
list: { remove },
|
|
@@ -113,4 +124,8 @@ function MuffinListBulkActions() {
|
|
|
113
124
|
)
|
|
114
125
|
}
|
|
115
126
|
|
|
116
|
-
setupAdmin(["list-
|
|
127
|
+
setupAdmin(["list-actions"], MuffinListActions)
|
|
128
|
+
|
|
129
|
+
function MuffinPagination() {
|
|
130
|
+
return null
|
|
131
|
+
}
|
package/src/dataprovider.ts
CHANGED
|
@@ -24,7 +24,14 @@ export function MuffinDataprovider(apiUrl: string) {
|
|
|
24
24
|
query.sort = order == "ASC" ? field : `-${field}`
|
|
25
25
|
}
|
|
26
26
|
const { headers, data } = await request(resource, { query })
|
|
27
|
-
return {
|
|
27
|
+
return {
|
|
28
|
+
data,
|
|
29
|
+
total: parseInt(headers.get("x-total"), 10),
|
|
30
|
+
pageInfo: {
|
|
31
|
+
hasPreviousPage: pagination.page > 1,
|
|
32
|
+
hasNextPage: data.length === pagination.perPage,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
28
35
|
},
|
|
29
36
|
|
|
30
37
|
getOne: async (resource: string, { id }: { id: TID }) => {
|
package/src/types.ts
CHANGED
|
@@ -12,24 +12,24 @@ export type TAdminType =
|
|
|
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;
|
|
57
|
+
export type AdminInput = [string, { required: boolean; source: string;[key: string]: any }]
|
|
58
58
|
|
|
59
59
|
export type AdminShowLink = {
|
|
60
60
|
label: string
|
|
@@ -85,14 +85,15 @@ export type AdminResourceProps = {
|
|
|
85
85
|
actions: AdminAction[]
|
|
86
86
|
create: AdminInput[] | false
|
|
87
87
|
edit:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
| {
|
|
89
|
+
inputs: AdminInput[]
|
|
90
|
+
remove?: boolean
|
|
91
|
+
}
|
|
92
|
+
| false
|
|
93
93
|
list: {
|
|
94
94
|
limit: number
|
|
95
95
|
limitMax: number
|
|
96
|
+
limitTotal: boolean
|
|
96
97
|
create: boolean
|
|
97
98
|
filters: AdminInput[]
|
|
98
99
|
fields: AdminField[]
|