ding-react-admin 2.5.1 → 2.5.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AdminLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/AdminLayout.tsx"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,gBAAgB,EAA+B,MAAM,UAAU,CAAC;AAC9E,OAAO,2BAA2B,CAAC;AAuKnC,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,KAAe,EACf,cAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,SAAoB,EACpB,wBAA4C,EAC5C,SAAgB,EAChB,OAAO,EACP,SAAiB,GAClB,EAAE,gBAAgB,2CAmWlB"}
1
+ {"version":3,"file":"AdminLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/AdminLayout.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,gBAAgB,EAA+B,MAAM,UAAU,CAAC;AAC9E,OAAO,2BAA2B,CAAC;AAuKnC,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,KAAe,EACf,cAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,SAAoB,EACpB,wBAA4C,EAC5C,SAAgB,EAChB,OAAO,EACP,SAAiB,GAClB,EAAE,gBAAgB,2CAmWlB"}
@@ -13,5 +13,7 @@ export declare function flattenNavLeaves(items: NavItem[], options?: {
13
13
  group?: string;
14
14
  }): FlatNavItem[];
15
15
  export declare function filterFlatNavItems(items: FlatNavItem[], query: string): FlatNavItem[];
16
+ /** Menu key for a parent row so it never collides with a child that shares `path`. */
17
+ export declare function navSubmenuKey(path: string): string;
16
18
  export declare function collectSubmenuKeys(items: NavItem[]): string[];
17
19
  //# sourceMappingURL=navFilter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navFilter.d.ts","sourceRoot":"","sources":["../../../src/layouts/navFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,MAAM,CAKpE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CAyBzE;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B,WAAW,EAAE,CAqBf;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAAE,EACpB,KAAK,EAAE,MAAM,GACZ,WAAW,EAAE,CASf;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAY7D"}
1
+ {"version":3,"file":"navFilter.d.ts","sourceRoot":"","sources":["../../../src/layouts/navFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,MAAM,CAKpE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CAyBzE;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3B,WAAW,EAAE,CAqBf;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAAE,EACpB,KAAK,EAAE,MAAM,GACZ,WAAW,EAAE,CASf;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAY7D"}
@@ -5,7 +5,7 @@ export type ThemeDensity = "comfortable" | "compact";
5
5
  /**
6
6
  * Sidebar / app-hub navigation row. Maps to Ant Design `Menu` items.
7
7
  *
8
- * - **`children`** — nested submenu; parent rows should use a `path` that you **do not** navigate to as a leaf (for example `/catalog`), unless you define that route.
8
+ * - **`children`** — nested submenu. The menu key is `${path}__submenu` so it does not collide with a child that reuses `path`.
9
9
  * - **`label`** — string or any React node (badges, extra markup).
10
10
  * - **`Icon`** — optional; omit on group-only rows if you prefer text-only labels.
11
11
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ding-react-admin",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Composable admin shell (Ant Design + React Router): quick-start AdminApp or build your own layout.",
@@ -38,7 +38,7 @@ function FileFieldInput({
38
38
  const showClear = clearable && hasUploadValue(value);
39
39
 
40
40
  return (
41
- <Space direction="vertical" size="middle" style={{ width: "100%" }}>
41
+ <Space orientation="vertical" size="middle" style={{ width: "100%" }}>
42
42
  {fileName ? (
43
43
  <Space>
44
44
  <PaperClipOutlined />
@@ -38,7 +38,7 @@ function ImageFieldInput({
38
38
  const showClear = clearable && hasUploadValue(value);
39
39
 
40
40
  return (
41
- <Space direction="vertical" size="middle" style={{ width: "100%" }}>
41
+ <Space orientation="vertical" size="middle" style={{ width: "100%" }}>
42
42
  {previewUrl ? (
43
43
  <Image
44
44
  src={previewUrl}
@@ -153,7 +153,7 @@ function ReferenceFieldSelect({
153
153
  showSearch={search}
154
154
  filterOption={search ? false : undefined}
155
155
  onSearch={search ? setSearchText : undefined}
156
- onDropdownVisibleChange={(open) => {
156
+ onOpenChange={(open) => {
157
157
  setDropdownOpen(open);
158
158
  if (!open) setSearchText(undefined);
159
159
  }}
@@ -113,7 +113,7 @@ function ReferenceManyFieldSelect({
113
113
  showSearch={search}
114
114
  filterOption={search ? false : undefined}
115
115
  onSearch={search ? setSearchText : undefined}
116
- onDropdownVisibleChange={(open) => {
116
+ onOpenChange={(open) => {
117
117
  setDropdownOpen(open);
118
118
  if (!open) setSearchText(undefined);
119
119
  }}
@@ -139,7 +139,7 @@ function ReferenceFilterInput({
139
139
  showSearch={search}
140
140
  filterOption={search ? false : undefined}
141
141
  onSearch={search ? setSearchText : undefined}
142
- onDropdownVisibleChange={(open) => {
142
+ onOpenChange={(open) => {
143
143
  setDropdownOpen(open);
144
144
  if (!open) setSearchText(undefined);
145
145
  }}
@@ -26,6 +26,7 @@ import { useThemeMode } from "../context/AppThemeProvider";
26
26
  import {
27
27
  collectSubmenuKeys,
28
28
  filterNavItems,
29
+ navSubmenuKey,
29
30
  } from "./navFilter";
30
31
  import { navItemsToAntdItems } from "./navMenuItems";
31
32
  import { filterNavByPermission } from "../permissions/resourcePermissions";
@@ -70,7 +71,7 @@ function ancestorKeysForActivePath(
70
71
  for (const node of nodes) {
71
72
  if (node.children?.length) {
72
73
  const sub = dfs(node.children);
73
- if (sub !== null) return [node.path, ...sub];
74
+ if (sub !== null) return [navSubmenuKey(node.path), ...sub];
74
75
  } else if (node.path === pathname) {
75
76
  return [];
76
77
  }
@@ -83,12 +83,17 @@ export function filterFlatNavItems(
83
83
  });
84
84
  }
85
85
 
86
+ /** Menu key for a parent row so it never collides with a child that shares `path`. */
87
+ export function navSubmenuKey(path: string): string {
88
+ return `${path}__submenu`;
89
+ }
90
+
86
91
  export function collectSubmenuKeys(items: NavItem[]): string[] {
87
92
  const keys: string[] = [];
88
93
  function walk(nodes: NavItem[]) {
89
94
  for (const node of nodes) {
90
95
  if (node.children?.length) {
91
- keys.push(node.path);
96
+ keys.push(navSubmenuKey(node.path));
92
97
  walk(node.children);
93
98
  }
94
99
  }
@@ -1,7 +1,7 @@
1
1
  import type { MenuProps } from "antd";
2
2
  import { NavMenuLabel } from "../components/NavMenuLabel";
3
3
  import type { NavItem } from "../types";
4
- import { getNavItemLabel } from "./navFilter";
4
+ import { getNavItemLabel, navSubmenuKey } from "./navFilter";
5
5
 
6
6
  export function navItemsToAntdItems(
7
7
  items: NavItem[],
@@ -36,7 +36,7 @@ export function navItemsToAntdItems(
36
36
 
37
37
  if (item.children?.length) {
38
38
  return {
39
- key: item.path,
39
+ key: navSubmenuKey(item.path),
40
40
  icon,
41
41
  label,
42
42
  ...itemTitle,
package/src/types.ts CHANGED
@@ -8,7 +8,7 @@ export type ThemeDensity = "comfortable" | "compact";
8
8
  /**
9
9
  * Sidebar / app-hub navigation row. Maps to Ant Design `Menu` items.
10
10
  *
11
- * - **`children`** — nested submenu; parent rows should use a `path` that you **do not** navigate to as a leaf (for example `/catalog`), unless you define that route.
11
+ * - **`children`** — nested submenu. The menu key is `${path}__submenu` so it does not collide with a child that reuses `path`.
12
12
  * - **`label`** — string or any React node (badges, extra markup).
13
13
  * - **`Icon`** — optional; omit on group-only rows if you prefer text-only labels.
14
14
  */