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,267 +1,273 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- require("antd/lib/dropdown/style");
11
-
12
- var _dropdown = _interopRequireDefault(require("antd/lib/dropdown"));
13
-
14
- require("antd/lib/input/style");
15
-
16
- var _input = _interopRequireDefault(require("antd/lib/input"));
17
-
18
- require("antd/lib/tree-select/style");
19
-
20
- var _treeSelect = _interopRequireDefault(require("antd/lib/tree-select"));
21
-
22
- require("antd/lib/menu/style");
23
-
24
- var _menu = _interopRequireDefault(require("antd/lib/menu"));
25
-
26
- require("antd/lib/select/style");
27
-
28
- var _select = _interopRequireDefault(require("antd/lib/select"));
29
-
30
- var _react = require("react");
31
-
32
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
33
-
34
- var _lodash = require("lodash");
35
-
36
- var _Icon = _interopRequireDefault(require("../Icon"));
37
-
38
- var _storage = require("./storage");
39
-
40
- var _utils = require("./utils");
41
-
42
- var _this = void 0;
43
-
44
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
45
-
46
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
-
48
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
49
-
50
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
51
-
52
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
53
-
54
- 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; }
55
-
56
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
57
-
58
- function _templateObject4() {
59
- var data = _taggedTemplateLiteral(["\n display: block;\n color: #666;\n line-height: ", ";\n font-size: ", ";\n\n .tnt-themeS1 & {\n color: rgba(255,255,255,.85);\n }\n &:hover {\n color: #666;\n }\n i {\n margin-left: 12px;\n }\n"]);
60
-
61
- _templateObject4 = function _templateObject4() {
62
- return data;
63
- };
64
-
65
- return data;
66
- }
67
-
68
- function _templateObject3() {
69
- var data = _taggedTemplateLiteral(["\n min-width: 160px;\n height: 28px;\n line-height: 28;\n position: relative;\n top: 50%;\n transform: translateY(-50%);\n"]);
70
-
71
- _templateObject3 = function _templateObject3() {
72
- return data;
73
- };
74
-
75
- return data;
76
- }
77
-
78
- function _templateObject2() {
79
- var data = _taggedTemplateLiteral(["\n min-width: 160px;\n height: 28px;\n line-height: 28;\n position: relative;\n top: 50%;\n transform: translateY(-50%);\n .ant-select-selection, .ant-select-selection__rendered {\n line-height: 28px;\n height: 28px;\n }\n\n .ant-select-selection {\n .hasHeaderTabs & {\n border-radius: 14px;\n font-size: 12px;\n // \u53BB\u6389\u9ED8\u8BA4\u9ED1\u8272\n // background: #191D29;\n // border: 1px solid rgba(186,189,197,0.60);\n // color: rgba(255,255,255,.8);\n // \u7EDF\u4E00\u4E3A\u6D45\u8272\u8C03\n background: #fff !important;\n border-color: #c9d2dd !important;\n color: #8b919e !important;\n }\n // \u7EDF\u4E00\u8272\u8C03\n // .tnt-themeS1.hasHeaderTabs & {\n // /* background: #141825; */\n // /* color: rgba(255,255,255,.85); */\n // background: #fff;\n // border-color: #c9d2dd;\n // color: #8b919e;\n // }\n\n // .tnt-themeS3.hasHeaderTabs &{\n // background: ", "; //#1D4295\n // color: rgba(255,255,255,0.8);\n // border-color: rgba(255,255,255,0.5);\n // }\n }\n\n .ant-select-arrow {\n .hasHeaderTabs & {\n color: #B2BECD;\n }\n .tnt-themeS1 & {\n /* color: rgba(255,255,255,.85); */\n }\n }\n\n .tnt-themeS1 & {\n border-radius: 2px;\n }\n\n .isInIframe & {\n margin-left: 20px;\n }\n"]);
80
-
81
- _templateObject2 = function _templateObject2() {
82
- return data;
83
- };
84
-
85
- return data;
86
- }
87
-
88
- function _templateObject() {
89
- var data = _taggedTemplateLiteral(["\n border-radius: 0;\n min-width: 250px;\n max-height: 350px;\n overflow-y: auto;\n border: 1px solid #ccc;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;\n .ant-dropdown-menu-item {\n padding: 0 20px;\n height: 44px;\n line-height: 44px;\n &:hover {\n background: rgba(0, 0, 0, 0.1);\n }\n &.app-search-warp {\n padding: 0;\n &:hover {\n background: none;\n }\n .ant-input-affix-wrapper {\n height: 100%;\n }\n .ant-input {\n border: none;\n border-bottom: 1px dashed #dcdcdc;\n box-shadow: none;\n padding: 0 20px;\n }\n }\n i {\n margin-right: 0 !important;\n margin-left: 6px !important;\n }\n }\n .isInIframe & {\n margin-left: 20px;\n }\n"]);
90
-
91
- _templateObject = function _templateObject() {
92
- return data;
93
- };
94
-
95
- return data;
96
- }
97
-
98
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
99
-
100
- var Option = _select["default"].Option;
101
- var MenuList = (0, _styledComponents["default"])(_menu["default"])(_templateObject()); // 新版UI
102
-
103
- var AppsSelect = (0, _styledComponents["default"])(_select["default"])(_templateObject2(), function (props) {
104
- return "".concat(props.theme.blueBgColor, " !important");
105
- });
106
- var AppTreeSelect = (0, _styledComponents["default"])(_treeSelect["default"])(_templateObject3());
107
-
108
- var SwitchAppMenu = _styledComponents["default"].a(_templateObject4(), function (props) {
109
- return "".concat(props.theme.headerHeight, "px");
110
- }, function (props) {
111
- return "".concat(props.theme.size === 'large' ? 16 : 14, "px");
112
- });
113
-
114
- var _default = (0, _styledComponents.withTheme)(function (props) {
115
- var selectedKey = props.selectedKey,
116
- _props$items = props.items,
117
- items = _props$items === void 0 ? [] : _props$items,
118
- onChange = props.onChange;
119
-
120
- var getInitialSelectedApp = function getInitialSelectedApp() {
121
- var currentAppStore = (0, _storage.getCurrentAppStore)();
122
-
123
- var findAppByKey = function findAppByKey(selectedKey) {
124
- var findApp;
125
- (0, _utils.traverseTree)(items, function (item) {
126
- if (item.key === selectedKey) {
127
- findApp = item;
128
- return false;
1
+ import { useState, useEffect } from 'react';
2
+ import styled, { withTheme } from 'styled-components';
3
+ import { Dropdown, Menu, Input, Select, TreeSelect } from 'antd';
4
+ import { get } from 'lodash';
5
+ import Icon from '../Icon';
6
+ import { getCurrentAppStore, setCurrentAppStore } from './storage';
7
+ import { traverseTree } from './utils';
8
+
9
+ const { Option } = Select;
10
+ const MenuList = styled(Menu)`
11
+ border-radius: 0;
12
+ min-width: 250px;
13
+ max-height: 350px;
14
+ overflow-y: auto;
15
+ border: 1px solid #ccc;
16
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
17
+ .ant-dropdown-menu-item {
18
+ padding: 0 20px;
19
+ height: 44px;
20
+ line-height: 44px;
21
+ &:hover {
22
+ background: rgba(0, 0, 0, 0.1);
23
+ }
24
+ &.app-search-warp {
25
+ padding: 0;
26
+ &:hover {
27
+ background: none;
28
+ }
29
+ .ant-input-affix-wrapper {
30
+ height: 100%;
31
+ }
32
+ .ant-input {
33
+ border: none;
34
+ border-bottom: 1px dashed #dcdcdc;
35
+ box-shadow: none;
36
+ padding: 0 20px;
37
+ }
38
+ }
39
+ i {
40
+ margin-right: 0 !important;
41
+ margin-left: 6px !important;
129
42
  }
130
- });
131
- return findApp;
132
- };
133
-
134
- var currentApp = findAppByKey(selectedKey || (0, _lodash.get)(currentAppStore, 'key'));
135
- return currentApp || items[0];
136
- };
137
-
138
- var changeApp = function changeApp(app) {
139
- setSelectedApp(app);
140
- (0, _storage.setCurrentAppStore)(app);
141
- onChange && onChange(app);
142
- };
143
-
144
- var _useState = (0, _react.useState)(),
145
- _useState2 = _slicedToArray(_useState, 2),
146
- searchValue = _useState2[0],
147
- setSearchValue = _useState2[1];
148
-
149
- var _useState3 = (0, _react.useState)(getInitialSelectedApp()),
150
- _useState4 = _slicedToArray(_useState3, 2),
151
- selectedApp = _useState4[0],
152
- setSelectedApp = _useState4[1];
153
-
154
- var Menus = React.createElement(MenuList, {
155
- selectedKeys: [(0, _lodash.get)(selectedApp, 'key')]
156
- }, React.createElement(_menu["default"].Item, {
157
- className: "app-search-warp",
158
- key: "search",
159
- disabled: true
160
- }, React.createElement(_input["default"], {
161
- allowClear: true,
162
- placeholder: "\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",
163
- value: searchValue,
164
- onChange: function onChange(evt) {
165
- setSearchValue(evt.target.value);
166
43
  }
167
- })), items.filter(function () {
168
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
169
- key = _ref.key,
170
- name = _ref.name;
171
-
172
- var regExp = new RegExp(searchValue, 'i');
173
-
174
- if (searchValue) {
175
- return regExp.test(key) || regExp.test(name);
44
+ .isInIframe & {
45
+ margin-left: 20px;
176
46
  }
177
-
178
- return true;
179
- }).map(function (item) {
180
- return React.createElement(_menu["default"].Item, {
181
- key: item.key,
182
- onClick: changeApp.bind(_this, item)
183
- }, item.name);
184
- }));
185
- (0, _react.useEffect)(function () {
186
- var newApp = getInitialSelectedApp();
187
-
188
- if ((newApp == null ? void 0 : newApp.key) !== (selectedApp == null ? void 0 : selectedApp.key)) {
189
- changeApp(newApp);
47
+ `;
48
+
49
+ // 新版UI
50
+ const AppsSelect = styled(Select)`
51
+ min-width: 160px;
52
+ height: 28px;
53
+ line-height: 28;
54
+ position: relative;
55
+ top: 50%;
56
+ transform: translateY(-50%);
57
+ .ant-select-selection, .ant-select-selection__rendered {
58
+ line-height: 28px;
59
+ height: 28px;
190
60
  }
191
- }, [items, selectedKey]);
192
61
 
193
- if (!props.theme.compatible) {
194
- if (items == null ? void 0 : items.some(function (item) {
195
- var _item$children;
62
+ .ant-select-selection {
63
+ .hasHeaderTabs & {
64
+ border-radius: 14px;
65
+ font-size: 12px;
66
+ // 去掉默认黑色
67
+ // background: #191D29;
68
+ // border: 1px solid rgba(186,189,197,0.60);
69
+ // color: rgba(255,255,255,.8);
70
+ // 统一为浅色调
71
+ background: #fff !important;
72
+ border-color: #c9d2dd !important;
73
+ color: #8b919e !important;
74
+ }
75
+ // 统一色调
76
+ // .tnt-themeS1.hasHeaderTabs & {
77
+ // /* background: #141825; */
78
+ // /* color: rgba(255,255,255,.85); */
79
+ // background: #fff;
80
+ // border-color: #c9d2dd;
81
+ // color: #8b919e;
82
+ // }
83
+
84
+ // .tnt-themeS3.hasHeaderTabs &{
85
+ // background: ${props => `${props.theme.blueBgColor} !important`}; //#1D4295
86
+ // color: rgba(255,255,255,0.8);
87
+ // border-color: rgba(255,255,255,0.5);
88
+ // }
89
+ }
196
90
 
197
- return (_item$children = item.children) == null ? void 0 : _item$children.length;
198
- })) {
199
- return React.createElement(AppTreeSelect, {
200
- placeholder: "\u8BF7\u9009\u62E9",
201
- showSearch: true,
202
- treeNodeFilterProp: "title",
203
- treeDefaultExpandAll: true,
204
- dropdownClassName: "tnt-layout-header-app-tree-select",
205
- dropdownStyle: {
206
- maxHeight: 560
207
- },
208
- value: (0, _lodash.get)(selectedApp, 'key'),
209
- treeData: (0, _utils.traverseTree)(items, function (item) {
210
- item.title = item.name;
211
- item.value = item.key;
212
- item.selectable = !item.children;
213
- item.disabled = !!item.children;
214
- }),
215
- onChange: function onChange(appKey) {
216
- var findItem;
217
- (0, _utils.traverseTree)(items, function (node) {
218
- if (node.key === appKey) {
219
- findItem = node;
220
- return false;
221
- }
222
- });
223
- changeApp(findItem);
224
- },
225
- style: {
226
- minWidth: 160,
227
- height: 28,
228
- lineHeight: 28
91
+ .ant-select-arrow {
92
+ .hasHeaderTabs & {
93
+ color: #B2BECD;
229
94
  }
230
- });
95
+ .tnt-themeS1 & {
96
+ /* color: rgba(255,255,255,.85); */
97
+ }
98
+ }
99
+
100
+ .tnt-themeS1 & {
101
+ border-radius: 2px;
231
102
  }
232
103
 
233
- return React.createElement(AppsSelect, {
234
- placeholder: "\u8BF7\u9009\u62E9",
235
- showSearch: true,
236
- optionFilterProp: "children",
237
- value: (0, _lodash.get)(selectedApp, 'key'),
238
- onChange: function onChange(appKey) {
239
- changeApp(items.find(function (_ref2) {
240
- var key = _ref2.key;
241
- return key === appKey;
242
- }));
243
- },
244
- style: {
245
- minWidth: 160,
246
- height: 28,
247
- lineHeight: 28
248
- }
249
- }, items.map(function (_ref3) {
250
- var key = _ref3.key,
251
- name = _ref3.name;
252
- return React.createElement(Option, {
253
- key: key,
254
- value: key
255
- }, name);
256
- }));
257
- }
104
+ .isInIframe & {
105
+ margin-left: 20px;
106
+ }
107
+ `;
108
+
109
+ const AppTreeSelect = styled(TreeSelect)`
110
+ min-width: 160px;
111
+ height: 28px;
112
+ line-height: 28;
113
+ position: relative;
114
+ top: 50%;
115
+ transform: translateY(-50%);
116
+ `;
117
+
118
+ const SwitchAppMenu = styled.a`
119
+ display: block;
120
+ color: #666;
121
+ line-height: ${props => `${props.theme.headerHeight}px`};
122
+ font-size: ${props => `${props.theme.size === 'large' ? 16 : 14}px`};
123
+
124
+ .tnt-themeS1 & {
125
+ color: rgba(255,255,255,.85);
126
+ }
127
+ &:hover {
128
+ color: #666;
129
+ }
130
+ i {
131
+ margin-left: 12px;
132
+ }
133
+ `;
134
+
135
+ export default withTheme(
136
+ props => {
137
+ const { selectedKey, items = [], onChange } = props;
138
+ const getInitialSelectedApp = () => {
139
+ const currentAppStore = getCurrentAppStore();
140
+ const findAppByKey = selectedKey => {
141
+ let findApp;
142
+
143
+ traverseTree(items, item => {
144
+ if (item.key === selectedKey) {
145
+ findApp = item;
146
+ return false;
147
+ }
148
+ });
149
+
150
+ return findApp;
151
+ };
152
+ const currentApp = findAppByKey(selectedKey || get(currentAppStore, 'key'));
153
+
154
+ return currentApp || items[0];
155
+ };
156
+ const changeApp = app => {
157
+ setSelectedApp(app);
158
+ setCurrentAppStore(app);
159
+ onChange && onChange(app);
160
+ };
161
+
162
+ const [searchValue, setSearchValue] = useState();
163
+ const [selectedApp, setSelectedApp] = useState(getInitialSelectedApp());
164
+ const Menus = (
165
+ <MenuList selectedKeys={[get(selectedApp, 'key')]}>
166
+ <Menu.Item className="app-search-warp" key="search" disabled>
167
+ <Input
168
+ allowClear
169
+ placeholder="输入关键词搜索"
170
+ value={searchValue}
171
+ onChange={evt => {
172
+ setSearchValue(evt.target.value);
173
+ }}
174
+ />
175
+ </Menu.Item>
176
+ {
177
+ items.filter(({ key, name } = {}) => {
178
+ const regExp = new RegExp(searchValue, 'i');
179
+ if (searchValue) {
180
+ return regExp.test(key) || regExp.test(name);
181
+ }
182
+ return true;
183
+ }).map(item => (
184
+ <Menu.Item
185
+ key={item.key}
186
+ onClick={changeApp.bind(this, item)}
187
+ >
188
+ {item.name}
189
+ </Menu.Item>
190
+ ))
191
+ }
192
+ </MenuList>
193
+ );
194
+
195
+ useEffect(() => {
196
+ const newApp = getInitialSelectedApp();
197
+
198
+ if (newApp?.key !== selectedApp?.key) {
199
+ changeApp(newApp);
200
+ }
201
+ }, [items, selectedKey]);
202
+
203
+ if (!props.theme.compatible) {
204
+ if (items?.some(item => item.children?.length)) {
205
+ return (
206
+ <AppTreeSelect
207
+ placeholder="请选择"
208
+ showSearch
209
+ treeNodeFilterProp="title"
210
+ treeDefaultExpandAll
211
+ dropdownClassName="tnt-layout-header-app-tree-select"
212
+ dropdownStyle={{ maxHeight: 560 }}
213
+ value={get(selectedApp, 'key')}
214
+ treeData={
215
+ traverseTree(items, item => {
216
+ item.title = item.name;
217
+ item.value = item.key;
218
+ item.selectable = !item.children;
219
+ item.disabled = !!item.children;
220
+ })
221
+ }
222
+ onChange={appKey => {
223
+ let findItem;
224
+
225
+ traverseTree(items, node => {
226
+ if (node.key === appKey) {
227
+ findItem = node;
228
+ return false;
229
+ }
230
+ });
231
+ changeApp(findItem);
232
+ }}
233
+ style={{ minWidth: 160, height: 28, lineHeight: 28 }}
234
+ />
235
+ );
236
+ }
258
237
 
259
- return React.createElement(_dropdown["default"], {
260
- overlay: Menus,
261
- trigger: ['click']
262
- }, React.createElement(SwitchAppMenu, null, React.createElement("span", null, (0, _lodash.get)(selectedApp, 'name', '请选择')), React.createElement(_Icon["default"], {
263
- type: "caret-down"
264
- })));
265
- });
238
+ return (
239
+ <AppsSelect
240
+ placeholder="请选择"
241
+ showSearch
242
+ optionFilterProp="children"
243
+ value={get(selectedApp, 'key')}
244
+ onChange={appKey => {
245
+ changeApp(items.find(({ key }) => key === appKey));
246
+ }}
247
+ style={{ minWidth: 160, height: 28, lineHeight: 28 }}
248
+ >
249
+ {
250
+ items.map(({ key, name }) => (
251
+ <Option key={key} value={key}>
252
+ {name}
253
+ </Option>
254
+ ))
255
+ }
256
+ </AppsSelect>
257
+ );
258
+ }
266
259
 
267
- exports["default"] = _default;
260
+ return (
261
+ <Dropdown overlay={Menus} trigger={['click']}>
262
+ <SwitchAppMenu>
263
+ <span>
264
+ {
265
+ get(selectedApp, 'name', '请选择')
266
+ }
267
+ </span>
268
+ <Icon type="caret-down" />
269
+ </SwitchAppMenu>
270
+ </Dropdown>
271
+ );
272
+ }
273
+ );