muffin-admin 5.0.0 → 6.0.1
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 +8 -5
- package/dist/dataprovider.d.ts +24 -0
- package/dist/dataprovider.js +10 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/MuffinResourceList.tsx +19 -4
- package/src/dataprovider.ts +11 -1
- package/src/types.ts +1 -0
package/dist/types.d.ts
CHANGED
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
|
|
|
@@ -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-actions"],
|
|
127
|
+
setupAdmin(["list-actions"], MuffinListActions)
|
|
128
|
+
|
|
129
|
+
function MuffinPagination() {
|
|
130
|
+
return null
|
|
131
|
+
}
|
package/src/dataprovider.ts
CHANGED
|
@@ -24,7 +24,17 @@ 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
|
-
|
|
27
|
+
if (pagination)
|
|
28
|
+
return {
|
|
29
|
+
data,
|
|
30
|
+
total: parseInt(headers.get("x-total"), 10),
|
|
31
|
+
pageInfo: {
|
|
32
|
+
hasPreviousPage: pagination.page > 1,
|
|
33
|
+
hasNextPage: data.length === pagination.perPage,
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { data }
|
|
28
38
|
},
|
|
29
39
|
|
|
30
40
|
getOne: async (resource: string, { id }: { id: TID }) => {
|