tntd 1.3.66 → 1.4.2
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.
- package/babel.config.js +1 -1
- package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
- package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
- package/dist/1.tntd.js +12 -0
- package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
- package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
- package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
- package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
- package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
- package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
- package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
- package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
- package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
- package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
- package/dist/stats.json +45855 -0
- package/dist/tntd.css +1 -0
- package/dist/tntd.js +15 -0
- package/es/ArrayInput/README.md +129 -0
- package/es/ArrayInput/icon.js +24 -0
- package/es/ArrayInput/index.js +282 -0
- package/es/ArrayInput/index.less +20 -0
- package/es/AuthContext.js +4 -0
- package/es/Columns/README.md +149 -0
- package/es/Columns/index.js +86 -0
- package/es/Columns/index.less +75 -0
- package/es/DevelopmentLogin/LoginModal.js +126 -0
- package/es/DevelopmentLogin/README.md +49 -0
- package/es/DevelopmentLogin/index.js +40 -0
- package/es/Ellipsis/README.md +104 -0
- package/es/Ellipsis/Svg/CopySVG.js +63 -0
- package/es/Ellipsis/Svg/TickSVG.js +41 -0
- package/es/Ellipsis/index.js +143 -0
- package/es/Ellipsis/index.less +56 -0
- package/es/Handle/README.md +104 -0
- package/es/Handle/index.js +92 -0
- package/es/Handle/index.less +9 -0
- package/es/Icon/README.md +119 -0
- package/es/Icon/fonts/demo.css +539 -0
- package/es/Icon/fonts/demo_index.html +3345 -0
- package/es/Icon/fonts/iconfont.css +569 -0
- package/es/Icon/fonts/iconfont.eot +0 -0
- package/es/Icon/fonts/iconfont.js +41 -0
- package/es/Icon/fonts/iconfont.json +975 -0
- package/es/Icon/fonts/iconfont.svg +440 -0
- package/es/Icon/fonts/iconfont.ttf +0 -0
- package/es/Icon/fonts/iconfont.woff +0 -0
- package/es/Icon/fonts/iconfont.woff2 +0 -0
- package/es/Icon/iconList.js +1 -0
- package/es/Icon/index.js +26 -0
- package/es/Icon/index.less +9 -0
- package/es/Img/Contain.js +69 -0
- package/es/Img/Cover.js +126 -0
- package/es/Img/README.md +131 -0
- package/es/Img/index.js +76 -0
- package/es/Layout/ActionsContext.js +3 -0
- package/es/Layout/AppList.js +233 -0
- package/es/Layout/Application.js +115 -0
- package/es/Layout/Avatar.js +116 -0
- package/es/Layout/CompatibleLanguage.js +179 -0
- package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
- package/es/Layout/EnterpriseLayout/Language.js +81 -0
- package/es/Layout/EnterpriseLayout/Theme.js +77 -0
- package/es/Layout/EnterpriseLayout/index.js +31 -0
- package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
- package/es/Layout/GlobalNavigation/index.js +137 -0
- package/es/Layout/Header.js +95 -0
- package/es/Layout/HeaderActions.js +107 -0
- package/es/Layout/HeaderNavs.js +93 -0
- package/es/Layout/HeaderTabs.js +264 -0
- package/es/Layout/Iconfont.js +4 -0
- package/es/Layout/Language.js +81 -0
- package/es/Layout/Layout.js +234 -0
- package/es/Layout/Logo.js +86 -0
- package/es/Layout/OrgAppList.js +310 -0
- package/es/Layout/README.md +783 -0
- package/es/Layout/SideMenu.js +340 -0
- package/es/Layout/Theme.js +107 -0
- package/es/Layout/checkAuth.js +29 -0
- package/es/Layout/createActions.js +39 -0
- package/es/Layout/images/avatar/empty.png +0 -0
- package/es/Layout/images/avatar/female1.png +0 -0
- package/es/Layout/images/avatar/female2.png +0 -0
- package/es/Layout/images/avatar/female3.png +0 -0
- package/es/Layout/images/avatar/female4.png +0 -0
- package/es/Layout/images/avatar/female5.png +0 -0
- package/es/Layout/images/avatar/female6.png +0 -0
- package/es/Layout/images/avatar/male1.png +0 -0
- package/es/Layout/images/avatar/male2.png +0 -0
- package/es/Layout/images/avatar/male3.png +0 -0
- package/es/Layout/images/avatar/male4.png +0 -0
- package/es/Layout/images/avatar/male5.png +0 -0
- package/es/Layout/images/avatar/male6.png +0 -0
- package/es/Layout/images/index.js +35 -0
- package/es/Layout/images/logo/baldur.svg +14 -0
- package/es/Layout/images/logo/bi.svg +14 -0
- package/es/Layout/images/logo/bridge.svg +15 -0
- package/es/Layout/images/logo/convert.svg +18 -0
- package/es/Layout/images/logo/dataocean.svg +31 -0
- package/es/Layout/images/logo/default.svg +19 -0
- package/es/Layout/images/logo/dispatch.svg +14 -0
- package/es/Layout/images/logo/graph.svg +26 -0
- package/es/Layout/images/logo/handle.svg +10 -0
- package/es/Layout/images/logo/indicator.svg +41 -0
- package/es/Layout/images/logo/kafka.svg +12 -0
- package/es/Layout/images/logo/logo-custom.svg +13 -0
- package/es/Layout/images/logo/model.svg +17 -0
- package/es/Layout/images/logo/mysql.svg +15 -0
- package/es/Layout/images/logo/orion.svg +24 -0
- package/es/Layout/images/logo/salaxy.svg +11 -0
- package/es/Layout/images/logo/storage.svg +16 -0
- package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
- package/es/Layout/images/logo/turing.svg +35 -0
- package/es/Layout/images/theme/theme1.svg +35 -0
- package/es/Layout/images/theme/theme2.svg +33 -0
- package/es/Layout/index.js +122 -0
- package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
- package/es/Layout/paaslayout/Header.js +77 -0
- package/es/Layout/paaslayout/Logo.js +22 -0
- package/es/Layout/paaslayout/SideMenu.js +168 -0
- package/es/Layout/paaslayout/index.js +235 -0
- package/es/Layout/storage.js +47 -0
- package/es/Layout/utils.js +136 -0
- package/es/LoadingButton/README.md +75 -0
- package/es/LoadingButton/index.js +45 -0
- package/es/Modal/README.md +59 -0
- package/es/Modal/index.js +96 -0
- package/es/Modal/index.less +86 -0
- package/es/Page/Box.js +74 -0
- package/es/Page/README.md +180 -0
- package/es/Page/index.js +165 -0
- package/es/Page/index.less +144 -0
- package/es/Page/utils.js +23 -0
- package/es/QueryForm/Field/Checkbox.js +21 -0
- package/es/QueryForm/Field/Select.js +80 -0
- package/es/QueryForm/Field/SelectInput.js +92 -0
- package/es/QueryForm/Field/fieldsMap.js +32 -0
- package/es/QueryForm/Field/index.js +157 -0
- package/es/QueryForm/README.md +512 -0
- package/es/QueryForm/createActions.js +53 -0
- package/es/QueryForm/index.js +384 -0
- package/es/QueryForm/index.less +133 -0
- package/es/QueryForm/useForm.js +7 -0
- package/es/QueryListScene/List.js +378 -0
- package/es/QueryListScene/QueryForm.js +166 -0
- package/es/QueryListScene/QueryListScene.js +76 -0
- package/es/QueryListScene/README.md +790 -0
- package/es/QueryListScene/Title.js +12 -0
- package/es/QueryListScene/Toolbar.js +20 -0
- package/es/QueryListScene/createActions.js +72 -0
- package/es/QueryListScene/index.js +19 -0
- package/es/QueryListScene/index.less +97 -0
- package/es/QueryListScene/useActions.js +7 -0
- package/es/Select/DropDownWrap.js +116 -0
- package/es/Select/README.md +68 -0
- package/es/Select/index.js +622 -0
- package/es/Table/README.md +109 -0
- package/es/Table/ResizableTable/index.js +110 -0
- package/es/Table/ResizableTable/index.less +36 -0
- package/es/Table/index.js +35 -0
- package/es/Title/README.md +106 -0
- package/es/Title/index.js +40 -0
- package/es/Title/index.less +170 -0
- package/es/index.js +19 -0
- package/es/locale.js +60 -0
- package/package.json +1 -1
- package/doc-scripts.config.js +0 -37
- package/doc-scripts.renderer.js +0 -11
- package/docs/README.md +0 -1643
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import "antd/lib/divider/style";
|
|
2
|
+
import _Divider from "antd/lib/divider";
|
|
3
|
+
|
|
4
|
+
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; }
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
function _templateObject() {
|
|
9
|
+
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"]);
|
|
10
|
+
|
|
11
|
+
_templateObject = function _templateObject() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
19
|
+
|
|
20
|
+
import styled, { withTheme } from 'styled-components';
|
|
21
|
+
import GlobalNavigation from './GlobalNavigation';
|
|
22
|
+
import Language from './Language';
|
|
23
|
+
import Theme from './Theme';
|
|
24
|
+
import LanguageTheme from './CompatibleLanguage';
|
|
25
|
+
import Application from './Application';
|
|
26
|
+
import Avatar from './Avatar';
|
|
27
|
+
var Actions = styled.ul(_templateObject(), function (props) {
|
|
28
|
+
return "".concat(props.theme.headerHeight, "px");
|
|
29
|
+
}, function (props) {
|
|
30
|
+
return "".concat(props.theme.headerActionsColor);
|
|
31
|
+
});
|
|
32
|
+
export default withTheme(function (props) {
|
|
33
|
+
var _props$config = props.config;
|
|
34
|
+
_props$config = _props$config === void 0 ? {} : _props$config;
|
|
35
|
+
|
|
36
|
+
var _props$config$theme = _props$config.theme,
|
|
37
|
+
theme = _props$config$theme === void 0 ? true : _props$config$theme,
|
|
38
|
+
_props$config$avatar = _props$config.avatar,
|
|
39
|
+
avatar = _props$config$avatar === void 0 ? true : _props$config$avatar,
|
|
40
|
+
_props$config$languag = _props$config.language,
|
|
41
|
+
language = _props$config$languag === void 0 ? true : _props$config$languag,
|
|
42
|
+
_props$config$applica = _props$config.application,
|
|
43
|
+
application = _props$config$applica === void 0 ? false : _props$config$applica,
|
|
44
|
+
_props$config$globalN = _props$config.globalNavigation,
|
|
45
|
+
globalNavigation = _props$config$globalN === void 0 ? false : _props$config$globalN,
|
|
46
|
+
compatible = props.theme.compatible,
|
|
47
|
+
_props$userInfo = props.userInfo,
|
|
48
|
+
userInfo = _props$userInfo === void 0 ? {} : _props$userInfo,
|
|
49
|
+
menus = props.menus,
|
|
50
|
+
apps = props.apps,
|
|
51
|
+
extraActions = props.extraActions,
|
|
52
|
+
headerRef = props.headerRef,
|
|
53
|
+
onLanguageChange = props.onLanguageChange,
|
|
54
|
+
onThemeChange = props.onThemeChange,
|
|
55
|
+
onApplicationChange = props.onApplicationChange,
|
|
56
|
+
onAppChange = props.onAppChange,
|
|
57
|
+
onCollapseChange = props.onCollapseChange,
|
|
58
|
+
onPersonalSetting = props.onPersonalSetting,
|
|
59
|
+
onChangePassword = props.onChangePassword,
|
|
60
|
+
onLogout = props.onLogout,
|
|
61
|
+
onLogoClick = props.onLogoClick,
|
|
62
|
+
AvatarCustom = props.AvatarCustom,
|
|
63
|
+
rest = _objectWithoutProperties(props, ["config", "theme", "userInfo", "menus", "apps", "extraActions", "headerRef", "onLanguageChange", "onThemeChange", "onApplicationChange", "onAppChange", "onCollapseChange", "onPersonalSetting", "onChangePassword", "onLogout", "onLogoClick", "AvatarCustom"]);
|
|
64
|
+
|
|
65
|
+
return React.createElement(Actions, rest, extraActions, globalNavigation && React.createElement(GlobalNavigation, {
|
|
66
|
+
headerRef: headerRef,
|
|
67
|
+
menus: menus
|
|
68
|
+
}), !AvatarCustom && (!compatible ? React.createElement(React.Fragment, null, language && React.createElement(Language, {
|
|
69
|
+
language: userInfo.lang,
|
|
70
|
+
onChange: onLanguageChange
|
|
71
|
+
}), theme && React.createElement(Theme, {
|
|
72
|
+
theme: userInfo.theme,
|
|
73
|
+
onChange: onThemeChange
|
|
74
|
+
})) : React.createElement(LanguageTheme, {
|
|
75
|
+
config: props.config,
|
|
76
|
+
language: userInfo.lang,
|
|
77
|
+
theme: userInfo.theme,
|
|
78
|
+
onLanguageChange: onLanguageChange,
|
|
79
|
+
onThemeChange: onThemeChange
|
|
80
|
+
})), application && React.createElement(Application, {
|
|
81
|
+
language: userInfo.lang,
|
|
82
|
+
apps: apps,
|
|
83
|
+
onChange: onApplicationChange
|
|
84
|
+
}), avatar && React.createElement(React.Fragment, null, React.createElement(_Divider, {
|
|
85
|
+
type: "vertical"
|
|
86
|
+
}), AvatarCustom ? React.createElement(AvatarCustom, {
|
|
87
|
+
userInfo: userInfo,
|
|
88
|
+
onPersonalSetting: onPersonalSetting,
|
|
89
|
+
onChangePassword: onChangePassword,
|
|
90
|
+
onLogout: onLogout,
|
|
91
|
+
onThemeChange: onThemeChange,
|
|
92
|
+
config: {
|
|
93
|
+
theme: theme,
|
|
94
|
+
language: language
|
|
95
|
+
}
|
|
96
|
+
}) : React.createElement(Avatar, {
|
|
97
|
+
userInfo: userInfo,
|
|
98
|
+
onPersonalSetting: onPersonalSetting,
|
|
99
|
+
onChangePassword: onChangePassword,
|
|
100
|
+
onLogout: onLogout,
|
|
101
|
+
onThemeChange: onThemeChange,
|
|
102
|
+
config: {
|
|
103
|
+
theme: theme,
|
|
104
|
+
language: language
|
|
105
|
+
}
|
|
106
|
+
})));
|
|
107
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
function _templateObject2() {
|
|
14
|
+
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"]);
|
|
15
|
+
|
|
16
|
+
_templateObject2 = function _templateObject2() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function _templateObject() {
|
|
24
|
+
var data = _taggedTemplateLiteral(["\n margin: 0;\n padding: 0;\n list-style: none;\n text-align: right;\n"]);
|
|
25
|
+
|
|
26
|
+
_templateObject = function _templateObject() {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
34
|
+
|
|
35
|
+
import { useState, useEffect } from 'react';
|
|
36
|
+
import styled, { withTheme } from 'styled-components';
|
|
37
|
+
import cn from 'classnames';
|
|
38
|
+
import { get } from 'lodash';
|
|
39
|
+
var Navs = styled.ul(_templateObject());
|
|
40
|
+
var NavItem = styled.li(_templateObject2(), function (props) {
|
|
41
|
+
return props.theme.size === 'large' ? '60px' : '50px';
|
|
42
|
+
}, function (props) {
|
|
43
|
+
return props.theme.secondaryTextColor;
|
|
44
|
+
}, function (props) {
|
|
45
|
+
return props.theme.primaryColor;
|
|
46
|
+
}, function (props) {
|
|
47
|
+
return props.theme.primaryColor;
|
|
48
|
+
});
|
|
49
|
+
export var HeaderNavs = withTheme(function (_ref) {
|
|
50
|
+
var theme = _ref.theme,
|
|
51
|
+
_ref$navs = _ref.navs,
|
|
52
|
+
navs = _ref$navs === void 0 ? [] : _ref$navs,
|
|
53
|
+
onChange = _ref.onChange,
|
|
54
|
+
onSelect = _ref.onSelect,
|
|
55
|
+
props = _objectWithoutProperties(_ref, ["theme", "navs", "onChange", "onSelect"]);
|
|
56
|
+
|
|
57
|
+
var _useState = useState(props.selectedKey || get(navs, '0.key')),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
selectedKey = _useState2[0],
|
|
60
|
+
setSelectedKey = _useState2[1];
|
|
61
|
+
|
|
62
|
+
var onClickNav = function onClickNav(nav) {
|
|
63
|
+
setSelectedKey(nav.key);
|
|
64
|
+
onSelect && onSelect(nav);
|
|
65
|
+
|
|
66
|
+
if (selectedKey !== nav.key) {
|
|
67
|
+
onChange && onChange(nav);
|
|
68
|
+
setSelectedKey(nav.key);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
setSelectedKey(props.selectedKey || get(navs, '0.key'));
|
|
74
|
+
}, [navs, props.selectedKey]);
|
|
75
|
+
return React.createElement(Navs, props, navs.map(function (nav) {
|
|
76
|
+
return React.createElement(NavItem, {
|
|
77
|
+
key: nav.key,
|
|
78
|
+
theme: theme,
|
|
79
|
+
className: cn({
|
|
80
|
+
active: selectedKey === nav.key
|
|
81
|
+
}),
|
|
82
|
+
onClick: function onClick() {
|
|
83
|
+
return onClickNav(nav);
|
|
84
|
+
}
|
|
85
|
+
}, React.createElement("a", {
|
|
86
|
+
href: nav.key,
|
|
87
|
+
onClick: function onClick(evt) {
|
|
88
|
+
return evt.preventDefault();
|
|
89
|
+
}
|
|
90
|
+
}, nav.name));
|
|
91
|
+
}));
|
|
92
|
+
});
|
|
93
|
+
export default HeaderNavs;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
6
|
+
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
function _templateObject3() {
|
|
18
|
+
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"]);
|
|
19
|
+
|
|
20
|
+
_templateObject3 = function _templateObject3() {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _templateObject2() {
|
|
28
|
+
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"]);
|
|
29
|
+
|
|
30
|
+
_templateObject2 = function _templateObject2() {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _templateObject() {
|
|
38
|
+
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"]);
|
|
39
|
+
|
|
40
|
+
_templateObject = function _templateObject() {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
48
|
+
|
|
49
|
+
import { useState, useEffect, useRef } from 'react';
|
|
50
|
+
import styled, { withTheme } from 'styled-components';
|
|
51
|
+
import cn from 'classnames';
|
|
52
|
+
import { get } from 'lodash';
|
|
53
|
+
import Icon from '../Icon';
|
|
54
|
+
var TabsContainer = styled.div(_templateObject(), function (props) {
|
|
55
|
+
return "".concat(props.theme.blueBgColor);
|
|
56
|
+
});
|
|
57
|
+
var Tabs = styled.ul(_templateObject2());
|
|
58
|
+
var TabItem = styled.li(_templateObject3(), function (props) {
|
|
59
|
+
return props.theme.size === 'large' ? '46px' : '36px';
|
|
60
|
+
}, function (props) {
|
|
61
|
+
return props.theme.headerActionsColor;
|
|
62
|
+
}, function (props) {
|
|
63
|
+
return props.theme.headerActionsColor;
|
|
64
|
+
}, function (props) {
|
|
65
|
+
return props.theme.primaryTextColor;
|
|
66
|
+
}, function (props) {
|
|
67
|
+
return props.theme.primaryTextColor;
|
|
68
|
+
});
|
|
69
|
+
export var HeaderTabs = withTheme(function (_ref) {
|
|
70
|
+
var theme = _ref.theme,
|
|
71
|
+
className = _ref.className,
|
|
72
|
+
_ref$tabs = _ref.tabs,
|
|
73
|
+
tabs = _ref$tabs === void 0 ? [] : _ref$tabs,
|
|
74
|
+
onTabChange = _ref.onTabChange,
|
|
75
|
+
onTabSelect = _ref.onTabSelect,
|
|
76
|
+
onTabClose = _ref.onTabClose,
|
|
77
|
+
appListVisible = _ref.appListVisible,
|
|
78
|
+
orgListVisible = _ref.orgListVisible,
|
|
79
|
+
orgAppListVisible = _ref.orgAppListVisible,
|
|
80
|
+
props = _objectWithoutProperties(_ref, ["theme", "className", "tabs", "onTabChange", "onTabSelect", "onTabClose", "appListVisible", "orgListVisible", "orgAppListVisible"]);
|
|
81
|
+
|
|
82
|
+
var _useState = useState(props.selectedKey || get(tabs, '0.key')),
|
|
83
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
84
|
+
selectedKey = _useState2[0],
|
|
85
|
+
setSelectedKey = _useState2[1];
|
|
86
|
+
|
|
87
|
+
var _useState3 = useState(tabs || []),
|
|
88
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
89
|
+
tabItems = _useState4[0],
|
|
90
|
+
setTabItems = _useState4[1];
|
|
91
|
+
|
|
92
|
+
var _useState5 = useState(false),
|
|
93
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
94
|
+
arrowVisible = _useState6[0],
|
|
95
|
+
setArrowVisible = _useState6[1];
|
|
96
|
+
|
|
97
|
+
var _useState7 = useState({
|
|
98
|
+
start: true,
|
|
99
|
+
end: true
|
|
100
|
+
}),
|
|
101
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
102
|
+
tabsPositionFlags = _useState8[0],
|
|
103
|
+
setTabsPositionFlags = _useState8[1];
|
|
104
|
+
|
|
105
|
+
var tabsRef = useRef();
|
|
106
|
+
|
|
107
|
+
var getTabsDom = function getTabsDom() {
|
|
108
|
+
return tabsRef.current;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
var onTabClick = function onTabClick(tab, index) {
|
|
112
|
+
setSelectedKey(tab.key);
|
|
113
|
+
onTabSelect == null ? void 0 : onTabSelect(tab);
|
|
114
|
+
|
|
115
|
+
if (selectedKey !== tab.key) {
|
|
116
|
+
onTabChange == null ? void 0 : onTabChange(tab);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var closeTabHandle = function closeTabHandle(tab, index, evt) {
|
|
121
|
+
evt.stopPropagation();
|
|
122
|
+
var newTabItems = tabItems.filter(function (_ref2) {
|
|
123
|
+
var key = _ref2.key;
|
|
124
|
+
return key !== tab.key;
|
|
125
|
+
});
|
|
126
|
+
var newSelectedKey = selectedKey;
|
|
127
|
+
setTabItems(newTabItems);
|
|
128
|
+
|
|
129
|
+
if (tab.key === selectedKey) {
|
|
130
|
+
var _newTabItems$, _newTabItems;
|
|
131
|
+
|
|
132
|
+
newSelectedKey = index === 0 ? (_newTabItems$ = newTabItems[0]) == null ? void 0 : _newTabItems$.key : (_newTabItems = newTabItems[index - 1]) == null ? void 0 : _newTabItems.key;
|
|
133
|
+
setSelectedKey(newSelectedKey);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
onTabClose == null ? void 0 : onTabClose(tab, newTabItems, newTabItems.find(function (_ref3) {
|
|
137
|
+
var key = _ref3.key;
|
|
138
|
+
return key === newSelectedKey;
|
|
139
|
+
}));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
var onMoveToLeft = function onMoveToLeft() {
|
|
143
|
+
var tabsDom = getTabsDom();
|
|
144
|
+
var parentBBox = tabsDom.parentNode.getBoundingClientRect();
|
|
145
|
+
var parentWidth = parentBBox.width - 32;
|
|
146
|
+
var x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ''));
|
|
147
|
+
var index = Math.ceil(x / 130);
|
|
148
|
+
var trueX = index * 130;
|
|
149
|
+
var newX = Math.min(0, -(trueX - parentWidth));
|
|
150
|
+
tabsDom.style.transform = "translateX(".concat(newX, "px)");
|
|
151
|
+
var width = tabItems.length * 130;
|
|
152
|
+
setTabsPositionFlags({
|
|
153
|
+
start: newX < 0,
|
|
154
|
+
end: Math.abs(newX) < width - parentWidth
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
var onMoveToRight = function onMoveToRight() {
|
|
159
|
+
var tabsDom = getTabsDom();
|
|
160
|
+
var parentBBox = tabsDom.parentNode.getBoundingClientRect();
|
|
161
|
+
var parentWidth = parentBBox.width - 32;
|
|
162
|
+
var width = tabItems.length * 130;
|
|
163
|
+
var x = Math.abs(+tabsDom.style.transform.replace(/[^\d.-]/g, ''));
|
|
164
|
+
var index = Math.floor(x / 130);
|
|
165
|
+
var trueX = index * 130;
|
|
166
|
+
var newX = Math.max(-(width - parentWidth), -(trueX + parentWidth));
|
|
167
|
+
tabsDom.style.transform = "translateX(".concat(newX, "px)");
|
|
168
|
+
setTabsPositionFlags({
|
|
169
|
+
start: newX < 0,
|
|
170
|
+
end: Math.abs(newX) < width - parentWidth
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var translateTabsDom = function translateTabsDom(tabs, selectedKey) {
|
|
175
|
+
if (!selectedKey) return;
|
|
176
|
+
var index = tabs.indexOf(tabs.find(function (_ref4) {
|
|
177
|
+
var key = _ref4.key;
|
|
178
|
+
return key === selectedKey;
|
|
179
|
+
}));
|
|
180
|
+
if (index === -1) return;
|
|
181
|
+
var tabsDom = getTabsDom();
|
|
182
|
+
var x = -+tabsDom.style.transform.replace(/[^\d.-]/g, '');
|
|
183
|
+
var bbox = {
|
|
184
|
+
left: index * 130,
|
|
185
|
+
right: (index + 1) * 130
|
|
186
|
+
};
|
|
187
|
+
var parentBBox = tabsDom.parentNode.getBoundingClientRect();
|
|
188
|
+
var parentWidth = parentBBox.width - 36;
|
|
189
|
+
var width = tabItems.length * 130;
|
|
190
|
+
var tailX = x + parentWidth; //当前滑动窗口尾部坐标
|
|
191
|
+
|
|
192
|
+
var newX = -x;
|
|
193
|
+
|
|
194
|
+
if (bbox.left < x) {
|
|
195
|
+
newX = -bbox.left;
|
|
196
|
+
} else if (bbox.right >= tailX) {
|
|
197
|
+
newX = parentWidth - bbox.right;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (newX + width < parentWidth) {
|
|
201
|
+
newX = -(width - parentWidth);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
newX = Math.min(0, newX);
|
|
205
|
+
tabsDom.style.transform = "translateX(".concat(newX, "px)");
|
|
206
|
+
setTabsPositionFlags({
|
|
207
|
+
start: newX < 0,
|
|
208
|
+
end: Math.abs(newX) < width - parentWidth
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
useEffect(function () {
|
|
213
|
+
setSelectedKey(props.selectedKey || 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'}] ;
|
|
214
|
+
|
|
215
|
+
setTabItems(tabs);
|
|
216
|
+
}, [tabs, props.selectedKey]);
|
|
217
|
+
useEffect(function () {}, [props.orgAppListVisible]);
|
|
218
|
+
useEffect(function () {
|
|
219
|
+
var tabsDom = getTabsDom();
|
|
220
|
+
setArrowVisible(tabsDom.offsetWidth - tabsDom.parentNode.offsetWidth > 0);
|
|
221
|
+
}, [tabItems]);
|
|
222
|
+
useEffect(function () {
|
|
223
|
+
translateTabsDom(tabItems, selectedKey);
|
|
224
|
+
}, [tabItems, selectedKey, appListVisible, orgListVisible, orgAppListVisible]);
|
|
225
|
+
return React.createElement(TabsContainer, _extends({}, props, {
|
|
226
|
+
className: cn('tnt-layout-header-tabs', _defineProperty({}, className, className))
|
|
227
|
+
}), React.createElement(Tabs, {
|
|
228
|
+
className: "tnt-layout-header-tabs-content",
|
|
229
|
+
ref: tabsRef
|
|
230
|
+
}, tabItems.map(function (tab, index) {
|
|
231
|
+
var _tabItems;
|
|
232
|
+
|
|
233
|
+
return React.createElement(TabItem, {
|
|
234
|
+
key: tab.key,
|
|
235
|
+
theme: theme,
|
|
236
|
+
className: cn({
|
|
237
|
+
active: selectedKey === tab.key,
|
|
238
|
+
activeTabPreSibling: ((_tabItems = tabItems[index + 1]) == null ? void 0 : _tabItems.key) === selectedKey
|
|
239
|
+
}),
|
|
240
|
+
onClick: function onClick() {
|
|
241
|
+
return onTabClick(tab, index);
|
|
242
|
+
}
|
|
243
|
+
}, React.createElement("a", {
|
|
244
|
+
href: tab.key,
|
|
245
|
+
onClick: function onClick(evt) {
|
|
246
|
+
return evt.preventDefault();
|
|
247
|
+
}
|
|
248
|
+
}, tab.name), tabItems.length > 1 && React.createElement(Icon, {
|
|
249
|
+
type: "close",
|
|
250
|
+
onClick: closeTabHandle.bind(null, tab, index)
|
|
251
|
+
}));
|
|
252
|
+
})), arrowVisible && React.createElement("div", {
|
|
253
|
+
className: "tnt-layout-header-tabs-arrows"
|
|
254
|
+
}, React.createElement(Icon, {
|
|
255
|
+
type: "left",
|
|
256
|
+
onClick: onMoveToLeft,
|
|
257
|
+
disabled: !tabsPositionFlags.start
|
|
258
|
+
}), React.createElement(Icon, {
|
|
259
|
+
type: "right",
|
|
260
|
+
onClick: onMoveToRight,
|
|
261
|
+
disabled: !tabsPositionFlags.end
|
|
262
|
+
})));
|
|
263
|
+
});
|
|
264
|
+
export default HeaderTabs;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
|
|
9
|
+
function _templateObject() {
|
|
10
|
+
var data = _taggedTemplateLiteral(["\n font-size: ", ";\n .tnt-icon {\n font-size: ", ";\n margin-right: 4px;\n }\n span {\n position: relative;\n font-size: ", ";\n top: ", ";\n font-family: auto;\n .tnt-themeS1 & {\n /* color: rgba(255,255,255,.85); */\n }\n }\n .isInIframe & {\n display: none;\n }\n"]);
|
|
11
|
+
|
|
12
|
+
_templateObject = function _templateObject() {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
20
|
+
|
|
21
|
+
import { useState } from 'react';
|
|
22
|
+
import styled, { withTheme } from 'styled-components';
|
|
23
|
+
import { get } from 'lodash';
|
|
24
|
+
import Iconfont from './Iconfont';
|
|
25
|
+
import { setLanguageStore, getLanguageStore } from './storage';
|
|
26
|
+
var languages = [{
|
|
27
|
+
value: 'cn',
|
|
28
|
+
name: '中文'
|
|
29
|
+
}, {
|
|
30
|
+
value: 'en',
|
|
31
|
+
name: ' EN '
|
|
32
|
+
}];
|
|
33
|
+
var languagesMap = languages.reduce(function (acc, cur) {
|
|
34
|
+
acc[cur.value] = cur;
|
|
35
|
+
return acc;
|
|
36
|
+
}, {});
|
|
37
|
+
var Language = styled.li(_templateObject(), function (_ref) {
|
|
38
|
+
var size = _ref.theme.size;
|
|
39
|
+
return size === 'large' ? '14px' : '12px';
|
|
40
|
+
}, function (_ref2) {
|
|
41
|
+
var size = _ref2.theme.size;
|
|
42
|
+
return size === 'large' ? '24px' : '20px';
|
|
43
|
+
}, function (_ref3) {
|
|
44
|
+
var size = _ref3.theme.size;
|
|
45
|
+
return size === 'large' ? '14px' : '12px';
|
|
46
|
+
}, function (_ref4) {
|
|
47
|
+
var size = _ref4.theme.size;
|
|
48
|
+
return size === 'large' ? '-3px' : '-2px';
|
|
49
|
+
});
|
|
50
|
+
export default withTheme(function (props) {
|
|
51
|
+
var onChange = props.onChange;
|
|
52
|
+
|
|
53
|
+
var getLanguage = function getLanguage() {
|
|
54
|
+
var lang = getLanguageStore() || props.language;
|
|
55
|
+
|
|
56
|
+
if (!languagesMap[lang]) {
|
|
57
|
+
lang = get(languages, '0.value');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return lang;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var _useState = useState(getLanguage()),
|
|
64
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
65
|
+
_useState2$ = _useState2[0],
|
|
66
|
+
language = _useState2$ === void 0 ? 'cn' : _useState2$,
|
|
67
|
+
setLanguage = _useState2[1];
|
|
68
|
+
|
|
69
|
+
var switchLanguage = function switchLanguage() {
|
|
70
|
+
var lang = language === 'cn' ? 'en' : 'cn';
|
|
71
|
+
setLanguage(lang);
|
|
72
|
+
setLanguageStore(lang);
|
|
73
|
+
onChange && onChange(lang);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return React.createElement(Language, {
|
|
77
|
+
onClick: switchLanguage
|
|
78
|
+
}, React.createElement(Iconfont, {
|
|
79
|
+
type: "flag-".concat(language)
|
|
80
|
+
}), React.createElement("span", null, get(languagesMap[language], 'name')));
|
|
81
|
+
});
|