muffin-admin 8.1.2 → 8.3.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.
@@ -0,0 +1,8 @@
1
+ import { SortPayload } from "react-admin";
2
+ type TProps = {
3
+ resource: string;
4
+ filter: (record: any) => Record<string, any>;
5
+ sort?: SortPayload;
6
+ };
7
+ export declare function MuffinRecordList({ resource, filter, sort }: TProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Box from "@mui/material/Box";
3
+ import Typography from "@mui/material/Typography";
4
+ import { Datagrid, useGetList, useRecordContext, useTranslate } from "react-admin";
5
+ import { useMuffinResourceOpts } from "./hooks";
6
+ import { buildAdmin } from "./utils";
7
+ export function MuffinRecordList({ resource, filter, sort }) {
8
+ const record = useRecordContext();
9
+ const translate = useTranslate();
10
+ const { list: { fields }, } = useMuffinResourceOpts(resource);
11
+ const { data, isPending } = useGetList(resource, { sort, filter: filter(record) });
12
+ return (_jsxs(Box, { p: 2, children: [_jsx(Typography, { variant: "h6", children: translate(`resources.${resource}.name`, { smart_count: 2 }) }), _jsx(Datagrid, { resource: resource, bulkActionButtons: false, isPending: isPending, data: data, children: buildAdmin(["list-fields", resource], fields) })] }));
13
+ }
@@ -8,7 +8,7 @@ import { buildAdmin, findBuilder, setupAdmin } from "./utils";
8
8
  export function MuffinShow({ children }) {
9
9
  const { show, name } = useMuffinResourceOpts();
10
10
  const ShowToolbar = findBuilder(["show-toolbar", name]);
11
- return (_jsxs(Show, { actions: _jsx(ShowToolbar, {}), children: [children, _jsx(SimpleShowLayout, { children: buildAdmin(["show-fields", name], show) })] }));
11
+ return (_jsxs(Show, { actions: _jsx(ShowToolbar, {}), children: [_jsx(SimpleShowLayout, { children: buildAdmin(["show-fields", name], show) }), children] }));
12
12
  }
13
13
  setupAdmin(["show"], MuffinShow);
14
14
  setupAdmin(["show-fields"], ({ fields }) => buildRA(fields));
@@ -1 +1 @@
1
- export declare function useMuffinResourceOpts(): import("..").AdminResourceProps;
1
+ export declare function useMuffinResourceOpts(resource?: any): import("..").AdminResourceProps;
@@ -1,7 +1,7 @@
1
1
  import { useResourceContext } from "react-admin";
2
2
  import { useMuffinAdminOpts } from "./useMuffinAdminOpts";
3
- export function useMuffinResourceOpts() {
4
- const resource = useResourceContext();
3
+ export function useMuffinResourceOpts(resource) {
4
+ resource = useResourceContext({ resource });
5
5
  const { resources } = useMuffinAdminOpts();
6
6
  return resources.find((r) => r.name === resource);
7
7
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./utils";
2
2
  export * from "./MuffinAdmin";
3
3
  export * from "./MuffinDashboard";
4
+ export * from "./MuffinRecordList";
4
5
  export * from "./MuffinResource";
5
6
  export * from "./MuffinResourceCreate";
6
7
  export * from "./MuffinResourceEdit";
@@ -17,4 +18,4 @@ export * from "./fields";
17
18
  export * from "./hooks";
18
19
  export * from "./types";
19
20
  export declare function initAdmin(prefix?: string, containerId?: string): Promise<void>;
20
- export declare const VERSION = "8.1.2";
21
+ export declare const VERSION = "8.3.0";
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import { MuffinAdminContext } from "./context";
14
14
  export * from "./utils";
15
15
  export * from "./MuffinAdmin";
16
16
  export * from "./MuffinDashboard";
17
+ export * from "./MuffinRecordList";
17
18
  export * from "./MuffinResource";
18
19
  export * from "./MuffinResourceCreate";
19
20
  export * from "./MuffinResourceEdit";
@@ -40,4 +41,4 @@ export function initAdmin() {
40
41
  root.render(_jsx(MuffinAdminContext.Provider, { value: adminOpts, children: _jsx(MuffinAdmin, {}) }));
41
42
  });
42
43
  }
43
- export const VERSION = "8.1.2";
44
+ export const VERSION = "8.3.0";