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,622 @@
1
+ import "antd/es/empty/style";
2
+ import _Empty from "antd/es/empty";
3
+ import "antd/es/select/style";
4
+ import _Select from "antd/es/select";
5
+
6
+ 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); }
7
+
8
+ 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; }
9
+
10
+ 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; }
11
+
12
+ 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; }
13
+
14
+ 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; }
15
+
16
+ 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; }
17
+
18
+ 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); }
19
+
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
+
22
+ 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); } }
23
+
24
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25
+
26
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
27
+
28
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
+
30
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
+
32
+ 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); }
33
+
34
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
+
36
+ import React, { PureComponent } from 'react';
37
+ import DropDownWrap from './DropDownWrap'; // 页面实际渲染的下拉菜单数量,实际为 2 * ITEM_ELEMENT_NUMBER
38
+
39
+ var ITEM_ELEMENT_NUMBER = 30; // Select size 配置
40
+
41
+ var ITEM_HEIGHT_CFG = {
42
+ small: 24,
43
+ large: 40,
44
+ "default": 32
45
+ };
46
+ var ARROW_CODE = {
47
+ 40: 'down',
48
+ 38: 'up'
49
+ };
50
+ var DROPDOWN_HEIGHT = 224;
51
+ var Option = _Select.Option;
52
+
53
+ var SuperSelect =
54
+ /*#__PURE__*/
55
+ function (_PureComponent) {
56
+ _inherits(SuperSelect, _PureComponent);
57
+
58
+ function SuperSelect(props) {
59
+ var _this;
60
+
61
+ _classCallCheck(this, SuperSelect);
62
+
63
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(SuperSelect).call(this, props));
64
+
65
+ _this.turnChildren = function (children) {
66
+ if (!children) return [];
67
+ var arr = [];
68
+
69
+ if (children && children.props) {
70
+ arr.push(children);
71
+ } else {
72
+ children.forEach(function (item) {
73
+ if (item) {
74
+ if (item instanceof Array) {
75
+ arr = arr.concat(item);
76
+ } else {
77
+ arr.push(item);
78
+ }
79
+ }
80
+ });
81
+ }
82
+
83
+ return arr;
84
+ };
85
+
86
+ _this.formulaWidth = function () {
87
+ // 获取dom设置宽度
88
+ var _this$props = _this.props,
89
+ arr2 = _this$props.children,
90
+ _this$props$dropdownM = _this$props.dropdownMatchSelectWidth,
91
+ dropdownMatchSelectWidth = _this$props$dropdownM === void 0 ? true : _this$props$dropdownM,
92
+ maxWidth = _this$props.maxWidth;
93
+ var selectDom = document.getElementById(_this.id);
94
+ var selectWidth = selectDom.clientWidth || selectDom.offsetWidth;
95
+ var arr = [];
96
+ var formulaMaxWidth = 10;
97
+
98
+ if (!dropdownMatchSelectWidth) {
99
+ formulaMaxWidth = maxWidth || 10;
100
+ }
101
+
102
+ if (!dropdownMatchSelectWidth && !maxWidth) {
103
+ var children = _this.turnChildren(arr2);
104
+
105
+ for (var i = 0; i < children.length; i++) {
106
+ var val = children[i].props.children;
107
+
108
+ var textWidth = _this.getTextPixelWith(val);
109
+
110
+ arr.push(textWidth.toFixed(2));
111
+ }
112
+
113
+ if (arr.length > 0) {
114
+ formulaMaxWidth = Math.max.apply(Math, arr);
115
+ }
116
+ }
117
+
118
+ _this.setState({
119
+ selectWidth: selectWidth,
120
+ maxWidth: formulaMaxWidth
121
+ });
122
+ };
123
+
124
+ _this.getTextPixelWith = function (text) {
125
+ var fontStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '14px';
126
+ var canvas = document.createElement('canvas'); // 创建 canvas 画布
127
+
128
+ var context = canvas.getContext('2d'); // 获取 canvas 绘图上下文环境
129
+
130
+ context.font = fontStyle; // 设置字体样式,使用前设置好对应的 font 样式才能准确获取文字的像素长度
131
+
132
+ var dimension = context.measureText(text); // 测量文字
133
+
134
+ return dimension.width;
135
+ };
136
+
137
+ _this.getItemStyle = function (i) {
138
+ return {
139
+ position: 'absolute',
140
+ top: _this.ITEM_HEIGHT * i,
141
+ width: '100%',
142
+ height: _this.ITEM_HEIGHT
143
+ };
144
+ };
145
+
146
+ _this.addEvent = function () {
147
+ _this.scrollEle = document.querySelector(".".concat(_this.dropdownClassName)); // 下拉菜单未展开时元素不存在
148
+
149
+ if (!_this.scrollEle) return;
150
+
151
+ _this.scrollEle.addEventListener('scroll', _this.onScroll, false);
152
+
153
+ _this.inputEle = document.querySelector("#".concat(_this.id));
154
+ if (!_this.inputEle) return;
155
+
156
+ _this.inputEle.addEventListener('keydown', _this.onKeyDown, false);
157
+ };
158
+
159
+ _this.onKeyDown = function (e) {
160
+ var _ref = e || {},
161
+ keyCode = _ref.keyCode;
162
+
163
+ setTimeout(function () {
164
+ var activeItem = document.querySelector(".".concat(_this.dropdownClassName, " .ant-select-dropdown-menu-item-active"));
165
+ if (!activeItem) return;
166
+ var offsetTop = activeItem.offsetTop;
167
+ var isUp = ARROW_CODE[keyCode] === 'up';
168
+ var isDown = ARROW_CODE[keyCode] === 'down'; // 在所有列表第一行按上键
169
+
170
+ if (offsetTop - _this.prevTop > DROPDOWN_HEIGHT && isUp) {
171
+ _this.scrollEle.scrollTo(0, _this.allHeight - DROPDOWN_HEIGHT);
172
+
173
+ _this.prevTop = _this.allHeight;
174
+ return;
175
+ } // 在所有列表中最后一行按下键
176
+
177
+
178
+ if (_this.prevTop > offsetTop + DROPDOWN_HEIGHT && isDown) {
179
+ _this.scrollEle.scrollTo(0, 0);
180
+
181
+ _this.prevTop = 0;
182
+ return;
183
+ }
184
+
185
+ _this.prevTop = offsetTop; // 向下滚动到下拉框最后一行时,向下滚动一行的高度
186
+
187
+ if (offsetTop > _this.scrollEle.scrollTop + DROPDOWN_HEIGHT - _this.ITEM_HEIGHT + 10 && isDown) {
188
+ _this.scrollEle.scrollTo(0, _this.scrollTop + _this.ITEM_HEIGHT);
189
+
190
+ return;
191
+ } // 向上滚动到下拉框第一一行时,向上滚动一行的高度
192
+
193
+
194
+ if (offsetTop < _this.scrollEle.scrollTop && isUp) {
195
+ _this.scrollEle.scrollTo(0, _this.scrollTop - _this.ITEM_HEIGHT);
196
+ }
197
+ }, 100);
198
+ };
199
+
200
+ _this.onScroll = function () {
201
+ return _this.throttleByHeight(_this.onScrollReal);
202
+ };
203
+
204
+ _this.onScrollReal = function () {
205
+ _this.allList = _this.getUseChildrenList();
206
+
207
+ var _this$getStartAndEndI = _this.getStartAndEndIndex(),
208
+ startIndex = _this$getStartAndEndI.startIndex,
209
+ endIndex = _this$getStartAndEndI.endIndex;
210
+
211
+ _this.prevScrollTop = _this.scrollTop; // 重新渲染列表组件 Wrap
212
+
213
+ var allHeight = _this.allList.length * _this.ITEM_HEIGHT || 100;
214
+
215
+ _this.wrap.reactList(allHeight, startIndex, endIndex);
216
+ };
217
+
218
+ _this.throttleByHeight = function () {
219
+ _this.scrollTop = _this.scrollEle.scrollTop; // 滚动的高度
220
+
221
+ var delta = _this.prevScrollTop - _this.scrollTop;
222
+ delta = delta < 0 ? 0 - delta : delta;
223
+ delta > _this.reactDelta && _this.onScrollReal();
224
+ };
225
+
226
+ _this.getUseChildrenList = function () {
227
+ return _this.state.filterChildren || _this.state.children;
228
+ };
229
+
230
+ _this.getStartAndEndIndex = function () {
231
+ // 滚动后显示在列表可视区中的第一个 item 的 index
232
+ var showIndex = Number((_this.scrollTop / _this.ITEM_HEIGHT).toFixed(0));
233
+ var startIndex = showIndex - ITEM_ELEMENT_NUMBER < 0 ? 0 : showIndex - ITEM_ELEMENT_NUMBER / 2;
234
+ var endIndex = showIndex + ITEM_ELEMENT_NUMBER;
235
+ return {
236
+ startIndex: startIndex,
237
+ endIndex: endIndex
238
+ };
239
+ };
240
+
241
+ _this.setSuperDrowDownMenu = function (visible) {
242
+ if (!visible) return;
243
+ _this.allList = _this.getUseChildrenList();
244
+
245
+ if (!_this.eventTimer || !_this.scrollEle) {
246
+ _this.eventTimer = setTimeout(function () {
247
+ return _this.addEvent();
248
+ }, 0);
249
+ } else {
250
+ var allHeight = _this.allList.length * _this.ITEM_HEIGHT || 100; // 下拉列表单独重新渲染
251
+
252
+ var _this$getStartAndEndI2 = _this.getStartAndEndIndex(),
253
+ startIndex = _this$getStartAndEndI2.startIndex,
254
+ endIndex = _this$getStartAndEndI2.endIndex;
255
+
256
+ setTimeout(function () {
257
+ _this.wrap && _this.wrap.reactList(allHeight, startIndex, endIndex);
258
+ }, 0);
259
+ }
260
+ };
261
+
262
+ _this.onDropdownVisibleChange = function (visible) {
263
+ var onDropdownVisibleChange = _this.props.onDropdownVisibleChange;
264
+ onDropdownVisibleChange && onDropdownVisibleChange(visible);
265
+ var _this$state = _this.state,
266
+ value = _this$state.value,
267
+ children = _this$state.children; // 关闭下拉框前清空筛选条件,防止下次打开任然显示筛选后的 options
268
+
269
+ if (!visible) {
270
+ // 定时器确保关闭后再设置 filterChildren,防止列表刷新闪烁
271
+ setTimeout(function () {
272
+ _this.setState({
273
+ filterChildren: null
274
+ });
275
+
276
+ _this.setDefaultScrollTop(value);
277
+ }, 100); // this.removeEvent();
278
+ } else {
279
+ // this.addEvent();
280
+ if (value) {
281
+ // 如果已有 value, 设置默认滚动位置
282
+ _this.setDefaultScrollTop(); // 设置下拉列表显示数据
283
+
284
+
285
+ _this.setSuperDrowDownMenu(visible);
286
+ } else if (!value && value !== 0 && children && children.length > 0) {
287
+ // 无数据时,下拉回归至第一个
288
+ var val = children[0].props.value;
289
+
290
+ _this.setDefaultScrollTop(val);
291
+ }
292
+ }
293
+ };
294
+
295
+ _this.onDeselect = function (value) {
296
+ var onDeselect = _this.props.onDeselect;
297
+ onDeselect && onDeselect(value);
298
+ };
299
+
300
+ _this.onChange = function (value, opt) {
301
+ var _this$props2 = _this.props,
302
+ showSearch = _this$props2.showSearch,
303
+ onChange = _this$props2.onChange,
304
+ autoClearSearchValue = _this$props2.autoClearSearchValue,
305
+ maxCount = _this$props2.maxCount,
306
+ mode = _this$props2.mode;
307
+
308
+ if (showSearch || _this.isMultiple) {
309
+ // 搜索模式下选择后是否需要重置搜索状态
310
+ if (autoClearSearchValue !== false) {
311
+ _this.setState({
312
+ filterChildren: null
313
+ }, function () {
314
+ // 搜索成功后重新设置列表的总高度
315
+ _this.setSuperDrowDownMenu(true);
316
+ });
317
+ }
318
+ }
319
+
320
+ if (mode === 'multiple') {
321
+ if (value.length <= maxCount) {
322
+ _this.setState({
323
+ value: value
324
+ });
325
+ }
326
+ } else {
327
+ _this.setState({
328
+ value: value
329
+ });
330
+ }
331
+
332
+ onChange && onChange(value, opt);
333
+
334
+ if (mode !== 'multiple') {
335
+ _this.select && _this.select.blur();
336
+ }
337
+ };
338
+
339
+ _this.onSearch = function (v) {
340
+ var _this$props3 = _this.props,
341
+ showSearch = _this$props3.showSearch,
342
+ onSearch = _this$props3.onSearch,
343
+ filterOption = _this$props3.filterOption,
344
+ arr = _this$props3.children;
345
+
346
+ var children = _this.turnChildren(arr);
347
+
348
+ if (showSearch && filterOption !== false) {
349
+ // 须根据 filterOption(如有该自定义函数)手动 filter 搜索匹配的列表
350
+ var filterChildren = null;
351
+
352
+ if (typeof filterOption === 'function') {
353
+ filterChildren = children.filter(function (item) {
354
+ return filterOption(v, item);
355
+ });
356
+ } else if (filterOption === undefined) {
357
+ filterChildren = children.filter(function (item) {
358
+ return _this.filterOption(v, item);
359
+ });
360
+ } // 搜索框有值,去除disabled=true的children
361
+
362
+
363
+ var newFilterChild = [];
364
+ filterChildren && filterChildren.forEach(function (item, index) {
365
+ if (!item.props.disabled) {
366
+ newFilterChild.push(item);
367
+ }
368
+ });
369
+ filterChildren = newFilterChild; // 设置下拉列表显示数据
370
+
371
+ _this.setState({
372
+ filterChildren: v === '' ? null : filterChildren
373
+ }, function () {
374
+ setTimeout(function () {
375
+ // 搜索后需要重置滚动位置到0,防止上次 scrollTop 位置无数据
376
+ if (filterChildren) {
377
+ _this.scrollTop = 0;
378
+
379
+ _this.scrollEle.scrollTo(0, 0);
380
+ } // 搜索成功后需要重新设置列表的总高度
381
+
382
+
383
+ _this.setSuperDrowDownMenu(true);
384
+ }, 0);
385
+ });
386
+ }
387
+
388
+ onSearch && onSearch(v);
389
+ };
390
+
391
+ _this.filterOption = function (v, option) {
392
+ // 自定义过滤对应的 option 属性配置
393
+ var filterProps = _this.props.optionFilterProp || 'value';
394
+ return "".concat(option.props[filterProps]).indexOf(v) >= 0;
395
+ };
396
+
397
+ _this.setDefaultScrollTop = function (data) {
398
+ var value = _this.state.value;
399
+ var arr = _this.props.children;
400
+
401
+ var children = _this.turnChildren(arr);
402
+
403
+ var val = data || data === 0 ? data : value;
404
+
405
+ for (var i = 0; i < children.length; i++) {
406
+ var item = children[i];
407
+ var itemValue = item.props.value;
408
+
409
+ if (itemValue === val || Array.isArray(val) && val.includes(itemValue)) {
410
+ var _ret = function () {
411
+ var targetScrollTop = i * _this.ITEM_HEIGHT;
412
+ setTimeout(function () {
413
+ if (!_this.scrollEle) {
414
+ _this.addEvent();
415
+ }
416
+
417
+ _this.scrollEle && _this.scrollEle.scrollTo(0, targetScrollTop);
418
+ }, 100);
419
+ return {
420
+ v: void 0
421
+ };
422
+ }();
423
+
424
+ if (_typeof(_ret) === "object") return _ret.v;
425
+ }
426
+ }
427
+ };
428
+
429
+ _this.removeEvent = function () {
430
+ if (!_this.scrollEle) return;
431
+
432
+ _this.scrollEle.removeEventListener('scroll', _this.onScroll, false);
433
+
434
+ if (!_this.inputEle) return;
435
+
436
+ _this.inputEle.removeEventListener('keydown', _this.onKeyDown, false);
437
+ };
438
+
439
+ var _mode = props.mode,
440
+ defaultValue = props.defaultValue,
441
+ _value = props.value,
442
+ optionHeight = props.optionHeight,
443
+ _arr = props.children;
444
+ _this.isMultiple = ['tags', 'multiple'].includes(_mode);
445
+
446
+ var _children = _this.turnChildren(_arr); // 设置默认 value
447
+
448
+
449
+ var defaultV = _this.isMultiple ? [] : '';
450
+ defaultV = _value || defaultValue || defaultV;
451
+ _this.state = {
452
+ children: _children || [],
453
+ filterChildren: null,
454
+ // 筛选后的 options,优先显示,所以清除筛选后手动设为 null
455
+ value: defaultV,
456
+ maxWidth: null,
457
+ selectWidth: null
458
+ }; // 下拉菜单项行高
459
+
460
+ _this.ITEM_HEIGHT = optionHeight || ITEM_HEIGHT_CFG[props.size || 'default']; // 可视区 dom 高度
461
+
462
+ _this.visibleDomHeight = _this.ITEM_HEIGHT * ITEM_ELEMENT_NUMBER; // 滚动时重新渲染的 scrollTop 判断值,大于 reactDelta 则刷新下拉列表
463
+
464
+ _this.reactDelta = _this.visibleDomHeight / 3; // 是否拖动滚动条快速滚动状态
465
+
466
+ _this.isStopReact = false; // 上一次滚动的 scrollTop 值
467
+
468
+ _this.prevScrollTop = 0; // 上一次按下方向键时 scrollTop 值
469
+
470
+ _this.prevTop = 0;
471
+ _this.scrollTop = 0; // className
472
+
473
+ _this.dropdownClassName = "dc".concat(+new Date());
474
+ _this.id = "sid".concat(+new Date());
475
+ return _this;
476
+ }
477
+
478
+ _createClass(SuperSelect, [{
479
+ key: "componentDidMount",
480
+ value: function componentDidMount() {
481
+ var _this2 = this;
482
+
483
+ // defaultOpens=true 时添加滚动事件
484
+ setTimeout(function () {
485
+ _this2.addEvent();
486
+ }, 500);
487
+ var arr = this.props.children;
488
+ var children = this.turnChildren(arr);
489
+
490
+ if (children && children.length > 0) {
491
+ this.formulaWidth();
492
+ }
493
+ }
494
+ }, {
495
+ key: "componentDidUpdate",
496
+ value: function componentDidUpdate(prevProps) {
497
+ var _this$props4 = this.props,
498
+ mode = _this$props4.mode,
499
+ defaultValue = _this$props4.defaultValue,
500
+ value = _this$props4.value,
501
+ children = _this$props4.children;
502
+ var arr = this.turnChildren(children);
503
+
504
+ if (prevProps.children !== children) {
505
+ this.isMultiple = ['tags', 'multiple'].includes(mode);
506
+ this.setState({
507
+ children: arr || [],
508
+ filterChildren: null
509
+ });
510
+
511
+ if (arr && arr.length > 0) {
512
+ this.formulaWidth();
513
+ }
514
+ }
515
+
516
+ if (prevProps.value !== value) {
517
+ // 更新时设置默认 value
518
+ var defaultV = this.isMultiple ? [] : '';
519
+ defaultV = value || defaultValue || defaultV;
520
+ this.setState({
521
+ value: defaultV
522
+ });
523
+ }
524
+ }
525
+ }, {
526
+ key: "componentWillUnmount",
527
+ value: function componentWillUnmount() {
528
+ this.removeEvent();
529
+ }
530
+ }, {
531
+ key: "render",
532
+ value: function render() {
533
+ var _this3 = this;
534
+
535
+ var _this$state2 = this.state,
536
+ maxWidth = _this$state2.maxWidth,
537
+ selectWidth = _this$state2.selectWidth;
538
+
539
+ var _this$props5 = this.props,
540
+ dropdownStyle = _this$props5.dropdownStyle,
541
+ optionLabelProp = _this$props5.optionLabelProp,
542
+ dropdownClassName = _this$props5.dropdownClassName,
543
+ props = _objectWithoutProperties(_this$props5, ["dropdownStyle", "optionLabelProp", "dropdownClassName"]);
544
+
545
+ this.allList = this.getUseChildrenList();
546
+ this.allHeight = this.allList.length * this.ITEM_HEIGHT || 100;
547
+
548
+ var _this$getStartAndEndI3 = this.getStartAndEndIndex(),
549
+ startIndex = _this$getStartAndEndI3.startIndex,
550
+ endIndex = _this$getStartAndEndI3.endIndex;
551
+
552
+ var dynamicWidth = maxWidth;
553
+
554
+ if (this.allList.length === 0 || maxWidth < selectWidth) {
555
+ dynamicWidth = selectWidth;
556
+ }
557
+
558
+ dropdownStyle = _objectSpread({
559
+ maxHeight: "".concat(DROPDOWN_HEIGHT, "px")
560
+ }, dropdownStyle, {
561
+ overflow: 'auto',
562
+ position: 'relative',
563
+ maxWidth: dynamicWidth
564
+ });
565
+ var value = this.state.value; // 判断处于 antd Form 中时不自动设置 value
566
+
567
+ var _props = _objectSpread({}, props); // 先删除 value,再手动赋值,防止空 value 影响 placeholder
568
+
569
+
570
+ delete _props.value; // value 为空字符会隐藏 placeholder,改为 undefined
571
+
572
+ if (typeof value === 'string' && !value) {
573
+ _props.value = undefined;
574
+ } else {
575
+ _props.value = value;
576
+ }
577
+
578
+ optionLabelProp = optionLabelProp || 'children';
579
+ return React.createElement(_Select, _extends({}, _props, {
580
+ id: this.id,
581
+ onSearch: this.onSearch,
582
+ onChange: this.onChange,
583
+ dropdownClassName: "".concat(this.dropdownClassName, " ").concat(dropdownClassName || ''),
584
+ optionLabelProp: optionLabelProp,
585
+ dropdownStyle: dropdownStyle,
586
+ onDropdownVisibleChange: this.onDropdownVisibleChange,
587
+ onDeselect: this.onDeselect,
588
+ ref: function ref(ele) {
589
+ return _this3.select = ele;
590
+ },
591
+ dropdownRender: function dropdownRender(menu, props) {
592
+ if (_this3.allList.length === 0) {
593
+ return React.createElement("div", {
594
+ style: {
595
+ padding: '5px 12px'
596
+ }
597
+ }, React.createElement(_Empty, {
598
+ image: _Empty.PRESENTED_IMAGE_SIMPLE
599
+ }));
600
+ }
601
+
602
+ return React.createElement(DropDownWrap, _extends({
603
+ startIndex: startIndex,
604
+ endIndex: endIndex,
605
+ allHeight: _this3.allHeight,
606
+ menu: menu,
607
+ itemHeight: _this3.ITEM_HEIGHT
608
+ }, {
609
+ ref: function ref(ele) {
610
+ _this3.wrap = ele;
611
+ }
612
+ }));
613
+ }
614
+ }), this.allList);
615
+ }
616
+ }]);
617
+
618
+ return SuperSelect;
619
+ }(PureComponent);
620
+
621
+ SuperSelect.Option = Option;
622
+ export default SuperSelect;