tntd 1.4.6 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/components/Layout/HeaderActions.js +90 -128
  2. package/components/LoadingButton/index.js +11 -15
  3. package/dist/stats.json +4958 -4958
  4. package/dist/tntd.js +1 -1
  5. package/es/Layout/HeaderActions.js +10 -10
  6. package/es/LoadingButton/index.js +20 -10
  7. package/lib/ArrayInput/icon.js +27 -31
  8. package/lib/ArrayInput/index.js +211 -298
  9. package/lib/AuthContext.js +2 -13
  10. package/lib/Columns/index.js +71 -100
  11. package/lib/DevelopmentLogin/LoginModal.js +79 -141
  12. package/lib/DevelopmentLogin/index.js +28 -55
  13. package/lib/Ellipsis/Svg/CopySVG.js +23 -71
  14. package/lib/Ellipsis/Svg/TickSVG.js +17 -49
  15. package/lib/Ellipsis/index.js +148 -154
  16. package/lib/Handle/index.js +72 -109
  17. package/lib/Icon/fonts/iconfont.js +1 -43
  18. package/lib/Icon/iconList.js +119 -8
  19. package/lib/Icon/index.js +13 -45
  20. package/lib/Img/Contain.js +49 -81
  21. package/lib/Img/Cover.js +88 -136
  22. package/lib/Img/index.js +36 -89
  23. package/lib/Layout/ActionsContext.js +2 -11
  24. package/lib/Layout/AppList.js +262 -256
  25. package/lib/Layout/Application.js +119 -135
  26. package/lib/Layout/Avatar.js +137 -137
  27. package/lib/Layout/CompatibleLanguage.js +214 -195
  28. package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
  29. package/lib/Layout/EnterpriseLayout/Language.js +75 -100
  30. package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
  31. package/lib/Layout/EnterpriseLayout/index.js +32 -45
  32. package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
  33. package/lib/Layout/GlobalNavigation/index.js +110 -158
  34. package/lib/Layout/Header.js +165 -116
  35. package/lib/Layout/HeaderActions.js +132 -129
  36. package/lib/Layout/HeaderNavs.js +90 -113
  37. package/lib/Layout/HeaderTabs.js +312 -278
  38. package/lib/Layout/Iconfont.js +2 -15
  39. package/lib/Layout/Language.js +63 -102
  40. package/lib/Layout/Layout.js +272 -261
  41. package/lib/Layout/Logo.js +132 -87
  42. package/lib/Layout/OrgAppList.js +440 -319
  43. package/lib/Layout/SideMenu.js +429 -343
  44. package/lib/Layout/Theme.js +95 -124
  45. package/lib/Layout/checkAuth.js +21 -35
  46. package/lib/Layout/createActions.js +38 -51
  47. package/lib/Layout/images/index.js +33 -41
  48. package/lib/Layout/index.js +110 -161
  49. package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
  50. package/lib/Layout/paaslayout/Header.js +84 -90
  51. package/lib/Layout/paaslayout/Logo.js +27 -32
  52. package/lib/Layout/paaslayout/SideMenu.js +161 -174
  53. package/lib/Layout/paaslayout/index.js +240 -261
  54. package/lib/Layout/storage.js +20 -78
  55. package/lib/Layout/utils.js +93 -143
  56. package/lib/LoadingButton/index.js +25 -57
  57. package/lib/Modal/index.js +83 -108
  58. package/lib/Page/Box.js +56 -81
  59. package/lib/Page/index.js +151 -173
  60. package/lib/Page/utils.js +12 -30
  61. package/lib/QueryForm/Field/Checkbox.js +11 -33
  62. package/lib/QueryForm/Field/Select.js +63 -99
  63. package/lib/QueryForm/Field/SelectInput.js +69 -114
  64. package/lib/QueryForm/Field/fieldsMap.js +30 -52
  65. package/lib/QueryForm/Field/index.js +76 -158
  66. package/lib/QueryForm/createActions.js +50 -65
  67. package/lib/QueryForm/index.js +304 -383
  68. package/lib/QueryForm/useForm.js +6 -17
  69. package/lib/QueryListScene/List.js +290 -366
  70. package/lib/QueryListScene/QueryForm.js +93 -161
  71. package/lib/QueryListScene/QueryListScene.js +33 -87
  72. package/lib/QueryListScene/Title.js +10 -20
  73. package/lib/QueryListScene/Toolbar.js +8 -31
  74. package/lib/QueryListScene/createActions.js +64 -79
  75. package/lib/QueryListScene/index.js +23 -40
  76. package/lib/QueryListScene/useActions.js +6 -17
  77. package/lib/Select/DropDownWrap.js +60 -124
  78. package/lib/Select/index.js +425 -561
  79. package/lib/Table/ResizableTable/index.js +77 -121
  80. package/lib/Table/index.js +19 -51
  81. package/lib/Title/index.js +34 -52
  82. package/lib/index.js +19 -159
  83. package/lib/locale.js +48 -63
  84. package/package.json +1 -1
  85. package/lib/Layout/EnterpriseLayout/Header.js +0 -113
  86. package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
@@ -1,133 +1,136 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- require("antd/lib/divider/style");
11
-
12
- var _divider = _interopRequireDefault(require("antd/lib/divider"));
13
-
14
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
15
-
16
- var _GlobalNavigation = _interopRequireDefault(require("./GlobalNavigation"));
17
-
18
- var _Language = _interopRequireDefault(require("./Language"));
19
-
20
- var _Theme = _interopRequireDefault(require("./Theme"));
21
-
22
- var _CompatibleLanguage = _interopRequireDefault(require("./CompatibleLanguage"));
23
-
24
- var _Application = _interopRequireDefault(require("./Application"));
25
-
26
- var _Avatar = _interopRequireDefault(require("./Avatar"));
27
-
28
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
29
-
30
- 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; }
31
-
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
33
-
34
- 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; }
35
-
36
- 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; }
37
-
38
- function _templateObject() {
39
- var data = _taggedTemplateLiteral(["\n list-style: none;\n display: inline-block;\n line-height: ", ";\n margin: 0 0 0 20px;\n .hasHeaderTabs & {\n margin: 0;\n }\n padding: 0;\n white-space: nowrap;\n\n .isInIframe & {\n display: none;\n }\n\n & > li {\n height: 100%;\n display: inline-block;\n vertical-align: top;\n cursor: pointer;\n font-size: 20px;\n margin: 0 7.5px;\n color: ", ";\n .large-size & {\n margin: 0 10px;\n }\n .tnt-themeS1 & {\n /* color: rgba(255,255,255,.85); */\n }\n &:last-of-type {\n margin-right: 0;\n }\n .hasHeaderTabs &{\n color: #455064;\n }\n // \u5220\u9664\u8272\u7CFB\u533A\u5206 \u7EDF\u4E00\u8272\u8C03\n // .hasHeaderTabs:not(.tnt-themeS1) & {\n // color: rgba(255,255,255,.8);\n // }\n .hasHeaderTabs:not(.tnt-themeS1) & {\n color: #455064 !important;\n }\n }\n"]);
40
-
41
- _templateObject = function _templateObject() {
42
- return data;
43
- };
44
-
45
- return data;
46
- }
47
-
48
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
49
-
50
- var Actions = _styledComponents["default"].ul(_templateObject(), function (props) {
51
- return "".concat(props.theme.headerHeight, "px");
52
- }, function (props) {
53
- return "".concat(props.theme.headerActionsColor);
54
- });
55
-
56
- var _default = (0, _styledComponents.withTheme)(function (props) {
57
- var _props$config = props.config;
58
- _props$config = _props$config === void 0 ? {} : _props$config;
59
-
60
- var _props$config$theme = _props$config.theme,
61
- theme = _props$config$theme === void 0 ? true : _props$config$theme,
62
- _props$config$avatar = _props$config.avatar,
63
- avatar = _props$config$avatar === void 0 ? true : _props$config$avatar,
64
- _props$config$languag = _props$config.language,
65
- language = _props$config$languag === void 0 ? true : _props$config$languag,
66
- _props$config$applica = _props$config.application,
67
- application = _props$config$applica === void 0 ? false : _props$config$applica,
68
- _props$config$globalN = _props$config.globalNavigation,
69
- globalNavigation = _props$config$globalN === void 0 ? false : _props$config$globalN,
70
- compatible = props.theme.compatible,
71
- _props$userInfo = props.userInfo,
72
- userInfo = _props$userInfo === void 0 ? {} : _props$userInfo,
73
- menus = props.menus,
74
- apps = props.apps,
75
- extraActions = props.extraActions,
76
- headerRef = props.headerRef,
77
- onLanguageChange = props.onLanguageChange,
78
- onThemeChange = props.onThemeChange,
79
- onApplicationChange = props.onApplicationChange,
80
- onAppChange = props.onAppChange,
81
- onCollapseChange = props.onCollapseChange,
82
- onPersonalSetting = props.onPersonalSetting,
83
- onChangePassword = props.onChangePassword,
84
- onLogout = props.onLogout,
85
- onLogoClick = props.onLogoClick,
86
- AvatarCustom = props.AvatarCustom,
87
- rest = _objectWithoutProperties(props, ["config", "theme", "userInfo", "menus", "apps", "extraActions", "headerRef", "onLanguageChange", "onThemeChange", "onApplicationChange", "onAppChange", "onCollapseChange", "onPersonalSetting", "onChangePassword", "onLogout", "onLogoClick", "AvatarCustom"]);
1
+ import styled, { withTheme } from "styled-components";
2
+ import { Divider } from "antd";
3
+ import GlobalNavigation from "./GlobalNavigation";
4
+ import Language from "./Language";
5
+ import Theme from "./Theme";
6
+ import LanguageTheme from "./CompatibleLanguage";
7
+ import Application from "./Application";
8
+ import Avatar from "./Avatar";
9
+
10
+ const Actions = styled.ul`
11
+ list-style: none;
12
+ display: inline-block;
13
+ line-height: ${(props) => `${props.theme.headerHeight}px`};
14
+ margin: 0 0 0 20px;
15
+ .hasHeaderTabs & {
16
+ margin: 0;
17
+ }
18
+ padding: 0;
19
+ white-space: nowrap;
88
20
 
89
- return React.createElement(Actions, rest, extraActions, globalNavigation && React.createElement(_GlobalNavigation["default"], {
90
- headerRef: headerRef,
91
- menus: menus
92
- }), !AvatarCustom && (!compatible ? React.createElement(React.Fragment, null, language && React.createElement(_Language["default"], {
93
- language: userInfo.lang,
94
- onChange: onLanguageChange
95
- }), theme && React.createElement(_Theme["default"], {
96
- theme: userInfo.theme,
97
- onChange: onThemeChange
98
- })) : React.createElement(_CompatibleLanguage["default"], {
99
- config: props.config,
100
- language: userInfo.lang,
101
- theme: userInfo.theme,
102
- onLanguageChange: onLanguageChange,
103
- onThemeChange: onThemeChange
104
- })), application && React.createElement(_Application["default"], {
105
- language: userInfo.lang,
106
- apps: apps,
107
- onChange: onApplicationChange
108
- }), avatar && React.createElement(React.Fragment, null, React.createElement(_divider["default"], {
109
- type: "vertical"
110
- }), AvatarCustom ? React.createElement(AvatarCustom, {
111
- userInfo: userInfo,
112
- onPersonalSetting: onPersonalSetting,
113
- onChangePassword: onChangePassword,
114
- onLogout: onLogout,
115
- onThemeChange: onThemeChange,
116
- config: {
117
- theme: theme,
118
- language: language
21
+ .isInIframe & {
22
+ display: none;
119
23
  }
120
- }) : React.createElement(_Avatar["default"], {
121
- userInfo: userInfo,
122
- onPersonalSetting: onPersonalSetting,
123
- onChangePassword: onChangePassword,
124
- onLogout: onLogout,
125
- onThemeChange: onThemeChange,
126
- config: {
127
- theme: theme,
128
- language: language
24
+
25
+ & > li {
26
+ height: 100%;
27
+ display: inline-block;
28
+ vertical-align: top;
29
+ cursor: pointer;
30
+ font-size: 20px;
31
+ margin: 0 7.5px;
32
+ color: ${(props) => `${props.theme.headerActionsColor}`};
33
+ .large-size & {
34
+ margin: 0 10px;
35
+ }
36
+ .tnt-themeS1 & {
37
+ /* color: rgba(255,255,255,.85); */
38
+ }
39
+ &:last-of-type {
40
+ margin-right: 0;
41
+ }
42
+ .hasHeaderTabs & {
43
+ color: #455064;
44
+ }
45
+ // 删除色系区分 统一色调
46
+ // .hasHeaderTabs:not(.tnt-themeS1) & {
47
+ // color: rgba(255,255,255,.8);
48
+ // }
49
+ .hasHeaderTabs:not(.tnt-themeS1) & {
50
+ color: #455064 !important;
51
+ }
129
52
  }
130
- })));
53
+ `;
54
+
55
+ export default withTheme((props) => {
56
+ const {
57
+ config: {
58
+ theme = true,
59
+ avatar = true,
60
+ language = true,
61
+ application = false,
62
+ globalNavigation = false,
63
+ } = {},
64
+ theme: { compatible },
65
+ userInfo = {},
66
+ menus,
67
+ apps,
68
+ extraActions,
69
+ headerRef,
70
+ onLanguageChange,
71
+ onThemeChange,
72
+ onApplicationChange,
73
+ onAppChange,
74
+ onCollapseChange,
75
+ onPersonalSetting,
76
+ onChangePassword,
77
+ onLogout,
78
+ onLogoClick,
79
+ AvatarCustom,
80
+ ...rest
81
+ } = props;
82
+
83
+ return (
84
+ <Actions {...rest}>
85
+ {extraActions}
86
+ {globalNavigation && <GlobalNavigation headerRef={headerRef} menus={menus} />}
87
+ {!compatible ? (
88
+ <>
89
+ {language && <Language language={userInfo.lang} onChange={onLanguageChange} />}
90
+ {theme && <Theme theme={userInfo.theme} onChange={onThemeChange} />}
91
+ </>
92
+ ) : (
93
+ <LanguageTheme
94
+ config={props.config}
95
+ language={userInfo.lang}
96
+ theme={userInfo.theme}
97
+ onLanguageChange={onLanguageChange}
98
+ onThemeChange={onThemeChange}
99
+ />
100
+ )}
101
+ {application && (
102
+ <Application language={userInfo.lang} apps={apps} onChange={onApplicationChange} />
103
+ )}
104
+ {avatar && (
105
+ <>
106
+ <Divider type="vertical" />
107
+ {AvatarCustom ? (
108
+ <AvatarCustom
109
+ userInfo={userInfo}
110
+ onPersonalSetting={onPersonalSetting}
111
+ onChangePassword={onChangePassword}
112
+ onLogout={onLogout}
113
+ onThemeChange={onThemeChange}
114
+ config={{
115
+ theme,
116
+ language,
117
+ }}
118
+ />
119
+ ) : (
120
+ <Avatar
121
+ userInfo={userInfo}
122
+ onPersonalSetting={onPersonalSetting}
123
+ onChangePassword={onChangePassword}
124
+ onLogout={onLogout}
125
+ onThemeChange={onThemeChange}
126
+ config={{
127
+ theme,
128
+ language,
129
+ }}
130
+ />
131
+ )}
132
+ </>
133
+ )}
134
+ </Actions>
135
+ );
131
136
  });
132
-
133
- exports["default"] = _default;
@@ -1,116 +1,93 @@
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.HeaderNavs = 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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
21
-
22
- 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; }
23
-
24
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
25
-
26
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
27
-
28
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
29
-
30
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
-
32
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
33
-
34
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
35
-
36
- function _templateObject2() {
37
- var data = _taggedTemplateLiteral(["\n position: relative;\n margin: 0;\n padding: 0 20px;\n cursor: pointer;\n display: inline-block;\n line-height: ", ";\n transition: background-color .5;\n\n a {\n font-size: 14px;\n color: ", ";\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n .tnt-themeS1 & {\n color: rgba(255,255,255,.8);\n }\n }\n\n &:hover, &.active {\n a {\n color: ", ";\n .tnt-themeS1 & {\n color: #418AFF;\n }\n }\n }\n &.active {\n &:after {\n position: absolute;\n left: 0;\n bottom: 0;\n width: 100%;\n height: 3px;\n background: ", ";\n display: inline-block;\n content: \"\";\n .tnt-themeS1 & {\n background: #418AFF;\n }\n }\n }\n"]);
38
-
39
- _templateObject2 = function _templateObject2() {
40
- return data;
41
- };
42
-
43
- return data;
44
- }
45
-
46
- function _templateObject() {
47
- var data = _taggedTemplateLiteral(["\n margin: 0;\n padding: 0;\n list-style: none;\n text-align: right;\n"]);
48
-
49
- _templateObject = function _templateObject() {
50
- return data;
51
- };
52
-
53
- return data;
54
- }
55
-
56
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
57
-
58
- var Navs = _styledComponents["default"].ul(_templateObject());
59
-
60
- var NavItem = _styledComponents["default"].li(_templateObject2(), function (props) {
61
- return props.theme.size === 'large' ? '60px' : '50px';
62
- }, function (props) {
63
- return props.theme.secondaryTextColor;
64
- }, function (props) {
65
- return props.theme.primaryColor;
66
- }, function (props) {
67
- return props.theme.primaryColor;
68
- });
69
-
70
- var HeaderNavs = (0, _styledComponents.withTheme)(function (_ref) {
71
- var theme = _ref.theme,
72
- _ref$navs = _ref.navs,
73
- navs = _ref$navs === void 0 ? [] : _ref$navs,
74
- onChange = _ref.onChange,
75
- onSelect = _ref.onSelect,
76
- props = _objectWithoutProperties(_ref, ["theme", "navs", "onChange", "onSelect"]);
77
-
78
- var _useState = (0, _react.useState)(props.selectedKey || (0, _lodash.get)(navs, '0.key')),
79
- _useState2 = _slicedToArray(_useState, 2),
80
- selectedKey = _useState2[0],
81
- setSelectedKey = _useState2[1];
82
-
83
- var onClickNav = function onClickNav(nav) {
84
- setSelectedKey(nav.key);
85
- onSelect && onSelect(nav);
1
+ import { useState, useEffect } from 'react';
2
+ import styled, { withTheme } from 'styled-components';
3
+ import cn from 'classnames';
4
+ import { get } from 'lodash';
5
+
6
+ const Navs = styled.ul`
7
+ margin: 0;
8
+ padding: 0;
9
+ list-style: none;
10
+ text-align: right;
11
+ `;
12
+ const NavItem = styled.li`
13
+ position: relative;
14
+ margin: 0;
15
+ padding: 0 20px;
16
+ cursor: pointer;
17
+ display: inline-block;
18
+ line-height: ${props => props.theme.size === 'large' ? '60px' : '50px'};
19
+ transition: background-color .5;
20
+
21
+ a {
22
+ font-size: 14px;
23
+ color: ${props => props.theme.secondaryTextColor};
24
+ text-rendering: optimizeLegibility;
25
+ -webkit-font-smoothing: antialiased;
26
+ -moz-osx-font-smoothing: grayscale;
27
+ .tnt-themeS1 & {
28
+ color: rgba(255,255,255,.8);
29
+ }
30
+ }
86
31
 
87
- if (selectedKey !== nav.key) {
88
- onChange && onChange(nav);
89
- setSelectedKey(nav.key);
32
+ &:hover, &.active {
33
+ a {
34
+ color: ${props => props.theme.primaryColor};
35
+ .tnt-themeS1 & {
36
+ color: #418AFF;
37
+ }
38
+ }
39
+ }
40
+ &.active {
41
+ &:after {
42
+ position: absolute;
43
+ left: 0;
44
+ bottom: 0;
45
+ width: 100%;
46
+ height: 3px;
47
+ background: ${props => props.theme.primaryColor};
48
+ display: inline-block;
49
+ content: "";
50
+ .tnt-themeS1 & {
51
+ background: #418AFF;
52
+ }
53
+ }
54
+ }
55
+ `;
56
+
57
+ export const HeaderNavs = withTheme(
58
+ ({ theme, navs = [], onChange, onSelect, ...props }) => {
59
+ const [selectedKey, setSelectedKey] = useState(props.selectedKey || get(navs, '0.key'));
60
+ const onClickNav = nav => {
61
+ setSelectedKey(nav.key);
62
+ onSelect && onSelect(nav);
63
+
64
+ if (selectedKey !== nav.key) {
65
+ onChange && onChange(nav);
66
+ setSelectedKey(nav.key);
67
+ }
68
+ };
69
+
70
+ useEffect(() => {
71
+ setSelectedKey(props.selectedKey || get(navs, '0.key'));
72
+ }, [navs, props.selectedKey]);
73
+
74
+ return (
75
+ <Navs {...props}>
76
+ {
77
+ navs.map(nav => (
78
+ <NavItem
79
+ key={nav.key}
80
+ theme={theme}
81
+ className={cn({ active: selectedKey === nav.key })}
82
+ onClick={() => onClickNav(nav)}
83
+ >
84
+ <a href={nav.key} onClick={evt => evt.preventDefault()}>{nav.name}</a>
85
+ </NavItem>
86
+ ))
87
+ }
88
+ </Navs>
89
+ );
90
90
  }
91
- };
91
+ );
92
92
 
93
- (0, _react.useEffect)(function () {
94
- setSelectedKey(props.selectedKey || (0, _lodash.get)(navs, '0.key'));
95
- }, [navs, props.selectedKey]);
96
- return React.createElement(Navs, props, navs.map(function (nav) {
97
- return React.createElement(NavItem, {
98
- key: nav.key,
99
- theme: theme,
100
- className: (0, _classnames["default"])({
101
- active: selectedKey === nav.key
102
- }),
103
- onClick: function onClick() {
104
- return onClickNav(nav);
105
- }
106
- }, React.createElement("a", {
107
- href: nav.key,
108
- onClick: function onClick(evt) {
109
- return evt.preventDefault();
110
- }
111
- }, nav.name));
112
- }));
113
- });
114
- exports.HeaderNavs = HeaderNavs;
115
- var _default = HeaderNavs;
116
- exports["default"] = _default;
93
+ export default HeaderNavs;