muffin-admin 9.5.1 → 9.5.3

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.
@@ -6,7 +6,7 @@ import ListItemButton from "@mui/material/ListItemButton";
6
6
  import ListItemIcon from "@mui/material/ListItemIcon";
7
7
  import ListItemText from "@mui/material/ListItemText";
8
8
  import { matchPath, useLocation } from "react-router-dom";
9
- import { Menu, useBasename, useTranslate } from "react-admin";
9
+ import { Menu, useBasename, useTheme, useTranslate } from "react-admin";
10
10
  import find from "lodash/find";
11
11
  import groupBy from "lodash/groupBy";
12
12
  import { useContext, useState } from "react";
@@ -35,5 +35,17 @@ function MenuGroup({ name, resources }) {
35
35
  const { pathname } = useLocation();
36
36
  const match = resources.some((resource) => !!matchPath({ path: `${basename}/${resource.name}/*` }, pathname));
37
37
  const [groupOpen, setGroupOpen] = useState(match);
38
- return (_jsxs("div", { children: [_jsxs(ListItemButton, { onClick: () => setGroupOpen(!groupOpen), sx: { color: match ? "rgba(0, 0, 0, 0.87)" : "rgba(0, 0, 0, 0.6)" }, children: [Icon && (_jsx(ListItemIcon, { sx: { minWidth: 40 }, children: _jsx(Icon, {}) })), _jsx(ListItemText, { primary: translate(`groups.${name}`) }), groupOpen ? _jsx(ExpandLess, {}) : _jsx(ExpandMore, {})] }), _jsx(Collapse, { in: groupOpen, timeout: "auto", unmountOnExit: true, children: resources.map(({ name }) => (_jsx(Menu.ResourceItem, { name: name }, name))) })] }));
38
+ const theme = useTheme()[0];
39
+ const colors = theme == "dark"
40
+ ? {
41
+ text: "rgba(255, 255, 255, 0.87)",
42
+ textSecondary: "rgba(255, 255, 255, 0.6)",
43
+ }
44
+ : {
45
+ text: "rgba(0, 0, 0, 0.87)",
46
+ textSecondary: "rgba(0, 0, 0, 0.6)",
47
+ };
48
+ return (_jsxs("div", { children: [_jsxs(ListItemButton, { onClick: () => setGroupOpen(!groupOpen), sx: {
49
+ color: match ? colors.text : colors.textSecondary,
50
+ }, children: [Icon && (_jsx(ListItemIcon, { sx: { minWidth: 40 }, children: _jsx(Icon, {}) })), _jsx(ListItemText, { primary: translate(`groups.${name}`) }), groupOpen ? _jsx(ExpandLess, {}) : _jsx(ExpandMore, {})] }), _jsx(Collapse, { in: groupOpen, timeout: "auto", unmountOnExit: true, children: resources.map(({ name }) => (_jsx(Menu.ResourceItem, { name: name }, name))) })] }));
39
51
  }
@@ -1,4 +1,4 @@
1
1
  import { AdminShowLink } from "../types";
2
- export declare function LinkAction({ field, icon, label, ...props }: AdminShowLink & {
2
+ export declare function LinkAction({ field, filter, icon, label, ...props }: AdminShowLink & {
3
3
  resource: string;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -14,12 +14,12 @@ import { useRecordContext, useResourceContext } from "react-admin";
14
14
  import LinkButton from "../buttons/LinkButton";
15
15
  import { useMuffinAdminOpts } from "../hooks";
16
16
  export function LinkAction(_a) {
17
- var { field, icon, label } = _a, props = __rest(_a, ["field", "icon", "label"]);
18
- const { resources } = useMuffinAdminOpts();
17
+ var { field, filter, icon, label } = _a, props = __rest(_a, ["field", "filter", "icon", "label"]);
19
18
  const record = useRecordContext();
19
+ const { resources } = useMuffinAdminOpts();
20
20
  const currentResource = useResourceContext();
21
21
  if (!record)
22
22
  return null;
23
23
  const resource = resources.find((r) => r.name === props.resource);
24
- return (_jsx(LinkButton, Object.assign({}, props, { icon: icon || (resource === null || resource === void 0 ? void 0 : resource.icon), label: label || `resources.${props.resource}.name`, filters: { [currentResource]: encodeURIComponent(record[field || "id"]) } })));
24
+ return (_jsx(LinkButton, Object.assign({}, props, { icon: icon || (resource === null || resource === void 0 ? void 0 : resource.icon), label: label || `resources.${props.resource}.name`, filters: { [filter || currentResource]: encodeURIComponent(record[field || "id"]) } })));
25
25
  }
package/dist/index.d.ts CHANGED
@@ -19,4 +19,4 @@ export * from "./fields";
19
19
  export * from "./hooks";
20
20
  export * from "./types";
21
21
  export declare function initAdmin(prefix?: string, containerId?: string): Promise<void>;
22
- export declare const VERSION = "9.5.1";
22
+ export declare const VERSION = "9.5.3";
package/dist/index.js CHANGED
@@ -42,4 +42,4 @@ export function initAdmin() {
42
42
  root.render(_jsx(MuffinAdminContext.Provider, { value: adminOpts, children: _jsx(MuffinAdmin, {}) }));
43
43
  });
44
44
  }
45
- export const VERSION = "9.5.1";
45
+ export const VERSION = "9.5.3";