tntd 1.4.20 → 1.4.21

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