@antscorp/antsomi-ui 1.3.5-beta.588 → 1.3.5-beta.589

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.
@@ -19,7 +19,7 @@ import { findActiveAppCodeByUrl, findLastMatchedItemByUrl, getMenuItem } from '.
19
19
  import { handleActiveRecommendationItem, recursiveFindItemByKey, recursiveFindParentOfActiveItem, } from './utils';
20
20
  // Hooks
21
21
  import { useNavigatePath } from '../../../hooks';
22
- import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
22
+ import { useCustomRouter, useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
23
23
  // Contexts
24
24
  import { useLeftMenuContext } from '../../../contexts';
25
25
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
@@ -50,6 +50,7 @@ export const ChildMenu = memo(props => {
50
50
  const isRecommendation = useLeftMenuContext(store => store.isRecommendation);
51
51
  const customActiveCurrentKey = useLeftMenuContext(store => store.customActiveCurrentKey);
52
52
  const setLeftMenuState = useLeftMenuContext(store => store.setState);
53
+ const { navigate } = useCustomRouter();
53
54
  const [currentActiveItem, setCurrentActiveItem] = useState('');
54
55
  const [openKeys, setOpenKeys] = useState([]);
55
56
  const { pathname, hash } = window.location;
@@ -169,6 +170,13 @@ export const ChildMenu = memo(props => {
169
170
  onMenuClick === null || onMenuClick === void 0 ? void 0 : onMenuClick(e.key, e.keyPath);
170
171
  }
171
172
  };
173
+ const onClickMenuItem = (menuItem) => {
174
+ const { key, menu_item_domain = '', menu_item_path = '' } = menuItem || {};
175
+ if (isPushDifferentDomain(menu_item_domain, menu_item_path)) {
176
+ return navigatePath(menu_item_domain, menu_item_path);
177
+ }
178
+ navigate(getPath(menu_item_path, key));
179
+ };
172
180
  const customMenuItems = (args) => {
173
181
  var _a;
174
182
  return (_a = args === null || args === void 0 ? void 0 : args.items) === null || _a === void 0 ? void 0 : _a.map(item => {
@@ -194,10 +202,10 @@ export const ChildMenu = memo(props => {
194
202
  return !!icon || !!logo_url ? (React.createElement(Flex, { style: { flexShrink: 0 }, align: "center" }, !isNil(icon) ? (React.createElement(IconWrapper, null,
195
203
  React.createElement(Icon, { type: icon }))) : !isNil(logo_url) ? (React.createElement(MenuItemImage, { imageUrl: logo_url, fallbackIcon: (_a = args === null || args === void 0 ? void 0 : args.parent) === null || _a === void 0 ? void 0 : _a.icon, className: classNames({ isActive: currentActiveItem === key }) })) : null)) : null;
196
204
  };
197
- const renderTitle = () => !menu_item_path || isRecommendation ? (renderLabel()) : isPushDifferentDomain(menu_item_domain, menu_item_path) ? (React.createElement("div", { onClick: () => navigatePath(menu_item_domain, menu_item_path), className: "menu-link" }, renderLabel())) : (React.createElement(Link, { to: getPath(menu_item_path, key), className: "menu-link", onClick: e => e.stopPropagation() }, renderLabel()));
205
+ const renderTitle = () => !menu_item_path || isRecommendation ? (renderLabel()) : (React.createElement("div", { className: "menu-link" }, renderLabel()));
198
206
  return {
199
207
  key,
200
- label: (React.createElement(Flex, { gap: 10, align: "center", justify: "space-between", style: { height: '100%' } },
208
+ label: (React.createElement(Flex, { gap: 10, align: "center", justify: "space-between", style: { height: '100%' }, onClick: () => onClickMenuItem(item) },
201
209
  renderIcon(),
202
210
  React.createElement(Flex, { style: styles.menuItemTitle, align: "center" }, renderTitle()))),
203
211
  disabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.588",
3
+ "version": "1.3.5-beta.589",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",