tntd 1.4.32 → 1.4.33-beta.1

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