tntd 1.3.64 → 1.4.0

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 (170) hide show
  1. package/.eslintignore +2 -1
  2. package/babel.config.js +12 -2
  3. package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
  4. package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  5. package/dist/1.tntd.js +12 -0
  6. package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
  7. package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  8. package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  9. package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  10. package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  11. package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  12. package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
  13. package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  14. package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  15. package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  16. package/dist/stats.json +45855 -0
  17. package/dist/tntd.css +1 -0
  18. package/dist/tntd.js +15 -0
  19. package/es/ArrayInput/README.md +129 -0
  20. package/es/ArrayInput/icon.js +24 -0
  21. package/es/ArrayInput/index.js +282 -0
  22. package/es/ArrayInput/index.less +20 -0
  23. package/es/AuthContext.js +4 -0
  24. package/es/Columns/README.md +149 -0
  25. package/es/Columns/index.js +86 -0
  26. package/es/Columns/index.less +75 -0
  27. package/es/DevelopmentLogin/LoginModal.js +126 -0
  28. package/es/DevelopmentLogin/README.md +49 -0
  29. package/es/DevelopmentLogin/index.js +40 -0
  30. package/es/Ellipsis/README.md +104 -0
  31. package/es/Ellipsis/Svg/CopySVG.js +63 -0
  32. package/es/Ellipsis/Svg/TickSVG.js +41 -0
  33. package/es/Ellipsis/index.js +143 -0
  34. package/es/Ellipsis/index.less +56 -0
  35. package/es/Handle/README.md +104 -0
  36. package/es/Handle/index.js +92 -0
  37. package/es/Handle/index.less +9 -0
  38. package/es/Icon/README.md +119 -0
  39. package/es/Icon/fonts/demo.css +539 -0
  40. package/es/Icon/fonts/demo_index.html +3345 -0
  41. package/es/Icon/fonts/iconfont.css +569 -0
  42. package/es/Icon/fonts/iconfont.eot +0 -0
  43. package/es/Icon/fonts/iconfont.js +41 -0
  44. package/es/Icon/fonts/iconfont.json +975 -0
  45. package/es/Icon/fonts/iconfont.svg +440 -0
  46. package/es/Icon/fonts/iconfont.ttf +0 -0
  47. package/es/Icon/fonts/iconfont.woff +0 -0
  48. package/es/Icon/fonts/iconfont.woff2 +0 -0
  49. package/es/Icon/iconList.js +1 -0
  50. package/es/Icon/index.js +26 -0
  51. package/es/Icon/index.less +9 -0
  52. package/es/Img/Contain.js +69 -0
  53. package/es/Img/Cover.js +126 -0
  54. package/es/Img/README.md +131 -0
  55. package/es/Img/index.js +76 -0
  56. package/es/Layout/ActionsContext.js +3 -0
  57. package/es/Layout/AppList.js +233 -0
  58. package/es/Layout/Application.js +115 -0
  59. package/es/Layout/Avatar.js +116 -0
  60. package/es/Layout/CompatibleLanguage.js +179 -0
  61. package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
  62. package/es/Layout/EnterpriseLayout/Language.js +81 -0
  63. package/es/Layout/EnterpriseLayout/Theme.js +77 -0
  64. package/es/Layout/EnterpriseLayout/index.js +31 -0
  65. package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
  66. package/es/Layout/GlobalNavigation/index.js +137 -0
  67. package/es/Layout/Header.js +95 -0
  68. package/es/Layout/HeaderActions.js +107 -0
  69. package/es/Layout/HeaderNavs.js +93 -0
  70. package/es/Layout/HeaderTabs.js +264 -0
  71. package/es/Layout/Iconfont.js +4 -0
  72. package/es/Layout/Language.js +81 -0
  73. package/es/Layout/Layout.js +234 -0
  74. package/es/Layout/Logo.js +86 -0
  75. package/es/Layout/OrgAppList.js +310 -0
  76. package/es/Layout/README.md +783 -0
  77. package/es/Layout/SideMenu.js +340 -0
  78. package/es/Layout/Theme.js +107 -0
  79. package/es/Layout/checkAuth.js +29 -0
  80. package/es/Layout/createActions.js +39 -0
  81. package/es/Layout/images/avatar/empty.png +0 -0
  82. package/es/Layout/images/avatar/female1.png +0 -0
  83. package/es/Layout/images/avatar/female2.png +0 -0
  84. package/es/Layout/images/avatar/female3.png +0 -0
  85. package/es/Layout/images/avatar/female4.png +0 -0
  86. package/es/Layout/images/avatar/female5.png +0 -0
  87. package/es/Layout/images/avatar/female6.png +0 -0
  88. package/es/Layout/images/avatar/male1.png +0 -0
  89. package/es/Layout/images/avatar/male2.png +0 -0
  90. package/es/Layout/images/avatar/male3.png +0 -0
  91. package/es/Layout/images/avatar/male4.png +0 -0
  92. package/es/Layout/images/avatar/male5.png +0 -0
  93. package/es/Layout/images/avatar/male6.png +0 -0
  94. package/es/Layout/images/index.js +35 -0
  95. package/es/Layout/images/logo/baldur.svg +14 -0
  96. package/es/Layout/images/logo/bi.svg +14 -0
  97. package/es/Layout/images/logo/bridge.svg +15 -0
  98. package/es/Layout/images/logo/convert.svg +18 -0
  99. package/es/Layout/images/logo/dataocean.svg +31 -0
  100. package/es/Layout/images/logo/default.svg +19 -0
  101. package/es/Layout/images/logo/dispatch.svg +14 -0
  102. package/es/Layout/images/logo/graph.svg +26 -0
  103. package/es/Layout/images/logo/handle.svg +10 -0
  104. package/es/Layout/images/logo/indicator.svg +41 -0
  105. package/es/Layout/images/logo/kafka.svg +12 -0
  106. package/es/Layout/images/logo/logo-custom.svg +13 -0
  107. package/es/Layout/images/logo/model.svg +17 -0
  108. package/es/Layout/images/logo/mysql.svg +15 -0
  109. package/es/Layout/images/logo/orion.svg +24 -0
  110. package/es/Layout/images/logo/salaxy.svg +11 -0
  111. package/es/Layout/images/logo/storage.svg +16 -0
  112. package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
  113. package/es/Layout/images/logo/turing.svg +35 -0
  114. package/es/Layout/images/theme/theme1.svg +35 -0
  115. package/es/Layout/images/theme/theme2.svg +33 -0
  116. package/es/Layout/index.js +122 -0
  117. package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
  118. package/es/Layout/paaslayout/Header.js +77 -0
  119. package/es/Layout/paaslayout/Logo.js +22 -0
  120. package/es/Layout/paaslayout/SideMenu.js +168 -0
  121. package/es/Layout/paaslayout/index.js +235 -0
  122. package/es/Layout/storage.js +47 -0
  123. package/es/Layout/utils.js +136 -0
  124. package/es/LoadingButton/README.md +75 -0
  125. package/es/LoadingButton/index.js +45 -0
  126. package/es/Modal/README.md +59 -0
  127. package/es/Modal/index.js +96 -0
  128. package/es/Modal/index.less +86 -0
  129. package/es/Page/Box.js +74 -0
  130. package/es/Page/README.md +180 -0
  131. package/es/Page/index.js +165 -0
  132. package/es/Page/index.less +144 -0
  133. package/es/Page/utils.js +23 -0
  134. package/es/QueryForm/Field/Checkbox.js +21 -0
  135. package/es/QueryForm/Field/Select.js +80 -0
  136. package/es/QueryForm/Field/SelectInput.js +92 -0
  137. package/es/QueryForm/Field/fieldsMap.js +32 -0
  138. package/es/QueryForm/Field/index.js +157 -0
  139. package/es/QueryForm/README.md +512 -0
  140. package/es/QueryForm/createActions.js +53 -0
  141. package/es/QueryForm/index.js +384 -0
  142. package/es/QueryForm/index.less +133 -0
  143. package/es/QueryForm/useForm.js +7 -0
  144. package/es/QueryListScene/List.js +378 -0
  145. package/es/QueryListScene/QueryForm.js +166 -0
  146. package/es/QueryListScene/QueryListScene.js +76 -0
  147. package/es/QueryListScene/README.md +790 -0
  148. package/es/QueryListScene/Title.js +12 -0
  149. package/es/QueryListScene/Toolbar.js +20 -0
  150. package/es/QueryListScene/createActions.js +72 -0
  151. package/es/QueryListScene/index.js +19 -0
  152. package/es/QueryListScene/index.less +97 -0
  153. package/es/QueryListScene/useActions.js +7 -0
  154. package/es/Select/DropDownWrap.js +116 -0
  155. package/es/Select/README.md +68 -0
  156. package/es/Select/index.js +622 -0
  157. package/es/Table/README.md +109 -0
  158. package/es/Table/ResizableTable/index.js +110 -0
  159. package/es/Table/ResizableTable/index.less +36 -0
  160. package/es/Table/index.js +35 -0
  161. package/es/Title/README.md +106 -0
  162. package/es/Title/index.js +40 -0
  163. package/es/Title/index.less +170 -0
  164. package/es/index.js +19 -0
  165. package/es/locale.js +60 -0
  166. package/package.json +4 -1
  167. package/scripts/postbuild.sh +5 -0
  168. package/doc-scripts.config.js +0 -37
  169. package/doc-scripts.renderer.js +0 -11
  170. package/docs/README.md +0 -1643
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @file Title
3
+ * @author zhangyou
4
+ */
5
+ import React from 'react';
6
+ export default (function (_ref) {
7
+ var title = _ref.title,
8
+ children = _ref.children;
9
+ return React.createElement("div", {
10
+ className: "tnt-querylistscene-title"
11
+ }, React.createElement("span", null, title), React.createElement("span", null, children));
12
+ });
@@ -0,0 +1,20 @@
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 _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; }
6
+
7
+ 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; }
8
+
9
+ import cn from 'classnames';
10
+ export default (function (_ref) {
11
+ var className = _ref.className,
12
+ children = _ref.children,
13
+ actions = _ref.actions,
14
+ qslProps = _ref.qslProps,
15
+ rest = _objectWithoutProperties(_ref, ["className", "children", "actions", "qslProps"]);
16
+
17
+ return React.createElement("div", _extends({}, rest, {
18
+ className: cn('tnt-querylistscene-toolbar', _defineProperty({}, className, className))
19
+ }), children);
20
+ });
@@ -0,0 +1,72 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ import { get, set } from 'lodash';
3
+ export default (function () {
4
+ var eventEmitter = new EventEmitter();
5
+ var data = {
6
+ dataSource: [],
7
+ pagination: {},
8
+ formData: {},
9
+ submittedFormData: {}
10
+ };
11
+ return {
12
+ setData: function setData(key, val) {
13
+ set(data, key, val);
14
+ },
15
+ getFormData: function getFormData(name) {
16
+ return get(data, "formData".concat(name ? '.' + name : ''));
17
+ },
18
+ getSubmittedFormData: function getSubmittedFormData(name) {
19
+ return get(data, "submittedFormData".concat(name ? '.' + name : ''));
20
+ },
21
+ getTableDataSource: function getTableDataSource() {
22
+ return get(data, 'dataSource');
23
+ },
24
+ getPagination: function getPagination() {
25
+ return get(data, 'pagination');
26
+ },
27
+ setFormData: function setFormData(formData) {
28
+ var needSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
29
+ set('formData', formData);
30
+ eventEmitter.emit('setFormData', formData, needSearch);
31
+ },
32
+ resetFormData: function resetFormData() {
33
+ var needSearch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
34
+ eventEmitter.emit('resetFormData', needSearch);
35
+ },
36
+ setTableDataSource: function setTableDataSource(dataSource) {
37
+ set('dataSource', dataSource);
38
+ eventEmitter.emit('setTableDataSource', dataSource);
39
+ },
40
+ setPagination: function setPagination(pagination) {
41
+ set('pagination', pagination);
42
+ eventEmitter.emit('setPagination', pagination);
43
+ },
44
+ // 重置记忆数据,form、pagination
45
+ resetMemoryData: function resetMemoryData() {
46
+ data.formData = {};
47
+ data.pagination = {};
48
+ },
49
+ search: function search() {
50
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
51
+ var showLoading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
52
+ return new Promise(function (resolve, reject) {
53
+ eventEmitter.emit('search', params, {
54
+ callback: resolve,
55
+ showLoading: showLoading
56
+ });
57
+ });
58
+ },
59
+ on: function on(eventName, callback) {
60
+ eventEmitter.on(eventName, callback);
61
+ },
62
+ emit: function emit() {
63
+ eventEmitter.emit.apply(eventEmitter, arguments);
64
+ },
65
+ removeListener: function removeListener() {
66
+ eventEmitter.removeListener.apply(eventEmitter, arguments);
67
+ },
68
+ off: function off() {
69
+ eventEmitter.removeListener.apply(eventEmitter, arguments);
70
+ }
71
+ };
72
+ });
@@ -0,0 +1,19 @@
1
+ import QueryListScene from './QueryListScene';
2
+ import Title from './Title';
3
+ import Form from './QueryForm';
4
+ import Toolbar from './Toolbar';
5
+ import List from './List';
6
+ import Actions from './createActions';
7
+ import useActions from './useActions';
8
+ import './index.less';
9
+ export var QueryForm = Form;
10
+ export var QueryList = List;
11
+ export var createActions = Actions;
12
+ QueryListScene.Title = Title;
13
+ QueryListScene.QueryForm = Form;
14
+ QueryListScene.Toolbar = Toolbar;
15
+ QueryListScene.QueryList = List;
16
+ QueryListScene.Field = Form.Field;
17
+ QueryListScene.useActions = useActions;
18
+ QueryListScene.createActions = createActions;
19
+ export default QueryListScene;
@@ -0,0 +1,97 @@
1
+ .tnt-querylistscene {
2
+ position: relative;
3
+ &.large-size {
4
+ .tnt-querylistscene-title {
5
+ height: 48px;
6
+ }
7
+ }
8
+
9
+ &-title {
10
+ position: sticky;
11
+ top: 0;
12
+ height: 40px;
13
+ background: #FFFFFF;
14
+ line-height: 40px;
15
+ padding: 0 20px;
16
+ z-index: 1;
17
+
18
+ & > span {
19
+ font-size: 14px;
20
+ color: #17233D;
21
+ letter-spacing: 0;
22
+ }
23
+ }
24
+
25
+ &-toolbar {
26
+ padding: 12px 16px 12px;
27
+ background: #fff;
28
+ box-shadow: 0 0 6px 0 rgba(0,0,0,0.06);
29
+ border-radius: 4px 4px 0 0;
30
+
31
+ & > *:not(:last-child) {
32
+ margin-right: 12px;
33
+ }
34
+ }
35
+
36
+ &-content {
37
+ background: #F1F2F5;
38
+ padding: 16px 20px;
39
+ }
40
+
41
+ &-list {
42
+ background: #fff;
43
+ box-shadow: 0 0 6px 0 rgba(0,0,0,0.06);
44
+ border-radius: 4px;
45
+ .hasToolbar & {
46
+ border-radius: 0 0 4px 4px;
47
+ }
48
+
49
+ .ant-table-pagination.ant-pagination {
50
+ position: relative;
51
+ width: 100%;
52
+ text-align: right;
53
+ margin-bottom: 0;
54
+ padding: 12px 16px;
55
+ background: #fff;
56
+ margin-top: 0;
57
+ border-radius: 0 0 4px 4px;
58
+ box-shadow: 0 -2px 4px rgba(0, 0, 0, .06);
59
+ z-index: 1;
60
+ // .ant-pagination-item {
61
+ // height: 28px;
62
+ // line-height: 28px;
63
+ // &:not(.ant-pagination-item-active) {
64
+ // border: none;
65
+ // }
66
+ // }
67
+ .ant-pagination-total-text {
68
+ float: left;
69
+ }
70
+ .ant-pagination-options {
71
+ text-align: left;
72
+ }
73
+ .ant-pagination-prev,
74
+ .ant-pagination-next,
75
+ .ant-pagination-jump-prev,
76
+ .ant-pagination-jump-next {
77
+ height: 28px;
78
+ line-height: 28px;
79
+ .ant-pagination-item-link {
80
+ border: none;
81
+ }
82
+ }
83
+ }
84
+
85
+ &.paginationSticky {
86
+ .ant-table-pagination.ant-pagination {
87
+ position: sticky;
88
+ bottom: 0;
89
+ }
90
+ }
91
+ &.hasScrollToBottom {
92
+ .ant-table-pagination.ant-pagination {
93
+ box-shadow: none;
94
+ }
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,7 @@
1
+ import { useRef } from 'react';
2
+ import createActions from './createActions';
3
+ export default function useActions() {
4
+ var actions = useRef(createActions());
5
+ return actions.current;
6
+ }
7
+ ;
@@ -0,0 +1,116 @@
1
+ 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); }
2
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ 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; }
8
+
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+
11
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12
+
13
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14
+
15
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16
+
17
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
+
19
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
+
21
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
22
+
23
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
24
+
25
+ import React, { PureComponent } from 'react';
26
+
27
+ var DropDownWrap =
28
+ /*#__PURE__*/
29
+ function (_PureComponent) {
30
+ _inherits(DropDownWrap, _PureComponent);
31
+
32
+ function DropDownWrap(props) {
33
+ var _this;
34
+
35
+ _classCallCheck(this, DropDownWrap);
36
+
37
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(DropDownWrap).call(this, props));
38
+
39
+ _this.getItemStyle = function (i) {
40
+ var itemHeight = _this.props.itemHeight;
41
+ return {
42
+ position: 'absolute',
43
+ top: itemHeight * i,
44
+ height: itemHeight,
45
+ width: '100%'
46
+ };
47
+ };
48
+
49
+ _this.reactList = function (allHeight, startIndex, endIndex) {
50
+ return _this.setState({
51
+ allHeight: allHeight,
52
+ startIndex: startIndex,
53
+ endIndex: endIndex
54
+ });
55
+ };
56
+
57
+ var _allHeight = props.allHeight,
58
+ _startIndex = props.startIndex,
59
+ _endIndex = props.endIndex;
60
+ _this.state = {
61
+ allHeight: _allHeight,
62
+ startIndex: _startIndex,
63
+ endIndex: _endIndex
64
+ };
65
+ return _this;
66
+ }
67
+
68
+ _createClass(DropDownWrap, [{
69
+ key: "componentDidUpdate",
70
+ value: function componentDidUpdate(prevProps) {
71
+ if (this.props.allHeight !== prevProps.allHeight) {
72
+ this.setState({
73
+ allHeight: this.props.allHeight
74
+ });
75
+ }
76
+ }
77
+ }, {
78
+ key: "render",
79
+ value: function render() {
80
+ var _this2 = this;
81
+
82
+ var menu = this.props.menu;
83
+ var _this$state = this.state,
84
+ startIndex = _this$state.startIndex,
85
+ endIndex = _this$state.endIndex,
86
+ allHeight = _this$state.allHeight; // 截取 Select 下拉列表中需要显示的部分
87
+
88
+ var cloneMenu = React.cloneElement(menu, {
89
+ menuItems: menu.props.menuItems.slice(startIndex, endIndex).map(function (item, i) {
90
+ var realIndex = (startIndex || 0) + Number(i);
91
+
92
+ var style = _this2.getItemStyle(realIndex); // 未搜到数据提示高度使用默认高度
93
+
94
+
95
+ if (item.key === 'NOT_FOUND') {
96
+ delete style.height;
97
+ }
98
+
99
+ return React.cloneElement(item, {
100
+ style: _objectSpread({}, item.props.style, {}, style)
101
+ });
102
+ }),
103
+ dropdownMenuStyle: _objectSpread({}, menu.props.dropdownMenuStyle, {
104
+ height: allHeight,
105
+ maxHeight: allHeight,
106
+ overflow: 'hidden'
107
+ })
108
+ });
109
+ return cloneMenu;
110
+ }
111
+ }]);
112
+
113
+ return DropDownWrap;
114
+ }(PureComponent);
115
+
116
+ export { DropDownWrap as default };
@@ -0,0 +1,68 @@
1
+ ## 基于ant3实现高性能虚拟滚动列表
2
+
3
+ ## 安装
4
+ ```bash
5
+ npm i tntd
6
+ ```
7
+
8
+ ## 用法
9
+ 所有API同ant3 Select
10
+ - 注:新增maxWidth属性,该属性只有在dropdownMatchSelectWidth=false的时候才起作用,由于dropdownMatchSelectWidth=false,下拉宽度需要系统计算,同时渲染多个此组件时,会有性能消耗,故新增此属性,在渲染之前计算好下拉宽的高度,已达到性能提升。这里也提供一个算文本的像素宽度的方法,仅供参考:
11
+
12
+ ```javascript
13
+ // 获取单行文本的像素宽度
14
+ getTextPixelWith = (text, fontStyle = "14px") => {
15
+ let canvas = document.createElement("canvas"); // 创建 canvas 画布
16
+ let context = canvas.getContext("2d"); // 获取 canvas 绘图上下文环境
17
+ context.font = fontStyle; // 设置字体样式,使用前设置好对应的 font 样式才能准确获取文字的像素长度
18
+ let dimension = context.measureText(text); // 测量文字
19
+ return dimension.width;
20
+ }
21
+ ```
22
+
23
+ ### 代码演示
24
+ ```jsx
25
+ import React from 'react';
26
+ import ReactDOM from 'react-dom';
27
+ import { Select } from 'tntd';
28
+ import 'antd/dist/antd.css';
29
+
30
+ const Option = Select.Option;
31
+
32
+ const children = [];
33
+ for (let i = 0; i < 10000; i++) {
34
+ children.push(
35
+ <Option value={i} key={i}>
36
+ {`测试${i}`}
37
+ </Option>
38
+ );
39
+ }
40
+
41
+ const Demo = props => {
42
+ const handleChange = (e) => {
43
+ console.log(e);
44
+ }
45
+
46
+ return (
47
+ <Select
48
+ className="u-width"
49
+ showSearch
50
+ optionFilterProp="children"
51
+ allowClear
52
+ placeholder="请选择"
53
+ onChange={handleChange}
54
+ style={{ width: "200px" }}
55
+ dropdownMatchSelectWidth={false}
56
+ defaultValue={500}
57
+ >
58
+ {children}
59
+ </Select>
60
+ );
61
+ }
62
+
63
+ ReactDOM.render(
64
+ <Demo />,
65
+ document.getElementById('root')
66
+ );
67
+
68
+ ```