@donglegeyu/company-ui 2.0.0 → 2.1.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.
@@ -83,6 +83,10 @@ export interface AdminLayoutTemplateProps {
83
83
  homeTab?: MultiTabHomeConfig;
84
84
  /** 首页内容(homeTab 激活时渲染;缺省回落 children) */
85
85
  homeContent?: ReactNode;
86
+ /** 页签栏首页左侧搜索入口(搜索「应用和菜单」),默认开启;传 false 关闭 */
87
+ tabSearch?: boolean;
88
+ /** 搜索框占位文案(默认「请输入关键词搜索应用和菜单」) */
89
+ tabSearchPlaceholder?: string;
86
90
  /** 页签栏右侧扩展区 */
87
91
  tabExtra?: ReactNode;
88
92
  /** 启用 AI 智能助手:主区右侧并列全高 AI 面板列(对齐设计稿 4 列布局),页面经 aiCapability 接入能力(默认关闭) */
@@ -113,4 +117,4 @@ export interface AdminLayoutTemplateProps {
113
117
  * - 间距契约固化:内容区只做滚动容器(零间距),业务模板自带全部内边距与背景
114
118
  * - 两种内容模式:pages 配置式(key 与菜单联动)或 children 兜底(直接放业务模板)
115
119
  */
116
- export default function AdminLayoutTemplate({ className, style, logo, brandName, userInfo, onLogout, onThemeSettings, domains, currentDomainId, defaultDomainId, onDomainChange, businessMenus, firstMenus, systemBottomMenus, visibleMenuCount, emptyImage, customNavMenus, onCustomNavUpdate, defaultFavorites, onFavoritesChange, defaultActiveFirstMenu, defaultActiveKey, defaultSecondSidebarFixed, tabs, defaultTabs, activeTabKey, defaultActiveTabKey, onTabsChange, onActiveTabChange, onTabClose, homeTab, homeContent, tabExtra, aiAssistant, aiAssistantWidth, aiAssistantDefaultOpen, aiTransport, onMenuOpen, onActiveFirstMenuChange, pages, children, contentClassName, contentStyle, }: AdminLayoutTemplateProps): import("react").JSX.Element;
120
+ export default function AdminLayoutTemplate({ className, style, logo, brandName, userInfo, onLogout, onThemeSettings, domains, currentDomainId, defaultDomainId, onDomainChange, businessMenus, firstMenus, systemBottomMenus, visibleMenuCount, emptyImage, customNavMenus, onCustomNavUpdate, defaultFavorites, onFavoritesChange, defaultActiveFirstMenu, defaultActiveKey, defaultSecondSidebarFixed, tabs, defaultTabs, activeTabKey, defaultActiveTabKey, onTabsChange, onActiveTabChange, onTabClose, homeTab, homeContent, tabSearch, tabSearchPlaceholder, tabExtra, aiAssistant, aiAssistantWidth, aiAssistantDefaultOpen, aiTransport, onMenuOpen, onActiveFirstMenuChange, pages, children, contentClassName, contentStyle, }: AdminLayoutTemplateProps): import("react").JSX.Element;
@@ -80,6 +80,19 @@ function collectParentKeys(menus) {
80
80
  return (_a = menu.children) == null ? void 0 : _a.length;
81
81
  }).map((menu) => menu.key);
82
82
  }
83
+ function collectSearchOptions(menus) {
84
+ const options = [];
85
+ const walk = (items) => {
86
+ items.forEach((menu) => {
87
+ var _a;
88
+ options.push({ key: menu.key, label: menu.label, path: menu.path });
89
+ if ((_a = menu.children) == null ? void 0 : _a.length)
90
+ walk(menu.children);
91
+ });
92
+ };
93
+ walk(menus);
94
+ return options;
95
+ }
83
96
  var AdminLayoutErrorBoundary = class extends import_react.Component {
84
97
  constructor(props) {
85
98
  super(props);
@@ -330,6 +343,8 @@ function AdminLayoutTemplate({
330
343
  onTabClose,
331
344
  homeTab,
332
345
  homeContent,
346
+ tabSearch = true,
347
+ tabSearchPlaceholder,
333
348
  tabExtra,
334
349
  aiAssistant,
335
350
  aiAssistantWidth = 363,
@@ -627,6 +642,17 @@ function AdminLayoutTemplate({
627
642
  openTab
628
643
  ]
629
644
  );
645
+ const tabSearchOptions = (0, import_react.useMemo)(
646
+ () => tabSearch ? collectSearchOptions(businessMenus) : void 0,
647
+ [tabSearch, businessMenus]
648
+ );
649
+ const handleTabSearchSelect = (0, import_react.useCallback)(
650
+ (option) => {
651
+ const menu = findMenuByKey(businessMenus, option.key);
652
+ handleMenuClick(menu ?? { key: option.key, label: option.label, path: option.path });
653
+ },
654
+ [businessMenus, handleMenuClick]
655
+ );
630
656
  const [moreOpen, setMoreOpen] = (0, import_react.useState)(false);
631
657
  const tabActionExtra = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
632
658
  tabExtra,
@@ -723,7 +749,10 @@ function AdminLayoutTemplate({
723
749
  homeTab,
724
750
  isHomeActive,
725
751
  onHomeClick: handleHomeClick,
726
- extra: tabActionExtra
752
+ extra: tabActionExtra,
753
+ searchOptions: tabSearchOptions,
754
+ searchPlaceholder: tabSearchPlaceholder,
755
+ onSearchSelect: handleTabSearchSelect
727
756
  }
728
757
  ) }),
729
758
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -12,6 +12,14 @@ export interface MultiTabHomeConfig {
12
12
  label: ReactNode;
13
13
  icon?: ReactNode;
14
14
  }
15
+ export interface MultiTabSearchOption {
16
+ /** 唯一标识(如菜单 key) */
17
+ key: string;
18
+ /** 名称,参与关键词过滤 */
19
+ label: string;
20
+ /** 路径,透传给业务方使用 */
21
+ path?: string;
22
+ }
15
23
  export interface CompanyMultiTabsProps {
16
24
  tabs: MultiTabItem[];
17
25
  activeKey: string;
@@ -22,6 +30,12 @@ export interface CompanyMultiTabsProps {
22
30
  onHomeClick?: () => void;
23
31
  getItemLabel?: (tab: MultiTabItem) => ReactNode;
24
32
  extra?: ReactNode;
33
+ /** 搜索数据源(应用与菜单);非空时页签栏首页左侧显示搜索入口 */
34
+ searchOptions?: MultiTabSearchOption[];
35
+ /** 搜索框占位文案 */
36
+ searchPlaceholder?: string;
37
+ /** 选中搜索项回调(选中后面板自动关闭) */
38
+ onSearchSelect?: (option: MultiTabSearchOption) => void;
25
39
  className?: string;
26
40
  style?: React.CSSProperties;
27
41
  }
@@ -34,6 +34,85 @@ var import_jsx_runtime = require("react/jsx-runtime");
34
34
  function DefaultCloseIcon({ onClick }) {
35
35
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: "关闭", mouseEnterDelay: 0.5, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: "close", className: "company-multi-tabs__close", size: 12, onClick }) });
36
36
  }
37
+ var DEFAULT_SEARCH_PLACEHOLDER = "请输入关键词搜索应用和菜单";
38
+ function SearchEntry({
39
+ options,
40
+ placeholder,
41
+ onSelect
42
+ }) {
43
+ const [open, setOpen] = (0, import_react.useState)(false);
44
+ const [keyword, setKeyword] = (0, import_react.useState)("");
45
+ const containerRef = (0, import_react.useRef)(null);
46
+ (0, import_react.useEffect)(() => {
47
+ if (!open)
48
+ return;
49
+ const handleMouseDown = (e) => {
50
+ var _a;
51
+ if (!((_a = containerRef.current) == null ? void 0 : _a.contains(e.target)))
52
+ setOpen(false);
53
+ };
54
+ const handleKeyDown = (e) => {
55
+ if (e.key === "Escape")
56
+ setOpen(false);
57
+ };
58
+ document.addEventListener("mousedown", handleMouseDown);
59
+ document.addEventListener("keydown", handleKeyDown);
60
+ return () => {
61
+ document.removeEventListener("mousedown", handleMouseDown);
62
+ document.removeEventListener("keydown", handleKeyDown);
63
+ };
64
+ }, [open]);
65
+ const filteredOptions = (0, import_react.useMemo)(() => {
66
+ const kw = keyword.trim().toLowerCase();
67
+ if (!kw)
68
+ return options;
69
+ return options.filter((option) => option.label.toLowerCase().includes(kw));
70
+ }, [options, keyword]);
71
+ const handleSelect = (0, import_react.useCallback)(
72
+ (option) => {
73
+ setOpen(false);
74
+ setKeyword("");
75
+ onSelect == null ? void 0 : onSelect(option);
76
+ },
77
+ [onSelect]
78
+ );
79
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-multi-tabs__search", ref: containerRef, children: [
80
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: "搜索", mouseEnterDelay: 0.5, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
81
+ "button",
82
+ {
83
+ type: "button",
84
+ "aria-label": "搜索",
85
+ className: `company-multi-tabs__search-trigger${open ? " is-open" : ""}`,
86
+ onClick: () => setOpen((prev) => !prev),
87
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: "search", size: 16 })
88
+ }
89
+ ) }),
90
+ open ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-multi-tabs__search-panel", children: [
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-multi-tabs__search-input", children: [
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
+ "input",
94
+ {
95
+ autoFocus: true,
96
+ value: keyword,
97
+ placeholder: placeholder ?? DEFAULT_SEARCH_PLACEHOLDER,
98
+ onChange: (e) => setKeyword(e.target.value)
99
+ }
100
+ ),
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: "search", size: 16, className: "company-multi-tabs__search-input-icon" })
102
+ ] }),
103
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "company-multi-tabs__search-list", children: filteredOptions.length ? filteredOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
+ "button",
105
+ {
106
+ type: "button",
107
+ className: "company-multi-tabs__search-option",
108
+ title: option.label,
109
+ onClick: () => handleSelect(option),
110
+ children: option.label
111
+ }
112
+ ) }, option.key)) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "company-multi-tabs__search-empty", children: "暂无匹配结果" }) })
113
+ ] }) : null
114
+ ] });
115
+ }
37
116
  function CompanyMultiTabsInner(props) {
38
117
  const {
39
118
  tabs,
@@ -45,10 +124,14 @@ function CompanyMultiTabsInner(props) {
45
124
  onHomeClick,
46
125
  getItemLabel,
47
126
  extra,
127
+ searchOptions,
128
+ searchPlaceholder,
129
+ onSearchSelect,
48
130
  className,
49
131
  style
50
132
  } = props;
51
133
  const { token } = import_antd.theme.useToken();
134
+ const showSearchEntry = Boolean(searchOptions == null ? void 0 : searchOptions.length);
52
135
  const handleTabClick = (0, import_react.useCallback)(
53
136
  (tab) => {
54
137
  if (tab.disabled)
@@ -89,9 +172,26 @@ function CompanyMultiTabsInner(props) {
89
172
  "--cmt-icon": token.colorTextQuaternary,
90
173
  "--cmt-icon-hover": token.colorTextSecondary,
91
174
  "--cmt-font-size": `${token.fontSize}px`,
175
+ // 搜索面板(对齐设计稿:白底圆角 + Select 阴影 + 聚焦主题色描边)
176
+ "--cmt-search-panel-bg": token.colorBgContainer,
177
+ "--cmt-search-panel-shadow": token.boxShadowSecondary,
178
+ "--cmt-search-input-bg": token.colorFillQuaternary,
179
+ "--cmt-search-input-border": token.colorPrimary,
180
+ "--cmt-search-text": token.colorText,
181
+ "--cmt-search-placeholder": token.colorTextPlaceholder,
182
+ "--cmt-search-icon": token.colorIcon,
183
+ "--cmt-search-option-hover": token.colorFillTertiary,
92
184
  ...style
93
185
  },
94
186
  children: [
187
+ showSearchEntry ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
188
+ SearchEntry,
189
+ {
190
+ options: searchOptions ?? [],
191
+ placeholder: searchPlaceholder,
192
+ onSelect: onSearchSelect
193
+ }
194
+ ) : null,
95
195
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-multi-tabs__list", children: [
96
196
  homeTab ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
97
197
  "div",
@@ -23,6 +23,131 @@
23
23
  scrollbar-width: none;
24
24
  }
25
25
 
26
+ // —— 首页左侧搜索入口 ——
27
+ &__search {
28
+ position: relative;
29
+ display: flex;
30
+ align-items: center;
31
+ flex-shrink: 0;
32
+ margin-right: var(--cmt-gap);
33
+ }
34
+
35
+ &__search-trigger {
36
+ box-sizing: border-box;
37
+ width: 28px;
38
+ height: 28px;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ padding: 0;
43
+ border: none;
44
+ border-radius: var(--cmt-item-radius);
45
+
46
+ // 默认背景与页签一致,图标默认色与页签文字一致,悬停效果同页签(bg-hover + 文字加深)
47
+ background: var(--cmt-item-bg);
48
+ color: var(--cmt-text);
49
+ cursor: pointer;
50
+ transition:
51
+ background 0.2s,
52
+ color 0.2s;
53
+
54
+ &:hover,
55
+ &.is-open {
56
+ background: var(--cmt-item-bg-hover);
57
+ color: var(--cmt-text-hover);
58
+ }
59
+ }
60
+
61
+ &__search-panel {
62
+ position: absolute;
63
+ top: calc(100% + 4px);
64
+ left: 0;
65
+ width: 280px;
66
+ padding: 6px;
67
+ background: var(--cmt-search-panel-bg);
68
+ border-radius: 6px;
69
+ box-shadow: var(--cmt-search-panel-shadow);
70
+ z-index: 1000;
71
+ }
72
+
73
+ &__search-input {
74
+ height: 32px;
75
+ display: flex;
76
+ align-items: center;
77
+ gap: 8px;
78
+ padding: 0 12px;
79
+ background: var(--cmt-search-input-bg);
80
+ border: 1px solid transparent;
81
+ border-radius: 4px;
82
+ transition: border-color 0.2s;
83
+
84
+ &:focus-within {
85
+ border-color: var(--cmt-search-input-border);
86
+ }
87
+
88
+ input {
89
+ flex: 1;
90
+ min-width: 0;
91
+ border: none;
92
+ outline: none;
93
+ background: transparent;
94
+ font-size: var(--cmt-font-size);
95
+ line-height: 22px;
96
+ color: var(--cmt-search-text);
97
+
98
+ &::placeholder {
99
+ color: var(--cmt-search-placeholder);
100
+ }
101
+ }
102
+ }
103
+
104
+ &__search-input-icon {
105
+ flex-shrink: 0;
106
+ color: var(--cmt-search-icon);
107
+ }
108
+
109
+ &__search-list {
110
+ margin: 4px 0 0;
111
+ padding: 0;
112
+ list-style: none;
113
+ max-height: 192px;
114
+ overflow-y: auto;
115
+ }
116
+
117
+ &__search-option {
118
+ box-sizing: border-box;
119
+ width: 100%;
120
+ height: 32px;
121
+ display: flex;
122
+ align-items: center;
123
+ padding: 0 12px;
124
+ border: none;
125
+ border-radius: 4px;
126
+ background: transparent;
127
+ font-size: var(--cmt-font-size);
128
+ line-height: 22px;
129
+ text-align: left;
130
+ color: var(--cmt-search-text);
131
+ cursor: pointer;
132
+ white-space: nowrap;
133
+ overflow: hidden;
134
+ text-overflow: ellipsis;
135
+ transition: background 0.2s;
136
+
137
+ &:hover {
138
+ background: var(--cmt-search-option-hover);
139
+ }
140
+ }
141
+
142
+ &__search-empty {
143
+ height: 32px;
144
+ display: flex;
145
+ align-items: center;
146
+ padding: 0 12px;
147
+ font-size: var(--cmt-font-size);
148
+ color: var(--cmt-search-placeholder);
149
+ }
150
+
26
151
  &__item {
27
152
  position: relative;
28
153
  box-sizing: border-box;
@@ -10,4 +10,4 @@ export interface MoreMenuDrawerProps {
10
10
  onToggleFavorite: (menu: SidebarMenuItem) => void;
11
11
  isFavorited: (menuKey: string) => boolean;
12
12
  }
13
- export default function MoreMenuDrawer({ visible, menus, onClose, onSelect, onOpenCustomNav, onToggleFavorite, isFavorited, }: MoreMenuDrawerProps): import("react").JSX.Element | null;
13
+ export default function MoreMenuDrawer({ visible, menus, onClose, onSelect, onOpenCustomNav, onToggleFavorite, isFavorited, }: MoreMenuDrawerProps): import("react").ReactPortal | null;
@@ -23,6 +23,7 @@ __export(MoreMenuDrawer_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(MoreMenuDrawer_exports);
25
25
  var import_react = require("react");
26
+ var import_react_dom = require("react-dom");
26
27
  var import_shared_components = require("../../shared-components");
27
28
  var import_index = require("./index.scss");
28
29
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -36,9 +37,12 @@ function MoreMenuDrawer({
36
37
  isFavorited
37
38
  }) {
38
39
  const searchInputRef = (0, import_react.useRef)(null);
40
+ const [inputValue, setInputValue] = (0, import_react.useState)("");
39
41
  const [searchKeyword, setSearchKeyword] = (0, import_react.useState)("");
42
+ const [searchPanelOpen, setSearchPanelOpen] = (0, import_react.useState)(false);
40
43
  const [selectedKey, setSelectedKey] = (0, import_react.useState)("");
41
44
  const [selectedMenu, setSelectedMenu] = (0, import_react.useState)(null);
45
+ const isComposingRef = (0, import_react.useRef)(false);
42
46
  const filteredMenus = (0, import_react.useMemo)(() => {
43
47
  if (!searchKeyword)
44
48
  return menus;
@@ -47,6 +51,27 @@ function MoreMenuDrawer({
47
51
  (menu) => menu.label.toLowerCase().includes(keyword) || (menu.children || []).some((child) => child.label.toLowerCase().includes(keyword))
48
52
  );
49
53
  }, [menus, searchKeyword]);
54
+ const allLeafMenus = (0, import_react.useMemo)(() => {
55
+ const leaves = [];
56
+ (menus || []).forEach((first) => {
57
+ (first.children || []).forEach((second) => {
58
+ if ((second.children || []).length > 0) {
59
+ (second.children || []).forEach(
60
+ (grandChild) => leaves.push({ leaf: grandChild, parent: second })
61
+ );
62
+ } else {
63
+ leaves.push({ leaf: second });
64
+ }
65
+ });
66
+ });
67
+ return leaves;
68
+ }, [menus]);
69
+ const searchResults = (0, import_react.useMemo)(() => {
70
+ if (!searchKeyword)
71
+ return allLeafMenus;
72
+ const keyword = searchKeyword.toLowerCase();
73
+ return allLeafMenus.filter((item) => item.leaf.label.toLowerCase().includes(keyword));
74
+ }, [allLeafMenus, searchKeyword]);
50
75
  (0, import_react.useEffect)(() => {
51
76
  if (visible && ((menus == null ? void 0 : menus.length) ?? 0) > 0) {
52
77
  const firstMenu = menus[0];
@@ -68,94 +93,149 @@ function MoreMenuDrawer({
68
93
  handleClose();
69
94
  };
70
95
  const handleClose = () => {
96
+ setInputValue("");
71
97
  setSearchKeyword("");
98
+ setSearchPanelOpen(false);
72
99
  setSelectedKey("");
73
100
  setSelectedMenu(null);
74
101
  onClose();
75
102
  };
103
+ const handleSearchChange = (e) => {
104
+ const value = e.target.value;
105
+ setInputValue(value);
106
+ if (!isComposingRef.current) {
107
+ setSearchKeyword(value);
108
+ }
109
+ };
110
+ const handleCompositionStart = () => {
111
+ isComposingRef.current = true;
112
+ };
113
+ const handleCompositionEnd = (e) => {
114
+ isComposingRef.current = false;
115
+ setSearchKeyword(e.target.value);
116
+ };
76
117
  const handleCustomNav = () => {
77
118
  onOpenCustomNav();
78
119
  handleClose();
79
120
  };
121
+ const renderMenuItem = (item, parentMenu) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "menu-item", onClick: () => handleChildClick(item, parentMenu), children: [
122
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: item.label }),
123
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
+ import_shared_components.SvgIcon,
125
+ {
126
+ name: isFavorited(item.key) ? "star-fill" : "star",
127
+ className: `star-icon${isFavorited(item.key) ? " is-favorited" : ""}`,
128
+ size: 14,
129
+ onClick: (e) => {
130
+ e.stopPropagation();
131
+ onToggleFavorite(item);
132
+ }
133
+ }
134
+ )
135
+ ] }, item.key);
136
+ const renderRightMenus = () => {
137
+ const blocks = [];
138
+ let leafRun = [];
139
+ const flushLeafRun = () => {
140
+ if (leafRun.length === 0)
141
+ return;
142
+ blocks.push(
143
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "menu-section", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "level-3", children: leafRun.map((item) => renderMenuItem(item)) }) }, `leaf-${leafRun.map((item) => item.key).join("-")}`)
144
+ );
145
+ leafRun = [];
146
+ };
147
+ ((selectedMenu == null ? void 0 : selectedMenu.children) || []).forEach((child) => {
148
+ if ((child.children || []).length > 0) {
149
+ flushLeafRun();
150
+ blocks.push(
151
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "menu-section", children: [
152
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "section-title", children: [
153
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "title-bar" }),
154
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "title-text", children: child.label })
155
+ ] }),
156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "level-3", children: (child.children || []).map((grandChild) => renderMenuItem(grandChild, child)) })
157
+ ] }, child.key)
158
+ );
159
+ } else {
160
+ leafRun.push(child);
161
+ }
162
+ });
163
+ flushLeafRun();
164
+ return blocks;
165
+ };
80
166
  if (!visible)
81
167
  return null;
82
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-sidebar-more-drawer", children: [
83
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "search-area", children: [
84
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "search-wrapper", children: [
85
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
- "input",
87
- {
88
- ref: searchInputRef,
89
- value: searchKeyword,
90
- onChange: (e) => setSearchKeyword(e.target.value),
91
- className: "search-input",
92
- placeholder: "请输入关键词搜索应用和菜单"
93
- }
94
- ),
95
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "search", className: "search-icon" })
96
- ] }),
97
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "close-btn", viewBox: "0 0 48 48", onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
- "path",
99
- {
100
- d: "M12 12l24 24M36 12L12 36",
101
- stroke: "currentColor",
102
- strokeWidth: "4",
103
- strokeLinecap: "round"
104
- }
105
- ) })
106
- ] }),
107
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "content-area", children: [
108
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "menu-left", children: [
109
- filteredMenus.map((menu) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
110
- "div",
111
- {
112
- className: `menu-item${selectedKey === menu.key ? " active" : ""}`,
113
- onClick: () => handleSelect(menu),
114
- children: [
115
- menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: menu.icon || "folder-open", className: "menu-icon" }),
116
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
117
- ]
118
- },
119
- menu.key
120
- )),
121
- filteredMenus.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "no-data", children: "暂无数据" }),
122
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "custom-nav-section", children: [
123
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "custom-nav-divider" }),
124
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "custom-nav-btn", onClick: handleCustomNav, children: [
125
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "setting", className: "icon" }),
126
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "自定义导航栏" })
127
- ] })
128
- ] })
129
- ] }),
130
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "menu-right", children: selectedMenu ? (selectedMenu.children || []).map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "menu-section", children: [
131
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "section-title", children: [
132
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "title-bar" }),
133
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "title-text", children: child.label })
134
- ] }),
135
- (child.children || []).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "level-3", children: (child.children || []).map((grandChild) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
136
- "div",
137
- {
138
- className: "menu-item",
139
- onClick: () => handleChildClick(grandChild, child),
140
- children: [
141
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: grandChild.label }),
142
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
- import_shared_components.SvgIcon,
168
+ return (0, import_react_dom.createPortal)(
169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "company-sidebar-more-drawer-mask", onClick: handleClose }),
171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "company-sidebar-more-drawer", children: [
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "search-area", children: [
173
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "search-wrapper", children: [
174
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
175
+ "input",
176
+ {
177
+ ref: searchInputRef,
178
+ value: inputValue,
179
+ onChange: handleSearchChange,
180
+ onCompositionStart: handleCompositionStart,
181
+ onCompositionEnd: handleCompositionEnd,
182
+ onFocus: () => setSearchPanelOpen(true),
183
+ onBlur: () => setSearchPanelOpen(false),
184
+ className: "search-input",
185
+ placeholder: "请输入关键词搜索应用和菜单"
186
+ }
187
+ ),
188
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "search", className: "search-icon" }),
189
+ searchPanelOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "search-dropdown", onMouseDown: (e) => e.preventDefault(), children: [
190
+ searchResults.map(({ leaf, parent }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
191
+ "div",
144
192
  {
145
- name: isFavorited(grandChild.key) ? "star-fill" : "star",
146
- className: `star-icon${isFavorited(grandChild.key) ? " is-favorited" : ""}`,
147
- size: 14,
148
- onClick: (e) => {
149
- e.stopPropagation();
150
- onToggleFavorite(grandChild);
151
- }
152
- }
153
- )
154
- ]
155
- },
156
- grandChild.key
157
- )) })
158
- ] }, child.key)) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "no-data", children: "请选择左侧菜单" }) })
159
- ] })
160
- ] });
193
+ className: "search-dropdown-item",
194
+ onClick: () => handleChildClick(leaf, parent),
195
+ children: leaf.label
196
+ },
197
+ parent ? `${parent.key}-${leaf.key}` : leaf.key
198
+ )),
199
+ searchResults.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "no-data", children: "暂无数据" })
200
+ ] })
201
+ ] }),
202
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "close-btn", viewBox: "0 0 48 48", onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
203
+ "path",
204
+ {
205
+ d: "M12 12l24 24M36 12L12 36",
206
+ stroke: "currentColor",
207
+ strokeWidth: "4",
208
+ strokeLinecap: "round"
209
+ }
210
+ ) })
211
+ ] }),
212
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "content-area", children: [
213
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "menu-left", children: [
214
+ filteredMenus.map((menu) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
215
+ "div",
216
+ {
217
+ className: `menu-item${selectedKey === menu.key ? " active" : ""}`,
218
+ onClick: () => handleSelect(menu),
219
+ children: [
220
+ menu.iconNode || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: menu.icon || "folder-open", className: "menu-icon" }),
221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "menu-label", children: menu.label })
222
+ ]
223
+ },
224
+ menu.key
225
+ )),
226
+ filteredMenus.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "no-data", children: "暂无数据" }),
227
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "custom-nav-section", children: [
228
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "custom-nav-divider" }),
229
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "custom-nav-btn", onClick: handleCustomNav, children: [
230
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { name: "setting", className: "icon" }),
231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "自定义导航栏" })
232
+ ] })
233
+ ] })
234
+ ] }),
235
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "menu-right", children: selectedMenu ? renderRightMenus() : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "no-data", children: "请选择左侧菜单" }) })
236
+ ] })
237
+ ] })
238
+ ] }),
239
+ document.body
240
+ );
161
241
  }
@@ -166,11 +166,10 @@ function CompanySidebar({
166
166
  const handleMoreSelect = (0, import_react.useCallback)(
167
167
  (menu, child) => {
168
168
  const target = child || menu;
169
- onFirstMenuSelect(menu.key);
170
- onMenuClick(target);
169
+ handleLeafMenuClick(target);
171
170
  setState((prev) => ({ ...prev, moreDrawerOpen: false }));
172
171
  },
173
- [onFirstMenuSelect, onMenuClick]
172
+ [handleLeafMenuClick]
174
173
  );
175
174
  const handleOpenCustomNav = (0, import_react.useCallback)(() => {
176
175
  setState((prev) => ({ ...prev, customNavVisible: true }));