tntd 1.4.4 → 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 (88) hide show
  1. package/components/Layout/HeaderActions.js +90 -128
  2. package/components/LoadingButton/index.js +11 -15
  3. package/components/QueryListScene/QueryForm.js +7 -4
  4. package/dist/stats.json +4990 -4990
  5. package/dist/tntd.js +1 -1
  6. package/es/Layout/HeaderActions.js +10 -10
  7. package/es/LoadingButton/index.js +20 -10
  8. package/es/QueryListScene/QueryForm.js +6 -3
  9. package/lib/ArrayInput/icon.js +27 -31
  10. package/lib/ArrayInput/index.js +211 -298
  11. package/lib/AuthContext.js +2 -13
  12. package/lib/Columns/index.js +71 -100
  13. package/lib/DevelopmentLogin/LoginModal.js +79 -141
  14. package/lib/DevelopmentLogin/index.js +28 -55
  15. package/lib/Ellipsis/Svg/CopySVG.js +23 -71
  16. package/lib/Ellipsis/Svg/TickSVG.js +17 -49
  17. package/lib/Ellipsis/index.js +148 -154
  18. package/lib/Handle/index.js +72 -109
  19. package/lib/Icon/fonts/iconfont.js +1 -43
  20. package/lib/Icon/iconList.js +119 -8
  21. package/lib/Icon/index.js +13 -45
  22. package/lib/Img/Contain.js +49 -81
  23. package/lib/Img/Cover.js +88 -136
  24. package/lib/Img/index.js +36 -89
  25. package/lib/Layout/ActionsContext.js +2 -11
  26. package/lib/Layout/AppList.js +262 -256
  27. package/lib/Layout/Application.js +119 -135
  28. package/lib/Layout/Avatar.js +137 -137
  29. package/lib/Layout/CompatibleLanguage.js +214 -195
  30. package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
  31. package/lib/Layout/EnterpriseLayout/Language.js +75 -100
  32. package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
  33. package/lib/Layout/EnterpriseLayout/index.js +32 -45
  34. package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
  35. package/lib/Layout/GlobalNavigation/index.js +110 -158
  36. package/lib/Layout/Header.js +165 -116
  37. package/lib/Layout/HeaderActions.js +132 -129
  38. package/lib/Layout/HeaderNavs.js +90 -113
  39. package/lib/Layout/HeaderTabs.js +312 -278
  40. package/lib/Layout/Iconfont.js +2 -15
  41. package/lib/Layout/Language.js +63 -102
  42. package/lib/Layout/Layout.js +272 -261
  43. package/lib/Layout/Logo.js +132 -87
  44. package/lib/Layout/OrgAppList.js +440 -319
  45. package/lib/Layout/SideMenu.js +429 -343
  46. package/lib/Layout/Theme.js +95 -124
  47. package/lib/Layout/checkAuth.js +21 -35
  48. package/lib/Layout/createActions.js +38 -51
  49. package/lib/Layout/images/index.js +33 -41
  50. package/lib/Layout/index.js +110 -161
  51. package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
  52. package/lib/Layout/paaslayout/Header.js +84 -90
  53. package/lib/Layout/paaslayout/Logo.js +27 -32
  54. package/lib/Layout/paaslayout/SideMenu.js +161 -174
  55. package/lib/Layout/paaslayout/index.js +240 -261
  56. package/lib/Layout/storage.js +20 -78
  57. package/lib/Layout/utils.js +93 -143
  58. package/lib/LoadingButton/index.js +25 -57
  59. package/lib/Modal/index.js +83 -108
  60. package/lib/Page/Box.js +56 -81
  61. package/lib/Page/index.js +151 -173
  62. package/lib/Page/utils.js +12 -30
  63. package/lib/QueryForm/Field/Checkbox.js +11 -33
  64. package/lib/QueryForm/Field/Select.js +63 -99
  65. package/lib/QueryForm/Field/SelectInput.js +69 -114
  66. package/lib/QueryForm/Field/fieldsMap.js +30 -52
  67. package/lib/QueryForm/Field/index.js +76 -158
  68. package/lib/QueryForm/createActions.js +50 -65
  69. package/lib/QueryForm/index.js +304 -383
  70. package/lib/QueryForm/useForm.js +6 -17
  71. package/lib/QueryListScene/List.js +290 -366
  72. package/lib/QueryListScene/QueryForm.js +93 -158
  73. package/lib/QueryListScene/QueryListScene.js +33 -87
  74. package/lib/QueryListScene/Title.js +10 -20
  75. package/lib/QueryListScene/Toolbar.js +8 -31
  76. package/lib/QueryListScene/createActions.js +64 -79
  77. package/lib/QueryListScene/index.js +23 -40
  78. package/lib/QueryListScene/useActions.js +6 -17
  79. package/lib/Select/DropDownWrap.js +60 -124
  80. package/lib/Select/index.js +425 -561
  81. package/lib/Table/ResizableTable/index.js +77 -121
  82. package/lib/Table/index.js +19 -51
  83. package/lib/Title/index.js +34 -52
  84. package/lib/index.js +19 -159
  85. package/lib/locale.js +48 -63
  86. package/package.json +1 -1
  87. package/lib/Layout/EnterpriseLayout/Header.js +0 -113
  88. package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
@@ -1,50 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _default = function _default(props) {
9
- return React.createElement("div", props, React.createElement("svg", {
10
- width: "17px",
11
- height: "16px",
12
- viewBox: "0 0 17 16"
13
- }, React.createElement("g", {
14
- id: "\u5168\u5BB6\u6876\u89C6\u89C9\u65B9\u6848\u4F18\u5316",
15
- stroke: "none",
16
- "stroke-width": "1",
17
- fill: "none",
18
- "fill-rule": "evenodd"
19
- }, React.createElement("g", {
20
- id: "\u5DE5\u4F5C\u53F01",
21
- transform: "translate(-754.000000, -299.000000)"
22
- }, React.createElement("g", {
23
- id: "\u5206\u7EC4-6",
24
- transform: "translate(240.000000, 96.000000)"
25
- }, React.createElement("g", {
26
- id: "\u7F16\u7EC4-18",
27
- transform: "translate(0.000000, 171.000000)"
28
- }, React.createElement("g", {
29
- id: "\u590D\u5236\u6210\u529F",
30
- transform: "translate(514.500000, 32.000000)"
31
- }, React.createElement("rect", {
32
- id: "\u77E9\u5F62",
33
- "fill-opacity": "0.01",
34
- fill: "#FFFFFF",
35
- "fill-rule": "nonzero",
36
- x: "0",
37
- y: "0",
38
- width: "16",
39
- height: "16"
40
- }), React.createElement("polyline", {
41
- id: "\u8DEF\u5F84",
42
- stroke: "#07C790",
43
- "stroke-width": "1.2",
44
- "stroke-linecap": "round",
45
- "stroke-linejoin": "round",
46
- points: "14.3333333 3.66666667 5.625 12.3333333 1.66666667 8.39393333"
47
- }))))))));
1
+ export default props => {
2
+ return <div {...props}>
3
+ <svg width="17px" height="16px" viewBox="0 0 17 16">
4
+ <g id="全家桶视觉方案优化" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="工作台1" transform="translate(-754.000000, -299.000000)">
6
+ <g id="分组-6" transform="translate(240.000000, 96.000000)">
7
+ <g id="编组-18" transform="translate(0.000000, 171.000000)">
8
+ <g id="复制成功" transform="translate(514.500000, 32.000000)">
9
+ <rect id="矩形" fill-opacity="0.01" fill="#FFFFFF" fill-rule="nonzero" x="0" y="0" width="16" height="16"></rect>
10
+ <polyline id="路径" stroke="#07C790" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" points="14.3333333 3.66666667 5.625 12.3333333 1.66666667 8.39393333"></polyline>
11
+ </g>
12
+ </g>
13
+ </g>
14
+ </g>
15
+ </g>
16
+ </svg>
17
+ </div>;
48
18
  };
49
-
50
- exports["default"] = _default;
@@ -1,157 +1,151 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- require("antd/lib/tooltip/style");
9
-
10
- var _tooltip = _interopRequireDefault(require("antd/lib/tooltip"));
11
-
12
- require("antd/lib/popover/style");
13
-
14
- var _popover2 = _interopRequireDefault(require("antd/lib/popover"));
15
-
16
- var _react = require("react");
17
-
18
- var _copyToClipboard = _interopRequireDefault(require("copy-to-clipboard"));
19
-
20
- var _CopySVG = _interopRequireDefault(require("./Svg/CopySVG"));
21
-
22
- var _TickSVG = _interopRequireDefault(require("./Svg/TickSVG"));
23
-
24
- require("./index.less");
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
29
-
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
-
32
- 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; }
33
-
34
- 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); }
35
-
36
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
37
-
38
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
39
-
40
- 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; }
41
-
42
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
-
44
- var tolerance = 0; // In px. Depends on the font you are using
45
-
46
- var isEllipsisActive = function isEllipsisActive(e) {
47
- return e.offsetWidth + tolerance < e.scrollWidth || e.offsetHeight < e.scrollHeight;
1
+ /*
2
+ * @Author: 梁洪刚
3
+ * @CreatDate: 2021-03-31 13:57:32
4
+ * @Describe: 省略号组件
5
+ */
6
+
7
+ import { useState, useEffect, useRef } from 'react';
8
+ import { Popover, Tooltip } from 'antd';
9
+ import copy from 'copy-to-clipboard';
10
+ import CopySVG from './Svg/CopySVG';
11
+ import TickSVG from './Svg/TickSVG';
12
+ import './index.less';
13
+
14
+ const tolerance = 0; // In px. Depends on the font you are using
15
+
16
+ const isEllipsisActive = (e) => {
17
+ return e.offsetWidth + tolerance < e.scrollWidth || e.offsetHeight < e.scrollHeight;
48
18
  };
49
19
 
50
- var _default = function _default(props) {
51
- var _props$_popover = props._popover,
52
- _popover = _props$_popover === void 0 ? props.Popover : _props$_popover,
53
- title = props.title,
54
- content = props.content,
55
- className = props.className,
56
- style = props.style,
57
- widthLimit = props.widthLimit,
58
- _props$_lines = props._lines,
59
- _lines = _props$_lines === void 0 ? props.lines !== 1 && props.lines : _props$_lines,
60
- children = props.children,
61
- emptyText = props.emptyText,
62
- _props$_copyable = props._copyable,
63
- _copyable = _props$_copyable === void 0 ? props.copyable : _props$_copyable,
64
- prefix = props.prefix,
65
- suffix = props.suffix; // allow visible or not state
66
-
67
-
68
- var _useState = (0, _react.useState)(true),
69
- _useState2 = _slicedToArray(_useState, 2),
70
- flag = _useState2[0],
71
- setFlag = _useState2[1]; // visible[Tooltip/Popover] state
72
-
73
-
74
- var _useState3 = (0, _react.useState)(false),
75
- _useState4 = _slicedToArray(_useState3, 2),
76
- tipVisible = _useState4[0],
77
- setTipVisible = _useState4[1]; // copy animation state
78
-
79
-
80
- var _useState5 = (0, _react.useState)(false),
81
- _useState6 = _slicedToArray(_useState5, 2),
82
- hasCopy = _useState6[0],
83
- setHasCopy = _useState6[1];
84
-
85
- var elementRef = (0, _react.useRef)();
86
- (0, _react.useEffect)(function () {
87
- elementRef.current && isEllipsisActive(elementRef.current) ? setFlag(true) : (setFlag(false), setTipVisible(false));
88
- }); // original Node
89
-
90
- var inner = typeof children === 'string' ? children : _popover ? content : title; // for className
91
-
92
- var getClassName = function getClassName() {
93
- return "overflow ".concat(_lines ? 'ellipsis-wrap' : 'ellipsis-nowrap', " ").concat(className || '');
94
- }; // Tooltip.trigger(default 'hover') ==trigger==> onVisibleChange(visible)
95
-
96
-
97
- var handleVisibleChange = function handleVisibleChange(visible) {
98
- // const { onVisibleChange } = props;
99
- // onVisibleChange(visible);
100
- flag && setTipVisible(visible);
101
- }; // onClick Copy Button
102
-
103
-
104
- var handleCopy = function handleCopy(innerText) {
105
- (0, _copyToClipboard["default"])(innerText);
106
- setHasCopy(!hasCopy);
107
- setTimeout(function () {
108
- setHasCopy(false);
109
- }, 1000);
110
- };
111
-
112
- var renderNode = function renderNode() {
113
- var popoverNode = React.createElement(_popover2["default"], _extends({}, props, {
114
- content: content || children,
115
- visible: tipVisible,
116
- onVisibleChange: function onVisibleChange(visible) {
117
- return handleVisibleChange(visible);
118
- }
119
- }), React.createElement("div", {
120
- className: className,
121
- style: {
122
- WebkitLineClamp: _lines
123
- },
124
- ref: elementRef
125
- }, children || content));
126
- var tooltipNode = React.createElement(_tooltip["default"], _extends({}, props, {
127
- title: title || children,
128
- visible: tipVisible,
129
- onVisibleChange: function onVisibleChange(visible) {
130
- return handleVisibleChange(visible);
131
- }
132
- }), React.createElement("div", {
133
- className: className,
134
- style: {
135
- WebkitLineClamp: _lines
136
- },
137
- ref: elementRef
138
- }, children || title));
139
- return _popover ? popoverNode : tooltipNode;
140
- };
141
-
142
- return React.createElement(React.Fragment, null, React.createElement("div", {
143
- className: "tnt-ellipsis",
144
- style: _objectSpread({}, style, {
145
- maxWidth: widthLimit
146
- })
147
- }, prefix && prefix, React.createElement("div", {
148
- className: getClassName()
149
- }, inner ? renderNode() : emptyText), suffix && suffix, inner && _copyable && React.createElement("div", {
150
- className: "svg-button",
151
- onClick: function onClick() {
152
- return handleCopy(elementRef.current.innerText);
153
- }
154
- }, !hasCopy ? React.createElement(_CopySVG["default"], null) : React.createElement(_TickSVG["default"], null))));
20
+ export default props => {
21
+ let {
22
+ _popover = props.Popover, // `Popover` or `Tooltip` ?
23
+ title, // in most cases for `Tooltip`
24
+ content, // in most cases for `Popover`
25
+ className,
26
+ style,
27
+ widthLimit, // width trigger value
28
+ _lines = props.lines !== 1 && props.lines, // number or lines, default 1 line;
29
+ children, // children Node
30
+ emptyText, // default: null
31
+ _copyable = props.copyable, // copy function
32
+ prefix, // 前缀dom
33
+ suffix // 后缀dom
34
+ } = props;
35
+
36
+ // allow visible or not state
37
+ const [flag, setFlag] = useState(true);
38
+ // visible[Tooltip/Popover] state
39
+ const [tipVisible, setTipVisible] = useState(false);
40
+ // copy animation state
41
+ const [hasCopy, setHasCopy] = useState(false);
42
+
43
+ const elementRef = useRef();
44
+
45
+ useEffect(() => {
46
+ elementRef.current && isEllipsisActive(elementRef.current)
47
+ ? setFlag(true)
48
+ : (
49
+ setFlag(false),
50
+ setTipVisible(false)
51
+ );
52
+ });
53
+
54
+ // original Node
55
+ const inner = typeof children === 'string' ? children : (_popover ? content : title);
56
+
57
+ // for className
58
+ const getClassName = () => {
59
+ return `overflow ${_lines ? 'ellipsis-wrap' : 'ellipsis-nowrap'} ${className || ''}`;
60
+ };
61
+
62
+ // Tooltip.trigger(default 'hover') ==trigger==> onVisibleChange(visible)
63
+ const handleVisibleChange = (visible) => {
64
+ // const { onVisibleChange } = props;
65
+ // onVisibleChange(visible);
66
+ flag && setTipVisible(visible);
67
+ };
68
+
69
+ // onClick Copy Button
70
+ const handleCopy = (innerText) => {
71
+ copy(innerText);
72
+ setHasCopy(!hasCopy);
73
+ setTimeout(() => {
74
+ setHasCopy(false);
75
+ }, 1000);
76
+ };
77
+
78
+ const renderNode = () => {
79
+ const popoverNode = (
80
+ <Popover
81
+ {...props}
82
+ content={content || children}
83
+ visible={tipVisible}
84
+ onVisibleChange={(visible) => handleVisibleChange(visible)}
85
+ >
86
+ <div
87
+ className={className}
88
+ style={{ WebkitLineClamp: _lines }}
89
+ ref={elementRef}
90
+ >
91
+ {children || content}
92
+ </div>
93
+ </Popover>
94
+ );
95
+
96
+ const tooltipNode = (
97
+ <Tooltip
98
+ {...props}
99
+ title={title || children}
100
+ visible={tipVisible}
101
+ onVisibleChange={(visible) => handleVisibleChange(visible)}
102
+ >
103
+ <div
104
+ className={className}
105
+ style={{ WebkitLineClamp: _lines }}
106
+ ref={elementRef}
107
+ >
108
+ {children || title}
109
+ </div>
110
+ </Tooltip>
111
+ );
112
+
113
+ return _popover ? popoverNode : tooltipNode;
114
+
115
+ };
116
+
117
+ return <>
118
+ <div
119
+ className="tnt-ellipsis"
120
+ style={{
121
+ ...style,
122
+ maxWidth: widthLimit
123
+ }}
124
+ >
125
+ {/* prefix */}
126
+ {prefix && prefix}
127
+ {/* content */}
128
+ <div
129
+ className={getClassName()}
130
+ >
131
+ {inner ? renderNode() : emptyText}
132
+ </div>
133
+ {/* suffix */}
134
+ {suffix && suffix}
135
+ {/* copyable button */}
136
+ {
137
+ inner && _copyable &&
138
+ <div
139
+ className='svg-button'
140
+ onClick={() => handleCopy(elementRef.current.innerText)}
141
+ >
142
+ {
143
+ !hasCopy
144
+ ? <CopySVG />
145
+ : <TickSVG />
146
+ }
147
+ </div>
148
+ }
149
+ </div>
150
+ </>;
155
151
  };
156
-
157
- exports["default"] = _default;
@@ -1,112 +1,75 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- require("antd/lib/dropdown/style");
9
-
10
- var _dropdown = _interopRequireDefault(require("antd/lib/dropdown"));
11
-
12
- require("antd/lib/menu/style");
13
-
14
- var _menu = _interopRequireDefault(require("antd/lib/menu"));
15
-
16
- require("antd/lib/divider/style");
17
-
18
- var _divider = _interopRequireDefault(require("antd/lib/divider"));
19
-
20
- var _react = require("react");
21
-
22
- var _Icon = _interopRequireDefault(require("../Icon"));
23
-
24
- require("./index.less");
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
- 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); }
29
-
30
- 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; }
31
-
32
- 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; }
33
-
34
- var clsPrefix = 'tnt-more-menus';
35
-
36
- var _default = function _default(props) {
37
- var _lastChildPart2, _lastChildPart3;
38
-
39
- var _ref = props || {},
40
- _ref$children = _ref.children,
41
- children = _ref$children === void 0 ? [] : _ref$children,
42
- type = _ref.type,
43
- _ref$num = _ref.num,
44
- num = _ref$num === void 0 ? 3 : _ref$num,
45
- lang = _ref.lang,
46
- _ref$divider = _ref.divider,
47
- divider = _ref$divider === void 0 ? true : _ref$divider,
48
- lessOneMoreFit = _ref.lessOneMoreFit,
49
- rest = _objectWithoutProperties(_ref, ["children", "type", "num", "lang", "divider", "lessOneMoreFit"]);
50
-
51
- var newChildren = [];
52
-
53
- if (Array.isArray(children)) {
54
- newChildren = (children == null ? void 0 : children.filter(function (item) {
55
- return !!item;
56
- })) || [];
57
- } else if (children) {
58
- newChildren.push(children);
59
- }
60
-
61
- var preChildPart = newChildren,
62
- lastChildPart = null; // 只有1个时不适配
63
-
64
- if (lessOneMoreFit && newChildren.length - num === 1) {
65
- preChildPart = newChildren;
66
- } else if (newChildren && num && !isNaN(num) && newChildren.length > num) {
67
- preChildPart = newChildren.slice(0, num);
68
- lastChildPart = newChildren.slice(num);
69
- }
70
-
71
- ;
72
-
73
- if (divider && preChildPart) {
74
- var preChildLen = preChildPart.length;
75
- preChildPart = preChildPart.map(function (dom, i) {
76
- var _lastChildPart;
77
-
78
- return React.createElement(_react.Fragment, {
79
- key: i
80
- }, dom, !(i === preChildLen - 1 && !((_lastChildPart = lastChildPart) == null ? void 0 : _lastChildPart.length) // 没有更多 且 是最后一个时 不显示 Divider
81
- ) && React.createElement(_divider["default"], {
82
- type: "vertical"
83
- }));
84
- });
85
- }
1
+ import { Fragment } from 'react';
2
+ import { Dropdown, Menu, Divider } from 'antd';
3
+ import Icon from '../Icon';
4
+ import './index.less';
5
+
6
+ const clsPrefix = 'tnt-more-menus';
7
+
8
+ export default props => {
9
+ const { children = [], type, num = 3, lang, divider = true, lessOneMoreFit, ...rest } = props || {};
10
+ let newChildren = [];
11
+ if(Array.isArray(children)){
12
+ newChildren = children?.filter(item => !!item) || [];
13
+ }else if(children){
14
+ newChildren.push(children);
15
+ }
86
16
 
87
- var menu = React.createElement(_menu["default"], {
88
- className: "org-pop-opera-btn"
89
- }, (_lastChildPart2 = lastChildPart) == null ? void 0 : _lastChildPart2.map(function (child, i) {
90
- return React.createElement(_menu["default"].Item, {
91
- key: i
92
- }, child);
93
- }));
94
- return React.createElement("div", _extends({
95
- onClick: function onClick(e) {
96
- e.stopPropagation();
17
+ let [preChildPart, lastChildPart] = [newChildren, null];
18
+
19
+ // 只有1个时不适配
20
+ if (lessOneMoreFit && newChildren.length - num === 1) {
21
+ preChildPart = newChildren;
22
+ } else if (newChildren && num && !isNaN(num) && newChildren.length > num) {
23
+ preChildPart = newChildren.slice(0, num);
24
+ lastChildPart = newChildren.slice(num);
25
+ };
26
+
27
+ if (divider && preChildPart) {
28
+ const preChildLen = preChildPart.length;
29
+ preChildPart = preChildPart.map((dom, i) => (
30
+ <Fragment key = {i}>
31
+ {dom}
32
+ {
33
+ !(
34
+ i === (preChildLen - 1) &&
35
+ !lastChildPart?.length // 没有更多 且 是最后一个时 不显示 Divider
36
+ ) &&
37
+ <Divider type="vertical" />
38
+ }
39
+ </Fragment>
40
+ ));
97
41
  }
98
- }, rest), preChildPart, ((_lastChildPart3 = lastChildPart) == null ? void 0 : _lastChildPart3.length) > 0 && React.createElement(_dropdown["default"], {
99
- overlay: menu,
100
- arrow: true
101
- }, type === 'icon' ? React.createElement(_Icon["default"], {
102
- type: "more"
103
- }) : React.createElement("a", {
104
- className: "ant-dropdown-more"
105
- }, lang === 'en' ? 'More' : '更多', React.createElement("i", {
106
- className: "".concat(clsPrefix, "-dropdown-icon")
107
- }, React.createElement(_Icon["default"], {
108
- type: "down"
109
- })))));
42
+ const menu = (
43
+ <Menu className="org-pop-opera-btn">
44
+ {
45
+ lastChildPart?.map(
46
+ (child,i) => <Menu.Item key={i}>{child}</Menu.Item>
47
+ )
48
+ }
49
+ </Menu>
50
+ );
51
+
52
+ return (
53
+ <div
54
+ onClick={(e) => { e.stopPropagation(); }}
55
+ {...rest}
56
+ >
57
+ {preChildPart}
58
+ {
59
+ lastChildPart?.length > 0 &&
60
+ <Dropdown overlay={menu} arrow>
61
+ {
62
+ type === 'icon' ?
63
+ <Icon type="more" /> :
64
+ <a className="ant-dropdown-more">
65
+ {lang === 'en' ? 'More' : '更多'}
66
+ <i className={`${clsPrefix}-dropdown-icon`}>
67
+ <Icon type="down" />
68
+ </i>
69
+ </a>
70
+ }
71
+ </Dropdown>
72
+ }
73
+ </div>
74
+ );
110
75
  };
111
-
112
- exports["default"] = _default;