listpage-next 0.0.253 → 0.0.254

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.
@@ -7,6 +7,5 @@ export interface AppProps {
7
7
  icon?: ReactNode;
8
8
  hasAuth?: () => boolean;
9
9
  loginElement?: JSX.Element;
10
- menuRender?: (menus: MenuItem[], defaultActiveKey?: string, onSelect?: (key: string) => void) => ReactNode;
11
10
  }
12
11
  export declare const App: (props: AppProps) => import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ import { createRoutes } from "./utils.js";
5
5
  import { Auth } from "./Auth.js";
6
6
  import { Layout } from "./Layout.js";
7
7
  const App = (props)=>{
8
- const { menus, basename = '', title, icon, loginElement, hasAuth, menuRender } = props;
8
+ const { menus, basename = '', title, icon, loginElement, hasAuth } = props;
9
9
  const router = useMemo(()=>{
10
10
  const routes = createRoutes(menus);
11
11
  return createBrowserRouter([
@@ -18,7 +18,6 @@ const App = (props)=>{
18
18
  element: /*#__PURE__*/ jsx(Auth, {
19
19
  hasAuth: hasAuth,
20
20
  children: /*#__PURE__*/ jsx(Layout, {
21
- menuRender: menuRender,
22
21
  menus: menus,
23
22
  title: title,
24
23
  icon: icon,
@@ -1,10 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
- import { MenuItem } from '../../components';
2
+ import { type MenuItem } from '../../ui/Menu';
3
3
  export interface LayoutProps {
4
4
  menus: MenuItem[];
5
5
  basename?: string;
6
6
  title?: string;
7
7
  icon?: ReactNode;
8
- menuRender?: (menus: MenuItem[], defaultActiveKey?: string, onSelect?: (key: string) => void) => ReactNode;
9
8
  }
10
9
  export declare const Layout: (props: LayoutProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useMemo } from "react";
3
3
  import { Outlet, useNavigate } from "react-router-dom";
4
- import { Menu, PageLayout } from "../../components/index.js";
4
+ import { PageLayout } from "../../components/index.js";
5
+ import { Menu } from "../../ui/Menu/index.js";
5
6
  import { getDefaultActiveKey } from "./utils.js";
6
7
  const Layout = (props)=>{
7
- const { menus, basename = '', title, icon, menuRender } = props;
8
+ const { menus, basename = '', title, icon } = props;
8
9
  const navigate = useNavigate();
9
10
  const defaultActiveKey = useMemo(()=>getDefaultActiveKey(basename, menus), [
10
11
  basename,
@@ -15,12 +16,12 @@ const Layout = (props)=>{
15
16
  icon,
16
17
  title
17
18
  },
18
- sider: menuRender?.(menus, defaultActiveKey, navigate) || /*#__PURE__*/ jsx(Menu, {
19
+ content: /*#__PURE__*/ jsx(Outlet, {}),
20
+ sider: /*#__PURE__*/ jsx(Menu, {
19
21
  items: menus,
20
22
  defaultActiveKey: defaultActiveKey,
21
23
  onSelect: navigate
22
- }),
23
- content: /*#__PURE__*/ jsx(Outlet, {})
24
+ })
24
25
  });
25
26
  };
26
27
  export { Layout };
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  export interface MenuItem {
3
- id: string;
3
+ key: string;
4
4
  label: string;
5
5
  icon?: React.ReactNode;
6
- path?: string;
7
6
  children?: MenuItem[];
8
7
  badge?: number | string;
9
8
  }
@@ -16,6 +15,8 @@ interface InternalSidebarItemProps {
16
15
  onToggleExpand: (id: string) => void;
17
16
  onNavigate?: (path: string) => void;
18
17
  level?: number;
18
+ parentPath?: string;
19
19
  }
20
+ export declare const resolvePath: (key: string, parentPath?: string) => string;
20
21
  export declare const SidebarItem: React.FC<InternalSidebarItemProps>;
21
22
  export {};
@@ -1,13 +1,18 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { ChevronDown, Circle } from "lucide-react";
4
- const SidebarItem = ({ item, isCollapsed, isActive, activePath, expandedIds, onToggleExpand, onNavigate, level = 0 })=>{
5
- const hasChildren = item.children && item.children.length > 0;
6
- const isExpanded = expandedIds.includes(item.id);
4
+ const resolvePath = (key, parentPath)=>{
5
+ const path = `${parentPath || ''}/${key}`;
6
+ return path.replace(/\/+/g, '/');
7
+ };
8
+ const SidebarItem = ({ item, isCollapsed, isActive, activePath, expandedIds, onToggleExpand, onNavigate, level = 0, parentPath })=>{
9
+ const hasChildren = !isCollapsed && item.children && item.children.length > 0;
10
+ const isExpanded = expandedIds.includes(item.key);
11
+ const currentPath = resolvePath(item.key, parentPath);
7
12
  const handleClick = (e)=>{
8
13
  e.stopPropagation();
9
- if (hasChildren) onToggleExpand(item.id);
10
- else if (item.path) onNavigate?.(item.path);
14
+ if (hasChildren) onToggleExpand(item.key);
15
+ else onNavigate?.(currentPath);
11
16
  };
12
17
  const paddingLeft = isCollapsed ? '0' : `${12 * level + 12}px`;
13
18
  return /*#__PURE__*/ jsxs("div", {
@@ -15,8 +20,7 @@ const SidebarItem = ({ item, isCollapsed, isActive, activePath, expandedIds, onT
15
20
  children: [
16
21
  /*#__PURE__*/ jsxs("div", {
17
22
  onClick: handleClick,
18
- className: `
19
- relative flex items-center justify-between py-1.5 px-2 mx-2 rounded-md cursor-pointer transition-all duration-200 group
23
+ className: `h-[40px] relative flex items-center justify-between py-1.5 px-2 mx-2 rounded-md cursor-pointer transition-all duration-200 group
20
24
  ${isActive ? 'bg-[#007AFF] text-white shadow-sm' : 'text-neutral-400 hover:bg-white/10 hover:text-neutral-200'}
21
25
  ${isCollapsed ? 'justify-center mx-2 px-0' : ''}
22
26
  `,
@@ -40,7 +44,7 @@ const SidebarItem = ({ item, isCollapsed, isActive, activePath, expandedIds, onT
40
44
  })
41
45
  }),
42
46
  !isCollapsed && /*#__PURE__*/ jsx("span", {
43
- className: `truncate text-[13px] leading-none ${isActive ? 'font-medium' : 'font-normal'}`,
47
+ className: `truncate text-[14px] leading-none ${isActive ? 'font-medium' : 'font-normal'}`,
44
48
  children: item.label
45
49
  })
46
50
  ]
@@ -53,7 +57,7 @@ const SidebarItem = ({ item, isCollapsed, isActive, activePath, expandedIds, onT
53
57
  children: item.badge
54
58
  }),
55
59
  hasChildren && /*#__PURE__*/ jsx("span", {
56
- className: `transition-transform duration-200 ${isExpanded ? 'rotate-180' : ''} ${isActive ? 'text-white/70' : 'text-neutral-600'}`,
60
+ className: `transition-transform duration-200 text-white/70 ${isExpanded ? 'rotate-180' : ''}`,
57
61
  children: /*#__PURE__*/ jsx(ChevronDown, {
58
62
  size: 12
59
63
  })
@@ -67,15 +71,16 @@ const SidebarItem = ({ item, isCollapsed, isActive, activePath, expandedIds, onT
67
71
  children: item.children?.map((child)=>/*#__PURE__*/ jsx(SidebarItem, {
68
72
  item: child,
69
73
  isCollapsed: isCollapsed,
70
- isActive: child.path === activePath,
74
+ isActive: resolvePath(child.key, currentPath) === activePath,
71
75
  activePath: activePath,
72
76
  expandedIds: expandedIds,
73
77
  onToggleExpand: onToggleExpand,
74
78
  onNavigate: onNavigate,
75
- level: level + 1
76
- }, child.id))
79
+ level: level + 1,
80
+ parentPath: currentPath
81
+ }, child.key))
77
82
  })
78
83
  ]
79
84
  });
80
85
  };
81
- export { SidebarItem };
86
+ export { SidebarItem, resolvePath };
@@ -1,10 +1,11 @@
1
1
  import { MenuItem } from './SiderItem';
2
+ export { type MenuItem } from './SiderItem';
2
3
  export interface MenuProps {
3
4
  title?: string;
4
5
  items: MenuItem[];
5
6
  isCollapsed?: boolean;
6
- activePath?: string;
7
- defaultActivePath?: string;
8
- onNavigate?: (path: string) => void;
7
+ activeKey?: string;
8
+ defaultActiveKey?: string;
9
+ onSelect?: (path: string) => void;
9
10
  }
10
11
  export declare const Menu: (props: MenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,13 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { SidebarItem } from "./SiderItem.js";
3
+ import { SidebarItem, resolvePath } from "./SiderItem.js";
4
4
  import { useControllableValue } from "ahooks";
5
5
  const Menu = (props)=>{
6
6
  const { items, isCollapsed, title } = props;
7
7
  const [activePath, setActivePath] = useControllableValue(props, {
8
- valuePropName: 'activePath',
9
- trigger: 'onNavigate',
10
- defaultValuePropName: 'defaultActivePath',
8
+ valuePropName: 'activeKey',
9
+ trigger: 'onSelect',
10
+ defaultValuePropName: 'defaultActiveKey',
11
11
  defaultValue: ''
12
12
  });
13
13
  const [expandedIds, setExpandedIds] = useState([]);
@@ -18,7 +18,7 @@ const Menu = (props)=>{
18
18
  ]);
19
19
  };
20
20
  return /*#__PURE__*/ jsxs("div", {
21
- className: "flex-1 overflow-y-auto overflow-x-hidden py-2 px-2 scrollbar-hide",
21
+ className: `overflow-y-auto overflow-x-hidden py-2 px-2 scrollbar-hide bg-[#000c17] ${isCollapsed ? 'w-[80px]' : 'flex-1'}`,
22
22
  children: [
23
23
  !isCollapsed && title && /*#__PURE__*/ jsx("div", {
24
24
  className: "px-3 mb-2 mt-2 text-[11px] font-medium text-neutral-500 uppercase tracking-widest",
@@ -29,12 +29,12 @@ const Menu = (props)=>{
29
29
  children: items.map((item)=>/*#__PURE__*/ jsx(SidebarItem, {
30
30
  item: item,
31
31
  isCollapsed: isCollapsed ?? false,
32
- isActive: item.path === activePath,
32
+ isActive: resolvePath(item.key) === activePath,
33
33
  activePath: activePath,
34
34
  expandedIds: expandedIds,
35
35
  onToggleExpand: handleToggleExpand,
36
36
  onNavigate: setActivePath
37
- }, item.id))
37
+ }, item.key))
38
38
  })
39
39
  ]
40
40
  });
@@ -3,5 +3,5 @@ export { Button, type ButtonProps } from './Button';
3
3
  export { LogPreview, type LogPreviewProps, type LogEntry } from './LogPreview';
4
4
  export { StatusTag, type StatusTagProps } from './StatusTag';
5
5
  export { Tabs, type TabsProps } from './Tabs';
6
- export { Menu, type MenuProps } from './Menu';
6
+ export { Menu, type MenuProps, type MenuItem } from './Menu';
7
7
  export { FileManager, AssetSelectorModal } from './FileManager';
package/dist/ui.css CHANGED
@@ -71,7 +71,6 @@
71
71
  --color-neutral-200: oklch(92.2% 0 0);
72
72
  --color-neutral-400: oklch(70.8% 0 0);
73
73
  --color-neutral-500: oklch(55.6% 0 0);
74
- --color-neutral-600: oklch(43.9% 0 0);
75
74
  --color-stone-400: oklch(70.9% 0.01 56.259);
76
75
  --color-stone-500: oklch(55.3% 0.013 58.071);
77
76
  --color-black: #000;
@@ -427,6 +426,9 @@
427
426
  .h-64 {
428
427
  height: calc(var(--spacing) * 64);
429
428
  }
429
+ .h-\[40px\] {
430
+ height: 40px;
431
+ }
430
432
  .h-\[85vh\] {
431
433
  height: 85vh;
432
434
  }
@@ -490,6 +492,9 @@
490
492
  .w-80 {
491
493
  width: calc(var(--spacing) * 80);
492
494
  }
495
+ .w-\[80px\] {
496
+ width: 80px;
497
+ }
493
498
  .w-\[200px\] {
494
499
  width: 200px;
495
500
  }
@@ -882,6 +887,9 @@
882
887
  .bg-\[\#0B1120\] {
883
888
  background-color: #0B1120;
884
889
  }
890
+ .bg-\[\#000c17\] {
891
+ background-color: #000c17;
892
+ }
885
893
  .bg-\[\#007AFF\] {
886
894
  background-color: #007AFF;
887
895
  }
@@ -1312,8 +1320,8 @@
1312
1320
  .text-\[11px\] {
1313
1321
  font-size: 11px;
1314
1322
  }
1315
- .text-\[13px\] {
1316
- font-size: 13px;
1323
+ .text-\[14px\] {
1324
+ font-size: 14px;
1317
1325
  }
1318
1326
  .leading-none {
1319
1327
  --tw-leading: 1;
@@ -1410,9 +1418,6 @@
1410
1418
  .text-neutral-500 {
1411
1419
  color: var(--color-neutral-500);
1412
1420
  }
1413
- .text-neutral-600 {
1414
- color: var(--color-neutral-600);
1415
- }
1416
1421
  .text-orange-400 {
1417
1422
  color: var(--color-orange-400);
1418
1423
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.253",
3
+ "version": "0.0.254",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",