tntd 1.4.4 → 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 (88) hide show
  1. package/components/Layout/HeaderActions.js +90 -128
  2. package/components/LoadingButton/index.js +11 -15
  3. package/components/QueryListScene/QueryForm.js +7 -4
  4. package/dist/stats.json +4990 -4990
  5. package/dist/tntd.js +1 -1
  6. package/es/Layout/HeaderActions.js +10 -10
  7. package/es/LoadingButton/index.js +20 -10
  8. package/es/QueryListScene/QueryForm.js +6 -3
  9. package/lib/ArrayInput/icon.js +27 -31
  10. package/lib/ArrayInput/index.js +211 -298
  11. package/lib/AuthContext.js +2 -13
  12. package/lib/Columns/index.js +71 -100
  13. package/lib/DevelopmentLogin/LoginModal.js +79 -141
  14. package/lib/DevelopmentLogin/index.js +28 -55
  15. package/lib/Ellipsis/Svg/CopySVG.js +23 -71
  16. package/lib/Ellipsis/Svg/TickSVG.js +17 -49
  17. package/lib/Ellipsis/index.js +148 -154
  18. package/lib/Handle/index.js +72 -109
  19. package/lib/Icon/fonts/iconfont.js +1 -43
  20. package/lib/Icon/iconList.js +119 -8
  21. package/lib/Icon/index.js +13 -45
  22. package/lib/Img/Contain.js +49 -81
  23. package/lib/Img/Cover.js +88 -136
  24. package/lib/Img/index.js +36 -89
  25. package/lib/Layout/ActionsContext.js +2 -11
  26. package/lib/Layout/AppList.js +262 -256
  27. package/lib/Layout/Application.js +119 -135
  28. package/lib/Layout/Avatar.js +137 -137
  29. package/lib/Layout/CompatibleLanguage.js +214 -195
  30. package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
  31. package/lib/Layout/EnterpriseLayout/Language.js +75 -100
  32. package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
  33. package/lib/Layout/EnterpriseLayout/index.js +32 -45
  34. package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
  35. package/lib/Layout/GlobalNavigation/index.js +110 -158
  36. package/lib/Layout/Header.js +165 -116
  37. package/lib/Layout/HeaderActions.js +132 -129
  38. package/lib/Layout/HeaderNavs.js +90 -113
  39. package/lib/Layout/HeaderTabs.js +312 -278
  40. package/lib/Layout/Iconfont.js +2 -15
  41. package/lib/Layout/Language.js +63 -102
  42. package/lib/Layout/Layout.js +272 -261
  43. package/lib/Layout/Logo.js +132 -87
  44. package/lib/Layout/OrgAppList.js +440 -319
  45. package/lib/Layout/SideMenu.js +429 -343
  46. package/lib/Layout/Theme.js +95 -124
  47. package/lib/Layout/checkAuth.js +21 -35
  48. package/lib/Layout/createActions.js +38 -51
  49. package/lib/Layout/images/index.js +33 -41
  50. package/lib/Layout/index.js +110 -161
  51. package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
  52. package/lib/Layout/paaslayout/Header.js +84 -90
  53. package/lib/Layout/paaslayout/Logo.js +27 -32
  54. package/lib/Layout/paaslayout/SideMenu.js +161 -174
  55. package/lib/Layout/paaslayout/index.js +240 -261
  56. package/lib/Layout/storage.js +20 -78
  57. package/lib/Layout/utils.js +93 -143
  58. package/lib/LoadingButton/index.js +25 -57
  59. package/lib/Modal/index.js +83 -108
  60. package/lib/Page/Box.js +56 -81
  61. package/lib/Page/index.js +151 -173
  62. package/lib/Page/utils.js +12 -30
  63. package/lib/QueryForm/Field/Checkbox.js +11 -33
  64. package/lib/QueryForm/Field/Select.js +63 -99
  65. package/lib/QueryForm/Field/SelectInput.js +69 -114
  66. package/lib/QueryForm/Field/fieldsMap.js +30 -52
  67. package/lib/QueryForm/Field/index.js +76 -158
  68. package/lib/QueryForm/createActions.js +50 -65
  69. package/lib/QueryForm/index.js +304 -383
  70. package/lib/QueryForm/useForm.js +6 -17
  71. package/lib/QueryListScene/List.js +290 -366
  72. package/lib/QueryListScene/QueryForm.js +93 -158
  73. package/lib/QueryListScene/QueryListScene.js +33 -87
  74. package/lib/QueryListScene/Title.js +10 -20
  75. package/lib/QueryListScene/Toolbar.js +8 -31
  76. package/lib/QueryListScene/createActions.js +64 -79
  77. package/lib/QueryListScene/index.js +23 -40
  78. package/lib/QueryListScene/useActions.js +6 -17
  79. package/lib/Select/DropDownWrap.js +60 -124
  80. package/lib/Select/index.js +425 -561
  81. package/lib/Table/ResizableTable/index.js +77 -121
  82. package/lib/Table/index.js +19 -51
  83. package/lib/Title/index.js +34 -52
  84. package/lib/index.js +19 -159
  85. package/lib/locale.js +48 -63
  86. package/package.json +1 -1
  87. package/lib/Layout/EnterpriseLayout/Header.js +0 -113
  88. package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
@@ -1,289 +1,323 @@
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"] = exports.HeaderTabs = void 0;
9
-
10
- var _react = require("react");
11
-
12
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
13
-
14
- var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
- var _lodash = require("lodash");
17
-
18
- var _Icon = _interopRequireDefault(require("../Icon"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
23
-
24
- 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; }
25
-
26
- 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); }
27
-
28
- 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; }
29
-
30
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
31
-
32
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
33
-
34
- 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; }
35
-
36
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
-
38
- 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; }
39
-
40
- 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; }
41
-
42
- function _templateObject3() {
43
- var data = _taggedTemplateLiteral(["\n position: relative;\n margin: 0;\n padding: 0 20px 0 10px;\n cursor: pointer;\n display: inline-block;\n line-height: ", ";\n /* transition: background-color .5; */\n width: 130px;\n color: rgba(255,255,255,.6);\n\n .tnt-icon[type=close] {\n display: none;\n position: absolute;\n right: 0;\n top: 0;\n font-size: 10px;\n padding: 0 10px;\n cursor: pointer;\n z-index: 1;\n }\n\n &:not(:last-child):after {\n position: absolute;\n content: \"\";\n right: 0;\n top: 6px;\n height: 24px;\n width: 1px;\n // opacity: .5;\n // background: #fff;\n background: #E1E6EE;\n opacity: .5;\n // .tnt-themeS1 & {\n // background: #E1E6EE;\n // opacity: 1;\n // }\n }\n\n &.active,\n &.activeTabPreSibling {\n &:after {\n display: none;\n }\n }\n\n a {\n font-size: 14px;\n color: ", ";//rgba(255,255,255,.6);\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n transition: none;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n line-height: 36px;\n width: 100%;\n // &:hover {\n // color: rgba(255,255,255,.8);\n // }\n // .tnt-themeS1 & {\n // color: ", ";\n // }\n }\n\n &:hover,\n &.active {\n .tnt-icon[type=close] {\n display: unset;\n color: #455064;\n // .tnt-themeS1 & {\n // color: #455064;\n // }\n }\n }\n\n &.active {\n background: #F1F2F5;\n border-radius: 2px 2px 0 0;\n color: ", ";\n font-weight: 600;\n\n a {\n color: ", ";\n }\n }\n"]);
44
-
45
- _templateObject3 = function _templateObject3() {
46
- return data;
47
- };
48
-
49
- return data;
50
- }
51
-
52
- function _templateObject2() {
53
- var data = _taggedTemplateLiteral(["\n margin: 14px 0 0;\n padding: 0;\n list-style: none;\n text-align: left;\n height: 36px;\n line-height: 36px;\n flex: 1;\n white-space: nowrap;\n padding-right: 40px;\n transition: transform .25s linear;\n position:absolute;\n"]);
54
-
55
- _templateObject2 = function _templateObject2() {
56
- return data;
57
- };
58
-
59
- return data;
60
- }
61
-
62
- function _templateObject() {
63
- var data = _taggedTemplateLiteral(["\n display: flex;\n flex: 1;\n overflow: hidden;\n position: relative;\n margin-right: 12px;\n margin-left: 4px;\n\n .tnt-layout-header-tabs-arrows {\n position: absolute;\n right: 0;\n bottom: 0;\n font-size: 16px;\n line-height: 36px;\n height: 36px;\n background: #fff !important;\n color: rgba(255,255,255,.8) !important;\n .tnt-icon {\n cursor: pointer;\n color: rgba(139,145,158,1);\n &[disabled] {\n color: rgba(139, 145, 158, .5);\n pointer-events: none;\n cursor: not-allowed;\n }\n }\n // background: #191D29;\n // .tnt-icon {\n // cursor: pointer;\n // &[disabled] {\n // color: rgba(139, 145, 158, .5);\n // pointer-events: none;\n // cursor: not-allowed;\n // }\n // }\n // .tnt-themeS1 & {\n // background: #fff;\n // .tnt-icon {\n // color: rgba(139,145,158,1);\n // }\n // }\n // \u591A\u7B7E\u9875\u7684\u7BAD\u5934\u6837\u5F0F\n // .tnt-themeS3 & {\n // background: ", "; //#1D4295;\n // .tnt-icon {\n // color: rgba(255, 255, 255, .5);\n // &[disabled] {\n // color: rgba(139, 145, 158, .5);\n // pointer-events: none;\n // cursor: not-allowed;\n // }\n // }\n // }\n }\n"]);
64
-
65
- _templateObject = function _templateObject() {
66
- return data;
67
- };
68
-
69
- return data;
70
- }
71
-
72
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
73
-
74
- var TabsContainer = _styledComponents["default"].div(_templateObject(), function (props) {
75
- return "".concat(props.theme.blueBgColor);
76
- });
77
-
78
- var Tabs = _styledComponents["default"].ul(_templateObject2());
79
-
80
- var TabItem = _styledComponents["default"].li(_templateObject3(), function (props) {
81
- return props.theme.size === 'large' ? '46px' : '36px';
82
- }, function (props) {
83
- return props.theme.headerActionsColor;
84
- }, function (props) {
85
- return props.theme.headerActionsColor;
86
- }, function (props) {
87
- return props.theme.primaryTextColor;
88
- }, function (props) {
89
- return props.theme.primaryTextColor;
90
- });
91
-
92
- var HeaderTabs = (0, _styledComponents.withTheme)(function (_ref) {
93
- var theme = _ref.theme,
94
- className = _ref.className,
95
- _ref$tabs = _ref.tabs,
96
- tabs = _ref$tabs === void 0 ? [] : _ref$tabs,
97
- onTabChange = _ref.onTabChange,
98
- onTabSelect = _ref.onTabSelect,
99
- onTabClose = _ref.onTabClose,
100
- appListVisible = _ref.appListVisible,
101
- orgListVisible = _ref.orgListVisible,
102
- orgAppListVisible = _ref.orgAppListVisible,
103
- props = _objectWithoutProperties(_ref, ["theme", "className", "tabs", "onTabChange", "onTabSelect", "onTabClose", "appListVisible", "orgListVisible", "orgAppListVisible"]);
104
-
105
- var _useState = (0, _react.useState)(props.selectedKey || (0, _lodash.get)(tabs, '0.key')),
106
- _useState2 = _slicedToArray(_useState, 2),
107
- selectedKey = _useState2[0],
108
- setSelectedKey = _useState2[1];
109
-
110
- var _useState3 = (0, _react.useState)(tabs || []),
111
- _useState4 = _slicedToArray(_useState3, 2),
112
- tabItems = _useState4[0],
113
- setTabItems = _useState4[1];
114
-
115
- var _useState5 = (0, _react.useState)(false),
116
- _useState6 = _slicedToArray(_useState5, 2),
117
- arrowVisible = _useState6[0],
118
- setArrowVisible = _useState6[1];
119
-
120
- var _useState7 = (0, _react.useState)({
121
- start: true,
122
- end: true
123
- }),
124
- _useState8 = _slicedToArray(_useState7, 2),
125
- tabsPositionFlags = _useState8[0],
126
- setTabsPositionFlags = _useState8[1];
127
-
128
- var tabsRef = (0, _react.useRef)();
129
-
130
- var getTabsDom = function getTabsDom() {
131
- return tabsRef.current;
132
- };
133
-
134
- var onTabClick = function onTabClick(tab, index) {
135
- setSelectedKey(tab.key);
136
- onTabSelect == null ? void 0 : onTabSelect(tab);
137
-
138
- if (selectedKey !== tab.key) {
139
- onTabChange == null ? void 0 : onTabChange(tab);
1
+ import { useState, useEffect, useRef } from 'react';
2
+ import styled, { withTheme } from 'styled-components';
3
+ import cn from 'classnames';
4
+ import { get } from 'lodash';
5
+ import Icon from '../Icon';
6
+
7
+ const TabsContainer = styled.div`
8
+ display: flex;
9
+ flex: 1;
10
+ overflow: hidden;
11
+ position: relative;
12
+ margin-right: 12px;
13
+ margin-left: 4px;
14
+
15
+ .tnt-layout-header-tabs-arrows {
16
+ position: absolute;
17
+ right: 0;
18
+ bottom: 0;
19
+ font-size: 16px;
20
+ line-height: 36px;
21
+ height: 36px;
22
+ background: #fff !important;
23
+ color: rgba(255,255,255,.8) !important;
24
+ .tnt-icon {
25
+ cursor: pointer;
26
+ color: rgba(139,145,158,1);
27
+ &[disabled] {
28
+ color: rgba(139, 145, 158, .5);
29
+ pointer-events: none;
30
+ cursor: not-allowed;
31
+ }
32
+ }
33
+ // background: #191D29;
34
+ // .tnt-icon {
35
+ // cursor: pointer;
36
+ // &[disabled] {
37
+ // color: rgba(139, 145, 158, .5);
38
+ // pointer-events: none;
39
+ // cursor: not-allowed;
40
+ // }
41
+ // }
42
+ // .tnt-themeS1 & {
43
+ // background: #fff;
44
+ // .tnt-icon {
45
+ // color: rgba(139,145,158,1);
46
+ // }
47
+ // }
48
+ // 多签页的箭头样式
49
+ // .tnt-themeS3 & {
50
+ // background: ${props => `${props.theme.blueBgColor}`}; //#1D4295;
51
+ // .tnt-icon {
52
+ // color: rgba(255, 255, 255, .5);
53
+ // &[disabled] {
54
+ // color: rgba(139, 145, 158, .5);
55
+ // pointer-events: none;
56
+ // cursor: not-allowed;
57
+ // }
58
+ // }
59
+ // }
140
60
  }
141
- };
142
-
143
- var closeTabHandle = function closeTabHandle(tab, index, evt) {
144
- evt.stopPropagation();
145
- var newTabItems = tabItems.filter(function (_ref2) {
146
- var key = _ref2.key;
147
- return key !== tab.key;
148
- });
149
- var newSelectedKey = selectedKey;
150
- setTabItems(newTabItems);
151
-
152
- if (tab.key === selectedKey) {
153
- var _newTabItems$, _newTabItems;
154
-
155
- newSelectedKey = index === 0 ? (_newTabItems$ = newTabItems[0]) == null ? void 0 : _newTabItems$.key : (_newTabItems = newTabItems[index - 1]) == null ? void 0 : _newTabItems.key;
156
- setSelectedKey(newSelectedKey);
61
+ `;
62
+ const Tabs = styled.ul`
63
+ margin: 14px 0 0;
64
+ padding: 0;
65
+ list-style: none;
66
+ text-align: left;
67
+ height: 36px;
68
+ line-height: 36px;
69
+ flex: 1;
70
+ white-space: nowrap;
71
+ padding-right: 40px;
72
+ transition: transform .25s linear;
73
+ position:absolute;
74
+ `;
75
+ const TabItem = styled.li`
76
+ position: relative;
77
+ margin: 0;
78
+ padding: 0 20px 0 10px;
79
+ cursor: pointer;
80
+ display: inline-block;
81
+ line-height: ${props => props.theme.size === 'large' ? '46px' : '36px'};
82
+ /* transition: background-color .5; */
83
+ width: 130px;
84
+ color: rgba(255,255,255,.6);
85
+
86
+ .tnt-icon[type=close] {
87
+ display: none;
88
+ position: absolute;
89
+ right: 0;
90
+ top: 0;
91
+ font-size: 10px;
92
+ padding: 0 10px;
93
+ cursor: pointer;
94
+ z-index: 1;
157
95
  }
158
96
 
159
- onTabClose == null ? void 0 : onTabClose(tab, newTabItems, newTabItems.find(function (_ref3) {
160
- var key = _ref3.key;
161
- return key === newSelectedKey;
162
- }));
163
- };
164
-
165
- var onMoveToLeft = function onMoveToLeft() {
166
- var tabsDom = getTabsDom();
167
- var parentBBox = tabsDom.parentNode.getBoundingClientRect();
168
- var parentWidth = parentBBox.width - 32;
169
- var x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ''));
170
- var index = Math.ceil(x / 130);
171
- var trueX = index * 130;
172
- var newX = Math.min(0, -(trueX - parentWidth));
173
- tabsDom.style.transform = "translateX(".concat(newX, "px)");
174
- var width = tabItems.length * 130;
175
- setTabsPositionFlags({
176
- start: newX < 0,
177
- end: Math.abs(newX) < width - parentWidth
178
- });
179
- };
180
-
181
- var onMoveToRight = function onMoveToRight() {
182
- var tabsDom = getTabsDom();
183
- var parentBBox = tabsDom.parentNode.getBoundingClientRect();
184
- var parentWidth = parentBBox.width - 32;
185
- var width = tabItems.length * 130;
186
- var x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ''));
187
- var index = Math.floor(x / 130);
188
- var trueX = index * 130;
189
- var newX = Math.max(-(width - parentWidth), -(trueX + parentWidth));
190
- tabsDom.style.transform = "translateX(".concat(newX, "px)");
191
- setTabsPositionFlags({
192
- start: newX < 0,
193
- end: Math.abs(newX) < width - parentWidth
194
- });
195
- };
196
-
197
- var translateTabsDom = function translateTabsDom(tabs, selectedKey) {
198
- if (!selectedKey) return;
199
- var index = tabs.indexOf(tabs.find(function (_ref4) {
200
- var key = _ref4.key;
201
- return key === selectedKey;
202
- }));
203
- if (index === -1) return;
204
- var tabsDom = getTabsDom();
205
- var x = -+tabsDom.style.transform.replace(/[^\d.-]/g, '');
206
- var bbox = {
207
- left: index * 130,
208
- right: (index + 1) * 130
209
- };
210
- var parentBBox = tabsDom.parentNode.getBoundingClientRect();
211
- var parentWidth = parentBBox.width - 36;
212
- var width = tabItems.length * 130;
213
- var tailX = x + parentWidth; //当前滑动窗口尾部坐标
214
-
215
- var newX = -x;
97
+ &:not(:last-child):after {
98
+ position: absolute;
99
+ content: "";
100
+ right: 0;
101
+ top: 6px;
102
+ height: 24px;
103
+ width: 1px;
104
+ // opacity: .5;
105
+ // background: #fff;
106
+ background: #E1E6EE;
107
+ opacity: .5;
108
+ // .tnt-themeS1 & {
109
+ // background: #E1E6EE;
110
+ // opacity: 1;
111
+ // }
112
+ }
216
113
 
217
- if (bbox.left < x) {
218
- newX = -bbox.left;
219
- } else if (bbox.right >= tailX) {
220
- newX = parentWidth - bbox.right;
114
+ &.active,
115
+ &.activeTabPreSibling {
116
+ &:after {
117
+ display: none;
118
+ }
221
119
  }
222
120
 
223
- if (newX + width < parentWidth) {
224
- newX = -(width - parentWidth);
121
+ a {
122
+ font-size: 14px;
123
+ color: ${props=>props.theme.headerActionsColor};//rgba(255,255,255,.6);
124
+ text-rendering: optimizeLegibility;
125
+ -webkit-font-smoothing: antialiased;
126
+ -moz-osx-font-smoothing: grayscale;
127
+ transition: none;
128
+ white-space: nowrap;
129
+ overflow: hidden;
130
+ text-overflow: ellipsis;
131
+ display: inline-block;
132
+ line-height: 36px;
133
+ width: 100%;
134
+ // &:hover {
135
+ // color: rgba(255,255,255,.8);
136
+ // }
137
+ // .tnt-themeS1 & {
138
+ // color: ${props => props.theme.headerActionsColor};
139
+ // }
225
140
  }
226
141
 
227
- newX = Math.min(0, newX);
228
- tabsDom.style.transform = "translateX(".concat(newX, "px)");
229
- setTabsPositionFlags({
230
- start: newX < 0,
231
- end: Math.abs(newX) < width - parentWidth
232
- });
233
- };
142
+ &:hover,
143
+ &.active {
144
+ .tnt-icon[type=close] {
145
+ display: unset;
146
+ color: #455064;
147
+ // .tnt-themeS1 & {
148
+ // color: #455064;
149
+ // }
150
+ }
151
+ }
234
152
 
235
- (0, _react.useEffect)(function () {
236
- setSelectedKey(props.selectedKey || (0, _lodash.get)(tabs, '0.key')); // const t = [{'code':'tagdata','enName':'tagdata','icon':'layer-color','menuName':'打标数据管理打标数据管理打标数据管理','path':'/orion/tag/datalist','key':'tagdata','name':'打标数据管理打标数据管理打标数据管理'},{'code':'taglist','enName':'taglist','icon':'home','menuName':'标签管理','path':'http://baidu.com/orion/tag/list','key':'taglist','name':'标签管理'},{'code':'relation1','enName':'dadicasesearch1','icon':'home','menuName':'案件检索1','path':'/orion/case/relation1','key':'relation1','name':'案件检索1'},{'code':'dadicasesearch-0','enName':'dadicasesearch','icon':'home','menuName':'案件检索-0','path':'/orion/case/relation0','key':'dadicasesearch-0','name':'案件检索-0'},{'code':'dadicasesearch-1','enName':'dadicasesearch','icon':'home','menuName':'案件检索-1','path':'/orion/case/relation1','key':'dadicasesearch-1','name':'案件检索-1'},{'code':'dadicasesearch-2','enName':'dadicasesearch','icon':'home','menuName':'案件检索-2','path':'/orion/case/relation2','key':'dadicasesearch-2','name':'案件检索-2'},{'code':'dadicasesearch-3','enName':'dadicasesearch','icon':'home','menuName':'案件检索-3','path':'/orion/case/relation3','key':'dadicasesearch-3','name':'案件检索-3'},{'code':'dadicasesearch-4','enName':'dadicasesearch','icon':'home','menuName':'案件检索-4','path':'/orion/case/relation4','key':'dadicasesearch-4','name':'案件检索-4'},{'code':'dadicasesearch-5','enName':'dadicasesearch','icon':'home','menuName':'案件检索-5','path':'/orion/case/relation5','key':'dadicasesearch-5','name':'案件检索-5'},{'code':'dadicasesearch-6','enName':'dadicasesearch','icon':'home','menuName':'案件检索-6','path':'/orion/case/relation6','key':'dadicasesearch-6','name':'案件检索-6'},{'code':'dadicasesearch-7','enName':'dadicasesearch','icon':'home','menuName':'案件检索-7','path':'/orion/case/relation7','key':'dadicasesearch-7','name':'案件检索-7'},{'code':'dadicasesearch-8','enName':'dadicasesearch','icon':'home','menuName':'案件检索-8','path':'/orion/case/relation8','key':'dadicasesearch-8','name':'案件检索-8'}] ;
153
+ &.active {
154
+ background: #F1F2F5;
155
+ border-radius: 2px 2px 0 0;
156
+ color: ${props => props.theme.primaryTextColor};
157
+ font-weight: 600;
237
158
 
238
- setTabItems(tabs);
239
- }, [tabs, props.selectedKey]);
240
- (0, _react.useEffect)(function () {}, [props.orgAppListVisible]);
241
- (0, _react.useEffect)(function () {
242
- var tabsDom = getTabsDom();
243
- setArrowVisible(tabsDom.offsetWidth - tabsDom.parentNode.offsetWidth > 0);
244
- }, [tabItems]);
245
- (0, _react.useEffect)(function () {
246
- translateTabsDom(tabItems, selectedKey);
247
- }, [tabItems, selectedKey, appListVisible, orgListVisible, orgAppListVisible]);
248
- return React.createElement(TabsContainer, _extends({}, props, {
249
- className: (0, _classnames["default"])('tnt-layout-header-tabs', _defineProperty({}, className, className))
250
- }), React.createElement(Tabs, {
251
- className: "tnt-layout-header-tabs-content",
252
- ref: tabsRef
253
- }, tabItems.map(function (tab, index) {
254
- var _tabItems;
159
+ a {
160
+ color: ${props => props.theme.primaryTextColor};
161
+ }
162
+ }
163
+ `;
164
+
165
+ export const HeaderTabs = withTheme(
166
+ ({ theme, className, tabs = [], onTabChange, onTabSelect, onTabClose, appListVisible, orgListVisible, orgAppListVisible, ...props }) => {
167
+ const [selectedKey, setSelectedKey] = useState(props.selectedKey || get(tabs, '0.key'));
168
+ const [tabItems, setTabItems] = useState(tabs || []);
169
+ const [arrowVisible, setArrowVisible] = useState(false);
170
+ const [tabsPositionFlags, setTabsPositionFlags] = useState({ start: true, end: true });
171
+ const tabsRef = useRef();
172
+
173
+ const getTabsDom = () => tabsRef.current;
174
+
175
+ const onTabClick = (tab,index) => {
176
+
177
+ setSelectedKey(tab.key);
178
+ onTabSelect?.(tab);
179
+
180
+ if (selectedKey !== tab.key) {
181
+ onTabChange?.(tab);
182
+ }
183
+ };
184
+ const closeTabHandle = (tab, index, evt) => {
185
+ evt.stopPropagation();
186
+ const newTabItems = tabItems.filter(({ key }) => key !== tab.key);
187
+ let newSelectedKey = selectedKey;
188
+
189
+ setTabItems(newTabItems);
190
+ if (tab.key === selectedKey) {
191
+ newSelectedKey = index === 0 ? newTabItems[0]?.key : newTabItems[index - 1]?.key;
192
+ setSelectedKey(newSelectedKey);
193
+ }
194
+ onTabClose?.(tab, newTabItems, newTabItems.find(({ key }) => key === newSelectedKey));
195
+ };
196
+ const onMoveToLeft = () => {
197
+ const tabsDom = getTabsDom();
198
+ const parentBBox = tabsDom.parentNode.getBoundingClientRect();
199
+ const parentWidth = parentBBox.width - 32;
200
+ let x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ''));
201
+ const index = Math.ceil(x/130);
202
+ const trueX = index*130;
203
+ let newX = Math.min(0,-(trueX - parentWidth));
204
+ tabsDom.style.transform = `translateX(${newX}px)`;
205
+
206
+ const width = tabItems.length*130;
207
+ setTabsPositionFlags({
208
+ start: newX<0,
209
+ end: Math.abs(newX)<(width-parentWidth)
210
+ });
211
+ };
212
+ const onMoveToRight = () => {
213
+ const tabsDom = getTabsDom();
214
+ const parentBBox = tabsDom.parentNode.getBoundingClientRect();
215
+ const parentWidth = parentBBox.width - 32;
216
+ const width = tabItems.length*130;
217
+
218
+ let x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ''));
219
+ const index = Math.floor(x/130);
220
+ const trueX = index*130;
221
+ let newX = Math.max(-(width-parentWidth),-(trueX + parentWidth));
222
+ tabsDom.style.transform = `translateX(${newX}px)`;
223
+
224
+ setTabsPositionFlags({
225
+ start: newX<0,
226
+ end: Math.abs(newX)<(width-parentWidth)
227
+ });
228
+ };
229
+
230
+ const translateTabsDom = (tabs, selectedKey) => {
231
+ if(!selectedKey)return;
232
+ const index = tabs.indexOf(tabs.find(({ key }) => key === selectedKey));
233
+ if(index===-1) return;
234
+ const tabsDom = getTabsDom();
235
+ let x = -(+tabsDom.style.transform.replace(/[^\d.-]/g, ''));
236
+ const bbox = {
237
+ left:index*130,
238
+ right:(index+1)*130
239
+ };
240
+ const parentBBox = tabsDom.parentNode.getBoundingClientRect();
241
+ const parentWidth = parentBBox.width - 36;
242
+ const width = tabItems.length*130;
243
+
244
+ let tailX = x + parentWidth;//当前滑动窗口尾部坐标
245
+ let newX = -x;
246
+ if(bbox.left<x){
247
+ newX = -bbox.left;
248
+ }else if(bbox.right>=tailX){
249
+ newX = parentWidth - bbox.right;
250
+ }
251
+ if(newX+width<parentWidth){
252
+ newX = -(width - parentWidth);
253
+ }
254
+ newX = Math.min(0,newX);
255
+ tabsDom.style.transform = `translateX(${newX}px)`;
256
+
257
+ setTabsPositionFlags({
258
+ start: newX<0,
259
+ end: Math.abs(newX)<(width-parentWidth)
260
+ });
261
+ };
262
+
263
+ useEffect(() => {
264
+ setSelectedKey(props.selectedKey || get(tabs, '0.key'));
265
+ // const t = [{'code':'tagdata','enName':'tagdata','icon':'layer-color','menuName':'打标数据管理打标数据管理打标数据管理','path':'/orion/tag/datalist','key':'tagdata','name':'打标数据管理打标数据管理打标数据管理'},{'code':'taglist','enName':'taglist','icon':'home','menuName':'标签管理','path':'http://baidu.com/orion/tag/list','key':'taglist','name':'标签管理'},{'code':'relation1','enName':'dadicasesearch1','icon':'home','menuName':'案件检索1','path':'/orion/case/relation1','key':'relation1','name':'案件检索1'},{'code':'dadicasesearch-0','enName':'dadicasesearch','icon':'home','menuName':'案件检索-0','path':'/orion/case/relation0','key':'dadicasesearch-0','name':'案件检索-0'},{'code':'dadicasesearch-1','enName':'dadicasesearch','icon':'home','menuName':'案件检索-1','path':'/orion/case/relation1','key':'dadicasesearch-1','name':'案件检索-1'},{'code':'dadicasesearch-2','enName':'dadicasesearch','icon':'home','menuName':'案件检索-2','path':'/orion/case/relation2','key':'dadicasesearch-2','name':'案件检索-2'},{'code':'dadicasesearch-3','enName':'dadicasesearch','icon':'home','menuName':'案件检索-3','path':'/orion/case/relation3','key':'dadicasesearch-3','name':'案件检索-3'},{'code':'dadicasesearch-4','enName':'dadicasesearch','icon':'home','menuName':'案件检索-4','path':'/orion/case/relation4','key':'dadicasesearch-4','name':'案件检索-4'},{'code':'dadicasesearch-5','enName':'dadicasesearch','icon':'home','menuName':'案件检索-5','path':'/orion/case/relation5','key':'dadicasesearch-5','name':'案件检索-5'},{'code':'dadicasesearch-6','enName':'dadicasesearch','icon':'home','menuName':'案件检索-6','path':'/orion/case/relation6','key':'dadicasesearch-6','name':'案件检索-6'},{'code':'dadicasesearch-7','enName':'dadicasesearch','icon':'home','menuName':'案件检索-7','path':'/orion/case/relation7','key':'dadicasesearch-7','name':'案件检索-7'},{'code':'dadicasesearch-8','enName':'dadicasesearch','icon':'home','menuName':'案件检索-8','path':'/orion/case/relation8','key':'dadicasesearch-8','name':'案件检索-8'}] ;
266
+ setTabItems(tabs);
267
+ }, [tabs, props.selectedKey]);
268
+
269
+ useEffect(()=>{
270
+
271
+ },[props.orgAppListVisible]);
272
+
273
+ useEffect(() => {
274
+ const tabsDom = getTabsDom();
275
+
276
+ setArrowVisible(tabsDom.offsetWidth - tabsDom.parentNode.offsetWidth > 0);
277
+ }, [tabItems]);
278
+
279
+ useEffect(() => {
280
+ translateTabsDom(tabItems, selectedKey);
281
+ }, [tabItems, selectedKey, appListVisible, orgListVisible, orgAppListVisible]);
282
+
283
+ return (
284
+ <TabsContainer
285
+ {...props}
286
+ className={cn('tnt-layout-header-tabs', { [className]: className })}
287
+ >
288
+ <Tabs className="tnt-layout-header-tabs-content" ref={tabsRef}>
289
+ {
290
+ tabItems.map((tab, index) => (
291
+ <TabItem
292
+ key={tab.key}
293
+ theme={theme}
294
+ className={cn({
295
+ active: selectedKey === tab.key,
296
+ activeTabPreSibling: tabItems[index + 1]?.key === selectedKey
297
+ })}
298
+ onClick={() => onTabClick(tab,index)}
299
+ >
300
+ <a href={tab.key} onClick={evt => evt.preventDefault()}>{tab.name}</a>
301
+ {
302
+ tabItems.length > 1 && (
303
+ <Icon type="close" onClick={closeTabHandle.bind(null, tab, index)} />
304
+ )
305
+ }
306
+ </TabItem>
307
+ ))
308
+ }
309
+ </Tabs>
310
+ {
311
+ arrowVisible && (
312
+ <div className="tnt-layout-header-tabs-arrows">
313
+ <Icon type="left" onClick={onMoveToLeft} disabled={!tabsPositionFlags.start} />
314
+ <Icon type="right" onClick={onMoveToRight} disabled={!tabsPositionFlags.end} />
315
+ </div>
316
+ )
317
+ }
318
+ </TabsContainer>
319
+ );
320
+ }
321
+ );
255
322
 
256
- return React.createElement(TabItem, {
257
- key: tab.key,
258
- theme: theme,
259
- className: (0, _classnames["default"])({
260
- active: selectedKey === tab.key,
261
- activeTabPreSibling: ((_tabItems = tabItems[index + 1]) == null ? void 0 : _tabItems.key) === selectedKey
262
- }),
263
- onClick: function onClick() {
264
- return onTabClick(tab, index);
265
- }
266
- }, React.createElement("a", {
267
- href: tab.key,
268
- onClick: function onClick(evt) {
269
- return evt.preventDefault();
270
- }
271
- }, tab.name), tabItems.length > 1 && React.createElement(_Icon["default"], {
272
- type: "close",
273
- onClick: closeTabHandle.bind(null, tab, index)
274
- }));
275
- })), arrowVisible && React.createElement("div", {
276
- className: "tnt-layout-header-tabs-arrows"
277
- }, React.createElement(_Icon["default"], {
278
- type: "left",
279
- onClick: onMoveToLeft,
280
- disabled: !tabsPositionFlags.start
281
- }), React.createElement(_Icon["default"], {
282
- type: "right",
283
- onClick: onMoveToRight,
284
- disabled: !tabsPositionFlags.end
285
- })));
286
- });
287
- exports.HeaderTabs = HeaderTabs;
288
- var _default = HeaderTabs;
289
- exports["default"] = _default;
323
+ export default HeaderTabs;
@@ -1,16 +1,3 @@
1
- "use strict";
1
+ import Icon from '../Icon';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _Icon = _interopRequireDefault(require("../Icon"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
- var _default = function _default(props) {
13
- return React.createElement(_Icon["default"], props);
14
- };
15
-
16
- exports["default"] = _default;
3
+ export default props => <Icon {...props} />;