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