tntd 1.4.7 → 1.4.10

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