tntd 1.4.6 → 1.4.7

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.
Files changed (86) hide show
  1. package/components/Layout/HeaderActions.js +90 -128
  2. package/components/LoadingButton/index.js +11 -15
  3. package/dist/stats.json +4958 -4958
  4. package/dist/tntd.js +1 -1
  5. package/es/Layout/HeaderActions.js +10 -10
  6. package/es/LoadingButton/index.js +20 -10
  7. package/lib/ArrayInput/icon.js +27 -31
  8. package/lib/ArrayInput/index.js +211 -298
  9. package/lib/AuthContext.js +2 -13
  10. package/lib/Columns/index.js +71 -100
  11. package/lib/DevelopmentLogin/LoginModal.js +79 -141
  12. package/lib/DevelopmentLogin/index.js +28 -55
  13. package/lib/Ellipsis/Svg/CopySVG.js +23 -71
  14. package/lib/Ellipsis/Svg/TickSVG.js +17 -49
  15. package/lib/Ellipsis/index.js +148 -154
  16. package/lib/Handle/index.js +72 -109
  17. package/lib/Icon/fonts/iconfont.js +1 -43
  18. package/lib/Icon/iconList.js +119 -8
  19. package/lib/Icon/index.js +13 -45
  20. package/lib/Img/Contain.js +49 -81
  21. package/lib/Img/Cover.js +88 -136
  22. package/lib/Img/index.js +36 -89
  23. package/lib/Layout/ActionsContext.js +2 -11
  24. package/lib/Layout/AppList.js +262 -256
  25. package/lib/Layout/Application.js +119 -135
  26. package/lib/Layout/Avatar.js +137 -137
  27. package/lib/Layout/CompatibleLanguage.js +214 -195
  28. package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
  29. package/lib/Layout/EnterpriseLayout/Language.js +75 -100
  30. package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
  31. package/lib/Layout/EnterpriseLayout/index.js +32 -45
  32. package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
  33. package/lib/Layout/GlobalNavigation/index.js +110 -158
  34. package/lib/Layout/Header.js +165 -116
  35. package/lib/Layout/HeaderActions.js +132 -129
  36. package/lib/Layout/HeaderNavs.js +90 -113
  37. package/lib/Layout/HeaderTabs.js +312 -278
  38. package/lib/Layout/Iconfont.js +2 -15
  39. package/lib/Layout/Language.js +63 -102
  40. package/lib/Layout/Layout.js +272 -261
  41. package/lib/Layout/Logo.js +132 -87
  42. package/lib/Layout/OrgAppList.js +440 -319
  43. package/lib/Layout/SideMenu.js +429 -343
  44. package/lib/Layout/Theme.js +95 -124
  45. package/lib/Layout/checkAuth.js +21 -35
  46. package/lib/Layout/createActions.js +38 -51
  47. package/lib/Layout/images/index.js +33 -41
  48. package/lib/Layout/index.js +110 -161
  49. package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
  50. package/lib/Layout/paaslayout/Header.js +84 -90
  51. package/lib/Layout/paaslayout/Logo.js +27 -32
  52. package/lib/Layout/paaslayout/SideMenu.js +161 -174
  53. package/lib/Layout/paaslayout/index.js +240 -261
  54. package/lib/Layout/storage.js +20 -78
  55. package/lib/Layout/utils.js +93 -143
  56. package/lib/LoadingButton/index.js +25 -57
  57. package/lib/Modal/index.js +83 -108
  58. package/lib/Page/Box.js +56 -81
  59. package/lib/Page/index.js +151 -173
  60. package/lib/Page/utils.js +12 -30
  61. package/lib/QueryForm/Field/Checkbox.js +11 -33
  62. package/lib/QueryForm/Field/Select.js +63 -99
  63. package/lib/QueryForm/Field/SelectInput.js +69 -114
  64. package/lib/QueryForm/Field/fieldsMap.js +30 -52
  65. package/lib/QueryForm/Field/index.js +76 -158
  66. package/lib/QueryForm/createActions.js +50 -65
  67. package/lib/QueryForm/index.js +304 -383
  68. package/lib/QueryForm/useForm.js +6 -17
  69. package/lib/QueryListScene/List.js +290 -366
  70. package/lib/QueryListScene/QueryForm.js +93 -161
  71. package/lib/QueryListScene/QueryListScene.js +33 -87
  72. package/lib/QueryListScene/Title.js +10 -20
  73. package/lib/QueryListScene/Toolbar.js +8 -31
  74. package/lib/QueryListScene/createActions.js +64 -79
  75. package/lib/QueryListScene/index.js +23 -40
  76. package/lib/QueryListScene/useActions.js +6 -17
  77. package/lib/Select/DropDownWrap.js +60 -124
  78. package/lib/Select/index.js +425 -561
  79. package/lib/Table/ResizableTable/index.js +77 -121
  80. package/lib/Table/index.js +19 -51
  81. package/lib/Title/index.js +34 -52
  82. package/lib/index.js +19 -159
  83. package/lib/locale.js +48 -63
  84. package/package.json +1 -1
  85. package/lib/Layout/EnterpriseLayout/Header.js +0 -113
  86. package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
@@ -1,91 +1,85 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = require("react");
9
-
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
- var _HeaderActions = _interopRequireDefault(require("../HeaderActions"));
13
-
14
- var _AppList = _interopRequireDefault(require("../AppList"));
15
-
16
- var _Logo = _interopRequireDefault(require("./Logo"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
-
22
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
23
-
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
25
-
26
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
28
- function _templateObject2() {
29
- var data = _taggedTemplateLiteral(["\n flex: 1;\n .isInIframe & {\n display: none;\n }\n"]);
30
-
31
- _templateObject2 = function _templateObject2() {
32
- return data;
33
- };
34
-
35
- return data;
36
- }
37
-
38
- function _templateObject() {
39
- var data = _taggedTemplateLiteral(["\n position: sticky;\n top: 0;\n height: ", ";\n display: flex;\n color: #fff;\n background: #fff;\n z-index: 201;\n .isInIframe.noAppList &,\n .isEmptyLayout & {\n display: none;\n }\n .tnt-themeS1 & {\n background: #323b4a;\n }\n padding-right: 20px;\n box-shadow: 0 1px 10px 0 rgba(0,0,0,0.1);\n transition: box-shadow .2s cubic-bezier(.4,0,.2,1), -webkit-box-shadow .2s cubic-bezier(.4,0,.2,1);\n\n .paas-header-actions {\n li {\n .tnt-themeS1 & {\n color: rgba(255,255,255,.85);\n }\n }\n }\n"]);
40
-
41
- _templateObject = function _templateObject() {
42
- return data;
43
- };
44
-
45
- return data;
46
- }
47
-
48
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
49
-
50
- var Header = _styledComponents["default"].div(_templateObject(), function (props) {
51
- return "".concat(props.theme.headerHeight, "px");
52
- });
53
-
54
- var Content = _styledComponents["default"].div(_templateObject2());
55
-
56
- var _default = function _default(props) {
57
- var logo = props.logo,
58
- name = props.name,
59
- enName = props.enName,
60
- language = props.language,
61
- selectedAppKey = props.selectedAppKey,
62
- appList = props.appList,
63
- onLogoClick = props.onLogoClick,
64
- onAppChange = props.onAppChange,
65
- extraActions = props.extraActions;
66
-
67
- var config = _objectSpread({
68
- application: true
69
- }, props.config);
70
-
71
- var headerRef = (0, _react.useRef)();
72
- return React.createElement(Header, {
73
- ref: headerRef
74
- }, React.createElement(_Logo["default"], {
75
- language: language,
76
- logo: logo,
77
- name: name,
78
- enName: enName,
79
- onClick: onLogoClick
80
- }), appList && React.createElement(_AppList["default"], {
81
- items: appList,
82
- selectedKey: selectedAppKey,
83
- onChange: onAppChange
84
- }), React.createElement(Content, null, props.children), React.createElement(_HeaderActions["default"], _extends({}, props, {
85
- config: config,
86
- headerRef: headerRef,
87
- className: "paas-header-actions"
88
- }), extraActions));
1
+ /**
2
+ * @file Layout header
3
+ * @author zhangyou
4
+ */
5
+ import { useRef } from 'react';
6
+ import styled from 'styled-components';
7
+ import Actions from '../HeaderActions';
8
+ import AppList from '../AppList';
9
+ import Logo from './Logo';
10
+
11
+ const Header = styled.div`
12
+ position: sticky;
13
+ top: 0;
14
+ height: ${props => `${props.theme.headerHeight}px`};
15
+ display: flex;
16
+ color: #fff;
17
+ background: #fff;
18
+ z-index: 201;
19
+ .isInIframe.noAppList &,
20
+ .isEmptyLayout & {
21
+ display: none;
22
+ }
23
+ .tnt-themeS1 & {
24
+ background: #323b4a;
25
+ }
26
+ padding-right: 20px;
27
+ box-shadow: 0 1px 10px 0 rgba(0,0,0,0.1);
28
+ transition: box-shadow .2s cubic-bezier(.4,0,.2,1), -webkit-box-shadow .2s cubic-bezier(.4,0,.2,1);
29
+
30
+ .paas-header-actions {
31
+ li {
32
+ .tnt-themeS1 & {
33
+ color: rgba(255,255,255,.85);
34
+ }
35
+ }
36
+ }
37
+ `;
38
+
39
+ const Content = styled.div`
40
+ flex: 1;
41
+ .isInIframe & {
42
+ display: none;
43
+ }
44
+ `;
45
+
46
+ export default props => {
47
+ const { logo, name, enName, language, selectedAppKey, appList, onLogoClick, onAppChange, extraActions } = props;
48
+ const config = {
49
+ application: true,
50
+ ...props.config
51
+ };
52
+ const headerRef = useRef();
53
+
54
+ return (
55
+ <Header ref={headerRef}>
56
+ <Logo
57
+ language={language}
58
+ logo={logo}
59
+ name={name}
60
+ enName={enName}
61
+ onClick={onLogoClick}
62
+ />
63
+ {
64
+ appList && (
65
+ <AppList
66
+ items={appList}
67
+ selectedKey={selectedAppKey}
68
+ onChange={onAppChange}
69
+ />
70
+ )
71
+ }
72
+ <Content>
73
+ {props.children}
74
+ </Content>
75
+ <Actions
76
+ {...props}
77
+ config={config}
78
+ headerRef={headerRef}
79
+ className="paas-header-actions"
80
+ >
81
+ {extraActions}
82
+ </Actions>
83
+ </Header>
84
+ );
89
85
  };
90
-
91
- exports["default"] = _default;
@@ -1,32 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
- var _Logo = _interopRequireDefault(require("../Logo"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
- function _templateObject() {
15
- var data = _taggedTemplateLiteral(["\n color: #17233d !important;\n letter-spacing: 0;\n background: #fff !important;\n box-shadow: none !important;\n .isInIframe & {\n display: none;\n }\n\n &:after {\n display: none;\n }\n\n .tnt-themeS1 & {\n color: rgba(255,255,255,.85) !important;\n background: #323b4a !important;\n }\n"]);
16
-
17
- _templateObject = function _templateObject() {
18
- return data;
19
- };
20
-
21
- return data;
22
- }
23
-
24
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
25
-
26
- var LogoWrapper = (0, _styledComponents["default"])(_Logo["default"])(_templateObject());
27
-
28
- var _default = function _default(props) {
29
- return React.createElement(LogoWrapper, props);
30
- };
31
-
32
- exports["default"] = _default;
1
+ /**
2
+ * @file Logo
3
+ * @author zhangyou
4
+ */
5
+ import styled from 'styled-components';
6
+ import Logo from '../Logo';
7
+
8
+ const LogoWrapper = styled(Logo)`
9
+ color: #17233d !important;
10
+ letter-spacing: 0;
11
+ background: #fff !important;
12
+ box-shadow: none !important;
13
+ .isInIframe & {
14
+ display: none;
15
+ }
16
+
17
+ &:after {
18
+ display: none;
19
+ }
20
+
21
+ .tnt-themeS1 & {
22
+ color: rgba(255,255,255,.85) !important;
23
+ background: #323b4a !important;
24
+ }
25
+ `;
26
+
27
+ export default props => <LogoWrapper {...props} />;
@@ -1,185 +1,172 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = require("react");
9
-
10
- var _styledComponents = _interopRequireDefault(require("styled-components"));
11
-
12
- var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
- var _Iconfont = _interopRequireDefault(require("../Iconfont"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
19
-
20
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
21
-
22
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
23
-
24
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
-
26
- function _templateObject2() {
27
- var data = _taggedTemplateLiteral(["\n background: #fff;\n list-style: none;\n font-size: 14px;\n color: #17233D;\n margin: 10px 0 0;\n padding: 0;\n li {\n position: relative;\n line-height: 38px;\n cursor: pointer;\n padding-left: 20px;\n & > a {\n color: #17233D;\n & > span {\n padding-left: 10px;\n }\n }\n &.active {\n background: #EAEDF8;\n &:before {\n position: absolute;\n left: 0;\n top: 0;\n content: '';\n width: 4px;\n height: 100%;\n background-color: #4C79FF;\n }\n }\n }\n"]);
28
-
29
- _templateObject2 = function _templateObject2() {
30
- return data;
31
- };
32
-
33
- return data;
34
- }
35
-
36
- function _templateObject() {
37
- var data = _taggedTemplateLiteral(["\n background: #fff;\n list-style: none;\n margin: 0;\n padding: 0;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n .isInIframe & {\n display: none;\n }\n \n & > li {\n font-size: 14px;\n letter-spacing: 0;\n margin-top: 20px;\n &:first-child {\n margin-top: 30px;\n }\n & > span {\n line-height: 38px;\n opacity: 0.4;\n display: inline-block;\n width: calc(100% - 20px);\n color: #17233D;\n border-bottom: 1px solid #B2BECD;\n margin-left: 20px;\n }\n }\n"]);
38
-
39
- _templateObject = function _templateObject() {
40
- return data;
41
- };
42
-
43
- return data;
44
- }
45
-
46
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
47
-
48
- var SideMenu = _styledComponents["default"].ul(_templateObject());
49
-
50
- var SubMenu = _styledComponents["default"].ul(_templateObject2());
51
-
52
- var _default = function _default(props) {
53
- var language = props.language,
54
- _props$menus = props.menus,
55
- menus = _props$menus === void 0 ? [] : _props$menus,
56
- formatMenuPath = props.formatMenuPath,
57
- changeRouter = props.changeRouter,
58
- selectedKey = props.selectedKey,
59
- onBeforeChange = props.onBeforeChange,
60
- onChange = props.onChange,
61
- onSelect = props.onSelect;
62
-
63
- var _useState = (0, _react.useState)(selectedKey),
64
- _useState2 = _slicedToArray(_useState, 2),
65
- activeMenu = _useState2[0],
66
- setActiveMenu = _useState2[1];
67
-
68
- var defaultBeforeChange = function defaultBeforeChange(_ref) {
69
- var data = _ref.data;
70
- return !isNewTabMenu(data);
71
- };
72
-
73
- var defaultSelect = function defaultSelect(_ref2) {
74
- var _window$location$path;
75
-
76
- var data = _ref2.data;
77
-
78
- var _ref3 = data || {},
79
- path = _ref3.path;
80
-
81
- var formatPath = formatMenuPath || function (path) {
82
- return path;
83
- };
84
-
85
- if (isNewTabMenu(data)) {
86
- openInNewTab(formatPath(data == null ? void 0 : data.path, data));
87
- return;
1
+ import { useState, useEffect, Component } from 'react';
2
+ import styled from 'styled-components';
3
+ import cn from 'classnames';
4
+ import Iconfont from '../Iconfont';
5
+
6
+ const SideMenu = styled.ul`
7
+ background: #fff;
8
+ list-style: none;
9
+ margin: 0;
10
+ padding: 0;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ .isInIframe & {
15
+ display: none;
88
16
  }
89
-
90
- var routerPrefix = (_window$location$path = window.location.pathname.match(/(^\/[^\/]+)/i)) == null ? void 0 : _window$location$path[1];
91
-
92
- if (window.location.pathname.startsWith(routerPrefix)) {
93
- var forwardPath = formatPath(path, data);
94
- changeRouter ? changeRouter(forwardPath, data) : window.history.pushState(data, data == null ? void 0 : data.name, forwardPath);
95
- } else {
96
- window.location.href = formatPath(path, data);
17
+
18
+ & > li {
19
+ font-size: 14px;
20
+ letter-spacing: 0;
21
+ margin-top: 20px;
22
+ &:first-child {
23
+ margin-top: 30px;
24
+ }
25
+ & > span {
26
+ line-height: 38px;
27
+ opacity: 0.4;
28
+ display: inline-block;
29
+ width: calc(100% - 20px);
30
+ color: #17233D;
31
+ border-bottom: 1px solid #B2BECD;
32
+ margin-left: 20px;
33
+ }
97
34
  }
98
- };
99
-
100
- var selectMenu = function selectMenu() {
101
- var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
102
- var finalBeforeChange = onBeforeChange || defaultBeforeChange;
103
- var finalSelect = onSelect || defaultSelect;
104
-
105
- if (param.key !== activeMenu) {
106
- if (finalBeforeChange(param, activeMenu)) {
107
- setActiveMenu(param.key);
108
- onChange && onChange(param);
109
- }
35
+ `;
36
+
37
+ const SubMenu = styled.ul`
38
+ background: #fff;
39
+ list-style: none;
40
+ font-size: 14px;
41
+ color: #17233D;
42
+ margin: 10px 0 0;
43
+ padding: 0;
44
+ li {
45
+ position: relative;
46
+ line-height: 38px;
47
+ cursor: pointer;
48
+ padding-left: 20px;
49
+ & > a {
50
+ color: #17233D;
51
+ & > span {
52
+ padding-left: 10px;
53
+ }
54
+ }
55
+ &.active {
56
+ background: #EAEDF8;
57
+ &:before {
58
+ position: absolute;
59
+ left: 0;
60
+ top: 0;
61
+ content: '';
62
+ width: 4px;
63
+ height: 100%;
64
+ background-color: #4C79FF;
65
+ }
66
+ }
110
67
  }
68
+ `;
69
+
70
+ export default props => {
71
+ const { language, menus = [], formatMenuPath, changeRouter, selectedKey, onBeforeChange, onChange, onSelect } = props;
72
+ const [activeMenu, setActiveMenu] = useState(selectedKey);
73
+ const defaultBeforeChange = ({ data }) => !isNewTabMenu(data);
74
+ const defaultSelect = ({ data }) => {
75
+ const { path } = data || {};
76
+ const formatPath = formatMenuPath || (path => path);
77
+
78
+ if (isNewTabMenu(data)) {
79
+ openInNewTab(formatPath(data?.path, data));
80
+ return;
81
+ }
111
82
 
112
- finalSelect(param);
113
- };
114
-
115
- var MenuItem = function MenuItem(_ref4) {
116
- var item = _ref4.item;
117
- var code = item.code,
118
- groupName = item.groupName,
119
- enName = item.enName,
120
- _item$children = item.children,
121
- children = _item$children === void 0 ? [] : _item$children;
83
+ const routerPrefix = window.location.pathname.match(/(^\/[^\/]+)/i)?.[1];
122
84
 
123
- var SubMenuItem = function SubMenuItem(_ref5) {
124
- var menu = _ref5.menu;
125
- var code = menu.code,
126
- menuName = menu.menuName,
127
- enName = menu.enName,
128
- icon = menu.icon,
129
- path = menu.path;
130
- return React.createElement("li", {
131
- key: code,
132
- onClick: function onClick(evt) {
133
- return selectMenu({
134
- key: code,
135
- data: menu,
136
- domEvent: evt
137
- });
138
- },
139
- className: (0, _classnames["default"])({
140
- active: code === activeMenu
141
- })
142
- }, React.createElement("a", {
143
- href: path,
144
- onClick: function onClick(evt) {
145
- return evt.preventDefault();
85
+ if (window.location.pathname.startsWith(routerPrefix)) {
86
+ const forwardPath = formatPath(path, data);
87
+ changeRouter ? changeRouter(forwardPath, data) : window.history.pushState(data, data?.name, forwardPath);
88
+ } else {
89
+ window.location.href = formatPath(path, data);
146
90
  }
147
- }, icon instanceof _react.Component ? icon : React.createElement(_Iconfont["default"], {
148
- type: icon
149
- }), React.createElement("span", null, {
150
- cn: menuName,
151
- en: enName
152
- }[language])));
153
91
  };
92
+ const selectMenu = (param = {}) => {
93
+ const finalBeforeChange = onBeforeChange || defaultBeforeChange;
94
+ const finalSelect = onSelect || defaultSelect;
95
+
96
+ if (param.key !== activeMenu) {
97
+ if (finalBeforeChange(param, activeMenu)) {
98
+ setActiveMenu(param.key);
99
+ onChange && onChange(param);
100
+ }
101
+ }
154
102
 
155
- if (groupName && children.length) {
156
- return React.createElement("li", {
157
- key: code
158
- }, React.createElement("span", null, {
159
- cn: groupName,
160
- en: enName
161
- }[language]), React.createElement(SubMenu, null, children.map(function (subItem) {
162
- return React.createElement(SubMenuItem, {
163
- menu: subItem,
164
- key: subItem == null ? void 0 : subItem.code
165
- });
166
- })));
167
- }
103
+ finalSelect(param);
104
+ };
168
105
 
169
- return React.createElement(SubMenuItem, {
170
- menu: item
171
- });
172
- };
106
+ const MenuItem = ({ item }) => {
107
+ const { code, groupName, enName, children = [] } = item;
108
+ const SubMenuItem = ({ menu }) => {
109
+ const { code, menuName, enName, icon, path } = menu;
110
+
111
+ return (
112
+ <li
113
+ key={code}
114
+ onClick={evt => selectMenu({ key: code, data: menu, domEvent: evt })}
115
+ className={cn({ active: code === activeMenu })}
116
+ >
117
+ <a href={path} onClick={evt => evt.preventDefault()}>
118
+ {
119
+ icon instanceof Component ? icon : (
120
+ <Iconfont type={icon} />
121
+ )
122
+ }
123
+ <span>
124
+ {
125
+ {
126
+ cn: menuName,
127
+ en: enName
128
+ }[language]
129
+ }
130
+ </span>
131
+ </a>
132
+ </li>
133
+ );
134
+ };
135
+
136
+ if (groupName && children.length) {
137
+ return (
138
+ <li key={code}>
139
+ <span>
140
+ {
141
+ {
142
+ cn: groupName,
143
+ en: enName
144
+ }[language]
145
+ }
146
+ </span>
147
+ <SubMenu>
148
+ {
149
+ children.map(subItem => <SubMenuItem menu={subItem} key={subItem?.code} />)
150
+ }
151
+ </SubMenu>
152
+ </li>
153
+ );
154
+ }
173
155
 
174
- (0, _react.useEffect)(function () {
175
- setActiveMenu(selectedKey);
176
- }, [selectedKey]);
177
- return React.createElement(SideMenu, null, menus.map(function (menu) {
178
- return React.createElement(MenuItem, {
179
- item: menu,
180
- key: menu.code
181
- });
182
- }));
183
- };
156
+ return <SubMenuItem menu={item} />;
157
+ };
184
158
 
185
- exports["default"] = _default;
159
+ useEffect(() => {
160
+ setActiveMenu(selectedKey);
161
+ }, [selectedKey]);
162
+
163
+ return (
164
+ <SideMenu>
165
+ {
166
+ menus.map(menu => (
167
+ <MenuItem item={menu} key={menu.code} />
168
+ ))
169
+ }
170
+ </SideMenu>
171
+ );
172
+ };