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,136 +1,133 @@
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;
1
+ "use strict";
20
2
 
21
- .isInIframe & {
22
- display: none;
23
- }
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; }
24
29
 
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
- }
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"]);
88
+
89
+ return React.createElement(Actions, rest, extraActions, globalNavigation && React.createElement(_GlobalNavigation["default"], {
90
+ headerRef: headerRef,
91
+ menus: menus
92
+ }), !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
119
+ }
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
52
129
  }
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
- );
130
+ })));
136
131
  });
132
+
133
+ exports["default"] = _default;
@@ -1,93 +1,116 @@
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
- }
1
+ "use strict";
31
2
 
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
- );
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);
86
+
87
+ if (selectedKey !== nav.key) {
88
+ onChange && onChange(nav);
89
+ setSelectedKey(nav.key);
90
90
  }
91
- );
91
+ };
92
92
 
93
- export default HeaderNavs;
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;