tntd 1.4.7 → 1.4.8

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 (79) hide show
  1. package/dist/stats.json +38 -38
  2. package/lib/ArrayInput/icon.js +31 -27
  3. package/lib/ArrayInput/index.js +298 -211
  4. package/lib/AuthContext.js +13 -2
  5. package/lib/Columns/index.js +100 -71
  6. package/lib/DevelopmentLogin/LoginModal.js +141 -79
  7. package/lib/DevelopmentLogin/index.js +55 -28
  8. package/lib/Ellipsis/Svg/CopySVG.js +71 -23
  9. package/lib/Ellipsis/Svg/TickSVG.js +49 -17
  10. package/lib/Ellipsis/index.js +154 -148
  11. package/lib/Handle/index.js +109 -72
  12. package/lib/Icon/fonts/iconfont.js +43 -1
  13. package/lib/Icon/iconList.js +8 -119
  14. package/lib/Icon/index.js +45 -13
  15. package/lib/Img/Contain.js +81 -49
  16. package/lib/Img/Cover.js +136 -88
  17. package/lib/Img/index.js +89 -36
  18. package/lib/Layout/ActionsContext.js +11 -2
  19. package/lib/Layout/AppList.js +256 -262
  20. package/lib/Layout/Application.js +135 -119
  21. package/lib/Layout/Avatar.js +137 -137
  22. package/lib/Layout/CompatibleLanguage.js +195 -214
  23. package/lib/Layout/EnterpriseLayout/Avatar.js +168 -156
  24. package/lib/Layout/EnterpriseLayout/Language.js +100 -75
  25. package/lib/Layout/EnterpriseLayout/Theme.js +94 -96
  26. package/lib/Layout/EnterpriseLayout/index.js +45 -32
  27. package/lib/Layout/GlobalNavigation/NavigationPopup.js +407 -335
  28. package/lib/Layout/GlobalNavigation/index.js +158 -110
  29. package/lib/Layout/Header.js +116 -165
  30. package/lib/Layout/HeaderActions.js +129 -132
  31. package/lib/Layout/HeaderNavs.js +113 -90
  32. package/lib/Layout/HeaderTabs.js +278 -312
  33. package/lib/Layout/Iconfont.js +15 -2
  34. package/lib/Layout/Language.js +102 -63
  35. package/lib/Layout/Layout.js +261 -272
  36. package/lib/Layout/Logo.js +87 -132
  37. package/lib/Layout/OrgAppList.js +319 -440
  38. package/lib/Layout/SideMenu.js +343 -429
  39. package/lib/Layout/Theme.js +124 -95
  40. package/lib/Layout/checkAuth.js +35 -21
  41. package/lib/Layout/createActions.js +51 -38
  42. package/lib/Layout/images/index.js +41 -33
  43. package/lib/Layout/index.js +161 -110
  44. package/lib/Layout/paaslayout/CompactSideMenu.js +178 -200
  45. package/lib/Layout/paaslayout/Header.js +90 -84
  46. package/lib/Layout/paaslayout/Logo.js +32 -27
  47. package/lib/Layout/paaslayout/SideMenu.js +174 -161
  48. package/lib/Layout/paaslayout/index.js +261 -240
  49. package/lib/Layout/storage.js +78 -20
  50. package/lib/Layout/utils.js +143 -93
  51. package/lib/LoadingButton/index.js +67 -25
  52. package/lib/Modal/index.js +108 -83
  53. package/lib/Page/Box.js +81 -56
  54. package/lib/Page/index.js +173 -151
  55. package/lib/Page/utils.js +30 -12
  56. package/lib/QueryForm/Field/Checkbox.js +33 -11
  57. package/lib/QueryForm/Field/Select.js +99 -63
  58. package/lib/QueryForm/Field/SelectInput.js +114 -69
  59. package/lib/QueryForm/Field/fieldsMap.js +52 -30
  60. package/lib/QueryForm/Field/index.js +158 -76
  61. package/lib/QueryForm/createActions.js +65 -50
  62. package/lib/QueryForm/index.js +383 -304
  63. package/lib/QueryForm/useForm.js +17 -6
  64. package/lib/QueryListScene/List.js +366 -290
  65. package/lib/QueryListScene/QueryForm.js +161 -93
  66. package/lib/QueryListScene/QueryListScene.js +87 -33
  67. package/lib/QueryListScene/Title.js +20 -10
  68. package/lib/QueryListScene/Toolbar.js +31 -8
  69. package/lib/QueryListScene/createActions.js +79 -64
  70. package/lib/QueryListScene/index.js +40 -23
  71. package/lib/QueryListScene/useActions.js +17 -6
  72. package/lib/Select/DropDownWrap.js +124 -60
  73. package/lib/Select/index.js +561 -425
  74. package/lib/Table/ResizableTable/index.js +121 -77
  75. package/lib/Table/index.js +51 -19
  76. package/lib/Title/index.js +52 -34
  77. package/lib/index.js +159 -19
  78. package/lib/locale.js +63 -48
  79. package/package.json +1 -1
package/lib/Img/index.js CHANGED
@@ -1,37 +1,90 @@
1
- import { Fragment, useState } from 'react';
2
- import Cover from './Cover';
3
- import Contain from './Contain';
4
-
5
- export default (props) => {
6
- const { type = 'cover', src, shape = 'sharp', title = '', alt = '', className, style, width = 'auto', height = 'auto', errorImgSrc, onError, ...rest } = props || {};
7
- const [src2, setSrc2] = useState(src);
8
-
9
- const handleImgLoadError = () => {
10
- if (errorImgSrc) {
11
- setSrc2(props.errorImgSrc);
12
- }
13
- props.onError && props.onError();
14
- };
15
- const params = {
16
- type, src: src2, shape, title, alt, className, style, width, height, errorImgSrc, ...rest
17
- };
18
-
19
- return (
20
- <Fragment>
21
- {
22
- type === 'contain' &&
23
- <Contain
24
- {...params}
25
- onError={handleImgLoadError}
26
- />
27
- }
28
- {
29
- type === 'cover' &&
30
- <Cover
31
- {...params}
32
- onError={handleImgLoadError}
33
- />
34
- }
35
- </Fragment>
36
- );
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 _Cover = _interopRequireDefault(require("./Cover"));
11
+
12
+ var _Contain = _interopRequireDefault(require("./Contain"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ 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); }
17
+
18
+ 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; }
19
+
20
+ 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; }
21
+
22
+ 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; }
23
+
24
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
25
+
26
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
27
+
28
+ 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; }
29
+
30
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
+
32
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
33
+
34
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
35
+
36
+ var _default = function _default(props) {
37
+ var _ref = props || {},
38
+ _ref$type = _ref.type,
39
+ type = _ref$type === void 0 ? 'cover' : _ref$type,
40
+ src = _ref.src,
41
+ _ref$shape = _ref.shape,
42
+ shape = _ref$shape === void 0 ? 'sharp' : _ref$shape,
43
+ _ref$title = _ref.title,
44
+ title = _ref$title === void 0 ? '' : _ref$title,
45
+ _ref$alt = _ref.alt,
46
+ alt = _ref$alt === void 0 ? '' : _ref$alt,
47
+ className = _ref.className,
48
+ style = _ref.style,
49
+ _ref$width = _ref.width,
50
+ width = _ref$width === void 0 ? 'auto' : _ref$width,
51
+ _ref$height = _ref.height,
52
+ height = _ref$height === void 0 ? 'auto' : _ref$height,
53
+ errorImgSrc = _ref.errorImgSrc,
54
+ onError = _ref.onError,
55
+ rest = _objectWithoutProperties(_ref, ["type", "src", "shape", "title", "alt", "className", "style", "width", "height", "errorImgSrc", "onError"]);
56
+
57
+ var _useState = (0, _react.useState)(src),
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ src2 = _useState2[0],
60
+ setSrc2 = _useState2[1];
61
+
62
+ var handleImgLoadError = function handleImgLoadError() {
63
+ if (errorImgSrc) {
64
+ setSrc2(props.errorImgSrc);
65
+ }
66
+
67
+ props.onError && props.onError();
68
+ };
69
+
70
+ var params = _objectSpread({
71
+ type: type,
72
+ src: src2,
73
+ shape: shape,
74
+ title: title,
75
+ alt: alt,
76
+ className: className,
77
+ style: style,
78
+ width: width,
79
+ height: height,
80
+ errorImgSrc: errorImgSrc
81
+ }, rest);
82
+
83
+ return React.createElement(_react.Fragment, null, type === 'contain' && React.createElement(_Contain["default"], _extends({}, params, {
84
+ onError: handleImgLoadError
85
+ })), type === 'cover' && React.createElement(_Cover["default"], _extends({}, params, {
86
+ onError: handleImgLoadError
87
+ })));
37
88
  };
89
+
90
+ exports["default"] = _default;
@@ -1,4 +1,13 @@
1
- import { createContext } from 'react';
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
+
2
10
  // import createActions from './createActions';
11
+ var _default = (0, _react.createContext)({});
3
12
 
4
- export default createContext({});
13
+ exports["default"] = _default;
@@ -1,273 +1,267 @@
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;
42
- }
43
- }
44
- .isInIframe & {
45
- margin-left: 20px;
46
- }
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;
60
- }
1
+ "use strict";
61
2
 
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
- }
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); }
90
4
 
91
- .ant-select-arrow {
92
- .hasHeaderTabs & {
93
- color: #B2BECD;
94
- }
95
- .tnt-themeS1 & {
96
- /* color: rgba(255,255,255,.85); */
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;
97
129
  }
98
- }
130
+ });
131
+ return findApp;
132
+ };
99
133
 
100
- .tnt-themeS1 & {
101
- border-radius: 2px;
102
- }
134
+ var currentApp = findAppByKey(selectedKey || (0, _lodash.get)(currentAppStore, 'key'));
135
+ return currentApp || items[0];
136
+ };
103
137
 
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);
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);
126
166
  }
127
- &:hover {
128
- color: #666;
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);
129
176
  }
130
- i {
131
- margin-left: 12px;
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);
132
190
  }
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
- }
191
+ }, [items, selectedKey]);
237
192
 
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
- }
193
+ if (!props.theme.compatible) {
194
+ if (items == null ? void 0 : items.some(function (item) {
195
+ var _item$children;
259
196
 
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
- );
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
229
+ }
230
+ });
272
231
  }
273
- );
232
+
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
+ }
258
+
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
+ });
266
+
267
+ exports["default"] = _default;