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