@microcosmmoney/portal-react 1.0.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,12 @@
1
+ import React from 'react';
2
+ import { type MicrocosmMenuGroup, type MicrocosmMenuItem } from '../menu-config';
3
+ export interface MicrocosmMenuSectionProps {
4
+ basePath?: string;
5
+ currentPath?: string;
6
+ onNavigate?: (path: string) => void;
7
+ groups?: MicrocosmMenuGroup[];
8
+ className?: string;
9
+ renderItem?: (item: MicrocosmMenuItem, resolvedPath: string, isActive: boolean) => React.ReactNode;
10
+ renderSectionHeader?: (group: MicrocosmMenuGroup) => React.ReactNode;
11
+ }
12
+ export declare function MicrocosmMenuSection({ basePath, currentPath, onNavigate, groups, className, renderItem, renderSectionHeader, }: MicrocosmMenuSectionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MicrocosmMenuSection = MicrocosmMenuSection;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ // AI-generated · AI-managed · AI-maintained
9
+ const react_1 = __importDefault(require("react"));
10
+ const menu_config_1 = require("../menu-config");
11
+ function isActive(itemPath, currentPath) {
12
+ if (!currentPath)
13
+ return false;
14
+ if (itemPath === '/')
15
+ return currentPath === '/';
16
+ return currentPath.startsWith(itemPath);
17
+ }
18
+ function MicrocosmMenuSection({ basePath, currentPath, onNavigate, groups = menu_config_1.microcosmMenuGroups, className = '', renderItem, renderSectionHeader, }) {
19
+ return ((0, jsx_runtime_1.jsx)("div", { className: `microcosm-menu ${className}`, children: groups.map((group) => ((0, jsx_runtime_1.jsxs)("div", { className: "microcosm-menu-group", children: [renderSectionHeader ? (renderSectionHeader(group)) : ((0, jsx_runtime_1.jsxs)("div", { style: {
20
+ display: 'flex',
21
+ alignItems: 'center',
22
+ gap: '8px',
23
+ padding: '8px 12px',
24
+ fontSize: '11px',
25
+ fontWeight: 600,
26
+ textTransform: 'uppercase',
27
+ letterSpacing: '0.05em',
28
+ opacity: 0.5,
29
+ fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
30
+ }, children: [(0, jsx_runtime_1.jsx)(group.icon, { size: 14 }), (0, jsx_runtime_1.jsx)("span", { children: group.title })] })), group.items.map((item) => {
31
+ const resolved = (0, menu_config_1.resolveMenuPath)(item.path, basePath);
32
+ const active = isActive(resolved, currentPath);
33
+ if (renderItem) {
34
+ return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: renderItem(item, resolved, active) }, item.key));
35
+ }
36
+ return ((0, jsx_runtime_1.jsxs)("button", { onClick: () => onNavigate?.(resolved), title: item.description, style: {
37
+ display: 'flex',
38
+ alignItems: 'center',
39
+ gap: '8px',
40
+ width: '100%',
41
+ padding: '8px 12px',
42
+ border: 'none',
43
+ background: active ? 'rgba(255,255,255,0.08)' : 'transparent',
44
+ color: active ? '#fff' : 'rgba(255,255,255,0.7)',
45
+ cursor: 'pointer',
46
+ fontSize: '13px',
47
+ fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
48
+ textAlign: 'left',
49
+ borderRadius: '6px',
50
+ transition: 'background 0.15s, color 0.15s',
51
+ }, onMouseEnter: (e) => {
52
+ if (!active) {
53
+ e.currentTarget.style.background = 'rgba(255,255,255,0.05)';
54
+ e.currentTarget.style.color = '#fff';
55
+ }
56
+ }, onMouseLeave: (e) => {
57
+ if (!active) {
58
+ e.currentTarget.style.background = 'transparent';
59
+ e.currentTarget.style.color = 'rgba(255,255,255,0.7)';
60
+ }
61
+ }, children: [(0, jsx_runtime_1.jsx)(item.icon, { size: 16 }), (0, jsx_runtime_1.jsx)("span", { children: item.title })] }, item.key));
62
+ })] }, group.key))) }));
63
+ }
@@ -0,0 +1,4 @@
1
+ export { MicrocosmMenuSection } from './components/menu-section';
2
+ export type { MicrocosmMenuSectionProps } from './components/menu-section';
3
+ export { blockchainMenu, web3OsMenu, microcosmMenuGroups, getAllMenuItems, resolveMenuPath, } from './menu-config';
4
+ export type { MicrocosmMenuItem, MicrocosmMenuGroup } from './menu-config';
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveMenuPath = exports.getAllMenuItems = exports.microcosmMenuGroups = exports.web3OsMenu = exports.blockchainMenu = exports.MicrocosmMenuSection = void 0;
4
+ // AI-generated · AI-managed · AI-maintained
5
+ var menu_section_1 = require("./components/menu-section");
6
+ Object.defineProperty(exports, "MicrocosmMenuSection", { enumerable: true, get: function () { return menu_section_1.MicrocosmMenuSection; } });
7
+ var menu_config_1 = require("./menu-config");
8
+ Object.defineProperty(exports, "blockchainMenu", { enumerable: true, get: function () { return menu_config_1.blockchainMenu; } });
9
+ Object.defineProperty(exports, "web3OsMenu", { enumerable: true, get: function () { return menu_config_1.web3OsMenu; } });
10
+ Object.defineProperty(exports, "microcosmMenuGroups", { enumerable: true, get: function () { return menu_config_1.microcosmMenuGroups; } });
11
+ Object.defineProperty(exports, "getAllMenuItems", { enumerable: true, get: function () { return menu_config_1.getAllMenuItems; } });
12
+ Object.defineProperty(exports, "resolveMenuPath", { enumerable: true, get: function () { return menu_config_1.resolveMenuPath; } });
@@ -0,0 +1,19 @@
1
+ import { type LucideIcon } from 'lucide-react';
2
+ export interface MicrocosmMenuItem {
3
+ title: string;
4
+ key: string;
5
+ path: string;
6
+ icon: LucideIcon;
7
+ description?: string;
8
+ }
9
+ export interface MicrocosmMenuGroup {
10
+ title: string;
11
+ key: string;
12
+ icon: LucideIcon;
13
+ items: MicrocosmMenuItem[];
14
+ }
15
+ export declare const blockchainMenu: MicrocosmMenuGroup;
16
+ export declare const web3OsMenu: MicrocosmMenuGroup;
17
+ export declare const microcosmMenuGroups: MicrocosmMenuGroup[];
18
+ export declare function getAllMenuItems(): MicrocosmMenuItem[];
19
+ export declare function resolveMenuPath(path: string, basePath?: string): string;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.microcosmMenuGroups = exports.web3OsMenu = exports.blockchainMenu = void 0;
4
+ exports.getAllMenuItems = getAllMenuItems;
5
+ exports.resolveMenuPath = resolveMenuPath;
6
+ // AI-generated · AI-managed · AI-maintained
7
+ const lucide_react_1 = require("lucide-react");
8
+ exports.blockchainMenu = {
9
+ title: 'Blockchain',
10
+ key: 'blockchain',
11
+ icon: lucide_react_1.Coins,
12
+ items: [
13
+ {
14
+ title: '铸造',
15
+ key: 'mining',
16
+ path: '/mcc/mining',
17
+ icon: lucide_react_1.Pickaxe,
18
+ description: '支付稳定币铸造获得 MCC',
19
+ },
20
+ {
21
+ title: '轮回回购',
22
+ key: 'reincarnation',
23
+ path: '/mcc/reincarnation',
24
+ icon: lucide_react_1.ArrowDownUp,
25
+ description: 'MCC 回购换取稳定币',
26
+ },
27
+ {
28
+ title: '钱包',
29
+ key: 'wallet',
30
+ path: '/mcc/wallet',
31
+ icon: lucide_react_1.Wallet,
32
+ description: 'MCC 资产总览',
33
+ },
34
+ {
35
+ title: 'MCD 积分',
36
+ key: 'mcd',
37
+ path: '/mcc/mcd',
38
+ icon: lucide_react_1.Ticket,
39
+ description: 'MCD 余额、积分记录',
40
+ },
41
+ ],
42
+ };
43
+ exports.web3OsMenu = {
44
+ title: 'Web3 OS',
45
+ key: 'web3os',
46
+ icon: lucide_react_1.Users,
47
+ items: [
48
+ {
49
+ title: '拍卖市场',
50
+ key: 'auctions',
51
+ path: '/mcc/auctions',
52
+ icon: lucide_react_1.Gift,
53
+ description: '领地拍卖竞价',
54
+ },
55
+ {
56
+ title: '领地管理',
57
+ key: 'territory',
58
+ path: '/user-system/territory',
59
+ icon: lucide_react_1.Building2,
60
+ description: '领地列表和详情',
61
+ },
62
+ {
63
+ title: '社区投票',
64
+ key: 'voting',
65
+ path: '/mcc/voting',
66
+ icon: lucide_react_1.Vote,
67
+ description: '参与社区提案投票',
68
+ },
69
+ {
70
+ title: '组织架构',
71
+ key: 'organization',
72
+ path: '/user-system/organization',
73
+ icon: lucide_react_1.Users,
74
+ description: '组织结构和层级',
75
+ },
76
+ ],
77
+ };
78
+ exports.microcosmMenuGroups = [
79
+ exports.blockchainMenu,
80
+ exports.web3OsMenu,
81
+ ];
82
+ function getAllMenuItems() {
83
+ return exports.microcosmMenuGroups.flatMap(group => group.items);
84
+ }
85
+ function resolveMenuPath(path, basePath) {
86
+ if (!basePath)
87
+ return path;
88
+ const base = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
89
+ return `${base}${path}`;
90
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@microcosmmoney/portal-react",
3
+ "version": "1.0.0",
4
+ "description": "Microcosm Portal UI components for React/Next.js",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "dev": "tsc --watch"
11
+ },
12
+ "peerDependencies": {
13
+ "react": ">=18.0.0",
14
+ "react-dom": ">=18.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@microcosmmoney/auth-core": "^1.0.0",
18
+ "@microcosmmoney/auth-react": "^1.0.0",
19
+ "lucide-react": ">=0.300.0"
20
+ },
21
+ "devDependencies": {
22
+ "@types/react": "^18.0.0",
23
+ "react": "^18.0.0",
24
+ "typescript": "^5.3.0"
25
+ },
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/MicrocosmMoney/Microcosm"
30
+ }
31
+ }