tntd 1.4.7 → 1.4.10

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 (85) hide show
  1. package/components/DevelopmentLogin/LoginModal.js +2 -2
  2. package/components/Layout/HeaderTabs.js +98 -73
  3. package/dist/1.tntd.js +1 -1
  4. package/dist/stats.json +98 -98
  5. package/dist/tntd.js +1 -1
  6. package/es/DevelopmentLogin/LoginModal.js +2 -2
  7. package/es/Layout/HeaderTabs.js +19 -15
  8. package/lib/ArrayInput/icon.js +31 -27
  9. package/lib/ArrayInput/index.js +298 -211
  10. package/lib/AuthContext.js +13 -2
  11. package/lib/Columns/index.js +100 -71
  12. package/lib/DevelopmentLogin/LoginModal.js +141 -79
  13. package/lib/DevelopmentLogin/index.js +55 -28
  14. package/lib/Ellipsis/Svg/CopySVG.js +71 -23
  15. package/lib/Ellipsis/Svg/TickSVG.js +49 -17
  16. package/lib/Ellipsis/index.js +154 -148
  17. package/lib/Handle/index.js +109 -72
  18. package/lib/Icon/fonts/iconfont.js +43 -1
  19. package/lib/Icon/iconList.js +8 -119
  20. package/lib/Icon/index.js +45 -13
  21. package/lib/Img/Contain.js +81 -49
  22. package/lib/Img/Cover.js +136 -88
  23. package/lib/Img/index.js +89 -36
  24. package/lib/Layout/ActionsContext.js +11 -2
  25. package/lib/Layout/AppList.js +256 -262
  26. package/lib/Layout/Application.js +135 -119
  27. package/lib/Layout/Avatar.js +137 -137
  28. package/lib/Layout/CompatibleLanguage.js +195 -214
  29. package/lib/Layout/EnterpriseLayout/Avatar.js +168 -156
  30. package/lib/Layout/EnterpriseLayout/Language.js +100 -75
  31. package/lib/Layout/EnterpriseLayout/Theme.js +94 -96
  32. package/lib/Layout/EnterpriseLayout/index.js +45 -32
  33. package/lib/Layout/GlobalNavigation/NavigationPopup.js +407 -335
  34. package/lib/Layout/GlobalNavigation/index.js +158 -110
  35. package/lib/Layout/Header.js +116 -165
  36. package/lib/Layout/HeaderActions.js +129 -132
  37. package/lib/Layout/HeaderNavs.js +113 -90
  38. package/lib/Layout/HeaderTabs.js +282 -312
  39. package/lib/Layout/Iconfont.js +15 -2
  40. package/lib/Layout/Language.js +102 -63
  41. package/lib/Layout/Layout.js +261 -272
  42. package/lib/Layout/Logo.js +87 -132
  43. package/lib/Layout/OrgAppList.js +319 -440
  44. package/lib/Layout/SideMenu.js +343 -429
  45. package/lib/Layout/Theme.js +124 -95
  46. package/lib/Layout/checkAuth.js +35 -21
  47. package/lib/Layout/createActions.js +51 -38
  48. package/lib/Layout/images/index.js +41 -33
  49. package/lib/Layout/index.js +161 -110
  50. package/lib/Layout/paaslayout/CompactSideMenu.js +178 -200
  51. package/lib/Layout/paaslayout/Header.js +90 -84
  52. package/lib/Layout/paaslayout/Logo.js +32 -27
  53. package/lib/Layout/paaslayout/SideMenu.js +174 -161
  54. package/lib/Layout/paaslayout/index.js +261 -240
  55. package/lib/Layout/storage.js +78 -20
  56. package/lib/Layout/utils.js +143 -93
  57. package/lib/LoadingButton/index.js +67 -25
  58. package/lib/Modal/index.js +108 -83
  59. package/lib/Page/Box.js +81 -56
  60. package/lib/Page/index.js +173 -151
  61. package/lib/Page/utils.js +30 -12
  62. package/lib/QueryForm/Field/Checkbox.js +33 -11
  63. package/lib/QueryForm/Field/Select.js +99 -63
  64. package/lib/QueryForm/Field/SelectInput.js +114 -69
  65. package/lib/QueryForm/Field/fieldsMap.js +52 -30
  66. package/lib/QueryForm/Field/index.js +158 -76
  67. package/lib/QueryForm/createActions.js +65 -50
  68. package/lib/QueryForm/index.js +383 -304
  69. package/lib/QueryForm/useForm.js +17 -6
  70. package/lib/QueryListScene/List.js +366 -290
  71. package/lib/QueryListScene/QueryForm.js +161 -93
  72. package/lib/QueryListScene/QueryListScene.js +87 -33
  73. package/lib/QueryListScene/Title.js +20 -10
  74. package/lib/QueryListScene/Toolbar.js +31 -8
  75. package/lib/QueryListScene/createActions.js +79 -64
  76. package/lib/QueryListScene/index.js +40 -23
  77. package/lib/QueryListScene/useActions.js +17 -6
  78. package/lib/Select/DropDownWrap.js +124 -60
  79. package/lib/Select/index.js +561 -425
  80. package/lib/Table/ResizableTable/index.js +121 -77
  81. package/lib/Table/index.js +51 -19
  82. package/lib/Title/index.js +52 -34
  83. package/lib/index.js +159 -19
  84. package/lib/locale.js +63 -48
  85. package/package.json +1 -1
@@ -1,323 +1,293 @@
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 0.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
+ language = _ref.language,
104
+ props = _objectWithoutProperties(_ref, ["theme", "className", "tabs", "onTabChange", "onTabSelect", "onTabClose", "appListVisible", "orgListVisible", "orgAppListVisible", "language"]);
105
+
106
+ var _useState = (0, _react.useState)(props.selectedKey || (0, _lodash.get)(tabs, "0.key")),
107
+ _useState2 = _slicedToArray(_useState, 2),
108
+ selectedKey = _useState2[0],
109
+ setSelectedKey = _useState2[1];
110
+
111
+ var _useState3 = (0, _react.useState)(tabs || []),
112
+ _useState4 = _slicedToArray(_useState3, 2),
113
+ tabItems = _useState4[0],
114
+ setTabItems = _useState4[1];
115
+
116
+ var _useState5 = (0, _react.useState)(false),
117
+ _useState6 = _slicedToArray(_useState5, 2),
118
+ arrowVisible = _useState6[0],
119
+ setArrowVisible = _useState6[1];
120
+
121
+ var _useState7 = (0, _react.useState)({
122
+ start: true,
123
+ end: true
124
+ }),
125
+ _useState8 = _slicedToArray(_useState7, 2),
126
+ tabsPositionFlags = _useState8[0],
127
+ setTabsPositionFlags = _useState8[1];
128
+
129
+ var tabsRef = (0, _react.useRef)();
130
+
131
+ var getTabsDom = function getTabsDom() {
132
+ return tabsRef.current;
133
+ };
134
+
135
+ var onTabClick = function onTabClick(tab, index) {
136
+ setSelectedKey(tab.key);
137
+ onTabSelect == null ? void 0 : onTabSelect(tab);
138
+
139
+ if (selectedKey !== tab.key) {
140
+ onTabChange == null ? void 0 : onTabChange(tab);
140
141
  }
142
+ };
143
+
144
+ var closeTabHandle = function closeTabHandle(tab, index, evt) {
145
+ evt.stopPropagation();
146
+ var newTabItems = tabItems.filter(function (_ref2) {
147
+ var key = _ref2.key;
148
+ return key !== tab.key;
149
+ });
150
+ var newSelectedKey = selectedKey;
151
+ setTabItems(newTabItems);
141
152
 
142
- &:hover,
143
- &.active {
144
- .tnt-icon[type=close] {
145
- display: unset;
146
- color: #455064;
147
- // .tnt-themeS1 & {
148
- // color: #455064;
149
- // }
150
- }
153
+ if (tab.key === selectedKey) {
154
+ var _newTabItems$, _newTabItems;
155
+
156
+ newSelectedKey = index === 0 ? (_newTabItems$ = newTabItems[0]) == null ? void 0 : _newTabItems$.key : (_newTabItems = newTabItems[index - 1]) == null ? void 0 : _newTabItems.key;
157
+ setSelectedKey(newSelectedKey);
151
158
  }
152
159
 
153
- &.active {
154
- background: #F1F2F5;
155
- border-radius: 2px 2px 0 0;
156
- color: ${props => props.theme.primaryTextColor};
157
- font-weight: 600;
160
+ onTabClose == null ? void 0 : onTabClose(tab, newTabItems, newTabItems.find(function (_ref3) {
161
+ var key = _ref3.key;
162
+ return key === newSelectedKey;
163
+ }));
164
+ };
165
+
166
+ var onMoveToLeft = function onMoveToLeft() {
167
+ var tabsDom = getTabsDom();
168
+ var parentBBox = tabsDom.parentNode.getBoundingClientRect();
169
+ var parentWidth = parentBBox.width - 32;
170
+ var x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ""));
171
+ var index = Math.ceil(x / 130);
172
+ var trueX = index * 130;
173
+ var newX = Math.min(0, -(trueX - parentWidth));
174
+ tabsDom.style.transform = "translateX(".concat(newX, "px)");
175
+ var width = tabItems.length * 130;
176
+ setTabsPositionFlags({
177
+ start: newX < 0,
178
+ end: Math.abs(newX) < width - parentWidth
179
+ });
180
+ };
181
+
182
+ var onMoveToRight = function onMoveToRight() {
183
+ var tabsDom = getTabsDom();
184
+ var parentBBox = tabsDom.parentNode.getBoundingClientRect();
185
+ var parentWidth = parentBBox.width - 32;
186
+ var width = tabItems.length * 130;
187
+ var x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ""));
188
+ var index = Math.floor(x / 130);
189
+ var trueX = index * 130;
190
+ var newX = Math.max(-(width - parentWidth), -(trueX + parentWidth));
191
+ tabsDom.style.transform = "translateX(".concat(newX, "px)");
192
+ setTabsPositionFlags({
193
+ start: newX < 0,
194
+ end: Math.abs(newX) < width - parentWidth
195
+ });
196
+ };
158
197
 
159
- a {
160
- color: ${props => props.theme.primaryTextColor};
161
- }
198
+ var translateTabsDom = function translateTabsDom(tabs, selectedKey) {
199
+ if (!selectedKey) return;
200
+ var index = tabs.indexOf(tabs.find(function (_ref4) {
201
+ var key = _ref4.key;
202
+ return key === selectedKey;
203
+ }));
204
+ if (index === -1) return;
205
+ var tabsDom = getTabsDom();
206
+ var x = -+tabsDom.style.transform.replace(/[^\d.-]/g, "");
207
+ var bbox = {
208
+ left: index * 130,
209
+ right: (index + 1) * 130
210
+ };
211
+ var parentBBox = tabsDom.parentNode.getBoundingClientRect();
212
+ var parentWidth = parentBBox.width - 36;
213
+ var width = tabItems.length * 130;
214
+ var tailX = x + parentWidth; //当前滑动窗口尾部坐标
215
+
216
+ var newX = -x;
217
+
218
+ if (bbox.left < x) {
219
+ newX = -bbox.left;
220
+ } else if (bbox.right >= tailX) {
221
+ newX = parentWidth - bbox.right;
162
222
  }
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
- );
223
+
224
+ if (newX + width < parentWidth) {
225
+ newX = -(width - parentWidth);
320
226
  }
321
- );
322
227
 
323
- export default HeaderTabs;
228
+ newX = Math.min(0, newX);
229
+ tabsDom.style.transform = "translateX(".concat(newX, "px)");
230
+ setTabsPositionFlags({
231
+ start: newX < 0,
232
+ end: Math.abs(newX) < width - parentWidth
233
+ });
234
+ };
235
+
236
+ (0, _react.useEffect)(function () {
237
+ 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'}] ;
238
+
239
+ setTabItems(tabs);
240
+ }, [tabs, props.selectedKey]);
241
+ (0, _react.useEffect)(function () {}, [props.orgAppListVisible]);
242
+ (0, _react.useEffect)(function () {
243
+ var tabsDom = getTabsDom();
244
+ setArrowVisible(tabsDom.offsetWidth - tabsDom.parentNode.offsetWidth > 0);
245
+ }, [tabItems]);
246
+ (0, _react.useEffect)(function () {
247
+ translateTabsDom(tabItems, selectedKey);
248
+ }, [tabItems, selectedKey, appListVisible, orgListVisible, orgAppListVisible]);
249
+ return React.createElement(TabsContainer, _extends({}, props, {
250
+ className: (0, _classnames["default"])("tnt-layout-header-tabs", _defineProperty({}, className, className))
251
+ }), React.createElement(Tabs, {
252
+ className: "tnt-layout-header-tabs-content",
253
+ ref: tabsRef
254
+ }, tabItems.map(function (tab, index) {
255
+ var _tabItems;
256
+
257
+ return React.createElement(TabItem, {
258
+ key: tab.key,
259
+ theme: theme,
260
+ className: (0, _classnames["default"])({
261
+ active: selectedKey === tab.key,
262
+ activeTabPreSibling: ((_tabItems = tabItems[index + 1]) == null ? void 0 : _tabItems.key) === selectedKey
263
+ }),
264
+ onClick: function onClick() {
265
+ return onTabClick(tab, index);
266
+ }
267
+ }, React.createElement("a", {
268
+ href: tab.key,
269
+ onClick: function onClick(evt) {
270
+ return evt.preventDefault();
271
+ }
272
+ }, {
273
+ cn: tab.name,
274
+ en: tab.enName || tab.name
275
+ }[language || "cn"]), tab.closable !== false && tabItems.length > 1 && React.createElement(_Icon["default"], {
276
+ type: "close",
277
+ onClick: closeTabHandle.bind(null, tab, index)
278
+ }));
279
+ })), arrowVisible && React.createElement("div", {
280
+ className: "tnt-layout-header-tabs-arrows"
281
+ }, React.createElement(_Icon["default"], {
282
+ type: "left",
283
+ onClick: onMoveToLeft,
284
+ disabled: !tabsPositionFlags.start
285
+ }), React.createElement(_Icon["default"], {
286
+ type: "right",
287
+ onClick: onMoveToRight,
288
+ disabled: !tabsPositionFlags.end
289
+ })));
290
+ });
291
+ exports.HeaderTabs = HeaderTabs;
292
+ var _default = HeaderTabs;
293
+ 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;