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
@@ -1,323 +1,289 @@
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
- // }
60
- }
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;
95
- }
1
+ "use strict";
96
2
 
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
- }
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); }
113
4
 
114
- &.active,
115
- &.activeTabPreSibling {
116
- &:after {
117
- display: none;
118
- }
119
- }
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
+ }
120
61
 
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
- // }
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);
140
140
  }
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);
141
151
 
142
- &:hover,
143
- &.active {
144
- .tnt-icon[type=close] {
145
- display: unset;
146
- color: #455064;
147
- // .tnt-themeS1 & {
148
- // color: #455064;
149
- // }
150
- }
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);
151
157
  }
152
158
 
153
- &.active {
154
- background: #F1F2F5;
155
- border-radius: 2px 2px 0 0;
156
- color: ${props => props.theme.primaryTextColor};
157
- font-weight: 600;
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
+ };
158
196
 
159
- a {
160
- color: ${props => props.theme.primaryTextColor};
161
- }
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;
216
+
217
+ if (bbox.left < x) {
218
+ newX = -bbox.left;
219
+ } else if (bbox.right >= tailX) {
220
+ newX = parentWidth - bbox.right;
162
221
  }
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
- );
222
+
223
+ if (newX + width < parentWidth) {
224
+ newX = -(width - parentWidth);
320
225
  }
321
- );
322
226
 
323
- export default HeaderTabs;
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
+ };
234
+
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'}] ;
237
+
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;
255
+
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;
@@ -1,3 +1,16 @@
1
- import Icon from '../Icon';
1
+ "use strict";
2
2
 
3
- export default props => <Icon {...props} />;
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;