@hi-ui/hiui 2.15.10 → 2.15.11
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/CHANGELOG.md +3 -0
- package/es/_util/warning.js +2 -2
- package/es/alert/__test__/index.test.js +67 -0
- package/es/alert/index.js +147 -6
- package/es/alert/style/index.css +1 -1
- package/es/badge/index.js +87 -9
- package/es/badge/style/index.css +1 -1
- package/es/badge/style/index.js +0 -0
- package/es/button/Button.js +51 -59
- package/es/button/ButtonGroup.js +31 -23
- package/es/button/IconLoading.js +2 -2
- package/es/button/__test__/index.test.js +29 -0
- package/es/button/index.js +2 -3
- package/es/button/style/index.css +1 -1
- package/es/card/index.js +42 -54
- package/es/card/style/index.css +1 -1
- package/es/cascader/Cascader.js +116 -181
- package/es/cascader/__test__/index.test.js +283 -0
- package/es/cascader/index.js +2 -5
- package/es/cascader/menu.js +155 -0
- package/es/cascader/style/cascader.css +1 -1
- package/es/cascader/style/menu.css +1 -1
- package/es/checkbox/{checkbox-legacy/Base.js → Base.js} +31 -46
- package/es/checkbox/CheckBox.js +185 -0
- package/es/checkbox/index.js +4 -13
- package/es/checkbox/style/index.css +1 -1
- package/es/collapse/__test__/index.test.js +58 -0
- package/es/collapse/index.js +93 -79
- package/es/collapse/style/index.css +1 -1
- package/es/confirm/index.js +50 -37
- package/es/context/index.js +37 -39
- package/es/counter/__test__/index.test.js +52 -0
- package/es/counter/index.js +270 -6
- package/es/counter/style/index.css +1 -1
- package/es/date-picker/BasePicker.js +288 -374
- package/es/date-picker/Calender.js +90 -326
- package/es/date-picker/DatePanel.js +186 -175
- package/es/date-picker/DatePicker.js +51 -151
- package/es/date-picker/DateRangePanel.js +181 -253
- package/es/date-picker/Modal.js +25 -15
- package/es/date-picker/Time.js +336 -230
- package/es/date-picker/TimePanel.js +32 -27
- package/es/date-picker/TimePeriodPanel.js +32 -21
- package/es/date-picker/TimePicker.js +40 -42
- package/es/date-picker/TimeRangePanel.js +42 -32
- package/es/date-picker/Type.js +1 -5
- package/es/date-picker/WeekRangePanel.js +150 -237
- package/es/date-picker/constants.js +28 -14
- package/es/date-picker/dateUtil.js +52 -221
- package/es/date-picker/index.js +2 -5
- package/es/date-picker/style/index.css +1 -1
- package/es/date-picker/util.js +8 -101
- package/es/dropdown/Dropdown.js +199 -193
- package/es/dropdown/{tests → __test__}/index.test.js +2 -2
- package/es/dropdown/index.js +4 -73
- package/es/dropdown/style/index.css +1 -1
- package/es/dropdown/style/index.js +2 -0
- package/es/ficon/index.js +23 -13
- package/es/form/index.js +171 -6
- package/es/form/{Item.js → item.js} +53 -53
- package/es/form/style/index.css +1 -1
- package/es/grid/index.js +37 -25
- package/es/icon/index.js +32 -21
- package/es/index.js +9 -61
- package/es/input/index.js +345 -28
- package/es/input/style/index.css +1 -1
- package/es/input/util.js +18 -26
- package/es/lib/withDragDropContext.js +2 -2
- package/es/loading/index.js +129 -5
- package/es/loading/style/index.css +0 -0
- package/es/loading/style/index.js +0 -0
- package/es/locales/en-US.js +11 -45
- package/es/locales/index.js +2 -16
- package/es/locales/zh-CN.js +12 -46
- package/es/menu/Item.js +41 -32
- package/es/menu/ItemGroup.js +81 -0
- package/es/menu/SubMenu.js +74 -55
- package/es/menu/Title.js +42 -36
- package/es/menu/index.js +419 -12
- package/es/menu/style/index.css +1 -1
- package/es/modal/__test__/index.test.js +123 -0
- package/es/modal/index.js +61 -77
- package/es/modal/style/index.css +1 -1
- package/es/nav-menu/NavMenu.js +45 -31
- package/es/nav-menu/__test__/index.test.js +2 -2
- package/es/nav-menu/index.js +2 -2
- package/es/notification/__test__/index.test.js +56 -0
- package/es/notification/index.js +231 -68
- package/es/notification/style/index.css +1 -1
- package/es/notification/style/index.js +0 -0
- package/es/pagination/Pager.js +8 -6
- package/es/pagination/Pagination.js +115 -124
- package/es/pagination/__test__/index.test.js +140 -0
- package/es/pagination/index.js +8 -9
- package/es/pagination/style/index.css +1 -1
- package/es/panel/index.js +33 -23
- package/es/popover/__test__/index.test.js +2 -2
- package/es/popover/index.js +69 -71
- package/es/popper/index.js +54 -64
- package/es/popper/style/index.css +1 -1
- package/es/progress/BarProgress.js +43 -109
- package/es/progress/CircleProgress.js +10 -9
- package/es/progress/DashboardProgress.js +9 -7
- package/es/progress/index.js +100 -8
- package/es/progress/style/index.css +1 -1
- package/es/radio/{radio-legacy/__test__ → __test__}/index.test.js +10 -10
- package/es/radio/index.js +216 -10
- package/es/radio/style/index.css +1 -1
- package/es/rate/Icons.js +2 -2
- package/es/rate/Rate.js +90 -65
- package/es/rate/__test__/index.test.js +54 -0
- package/es/rate/index.js +2 -5
- package/es/rate/style/index.css +1 -1
- package/es/select/Option.js +93 -0
- package/es/select/Select.js +253 -325
- package/es/select/SelectDropdown.js +63 -215
- package/es/select/SelectInput.js +54 -88
- package/es/select/__test__/index.test.js +429 -0
- package/es/select/index.js +4 -6
- package/es/select/style/select-dropdown.css +1 -1
- package/es/select/style/select-input.css +1 -1
- package/es/stepper/index.js +127 -21
- package/es/stepper/style/index.css +1 -1
- package/es/style/color/colors.css +0 -0
- package/es/style/icon/diyIcon.css +1 -1
- package/es/style/icon/index.css +1 -1
- package/es/style/index.css +0 -0
- package/es/style/mixins/colors.css +0 -0
- package/es/style/mixins/index.css +0 -0
- package/es/style/theme/dark.css +0 -0
- package/es/style/theme/default.css +0 -0
- package/es/switch/{__tests__ → __test__}/index.test.js +2 -31
- package/es/switch/index.js +36 -24
- package/es/switch/style/index.css +1 -1
- package/es/table/__test__/index.test.js +73 -0
- package/es/table/{Body.js → body.js} +52 -36
- package/es/table/checkbox/index.js +36 -33
- package/es/table/clickOuterside.js +115 -0
- package/es/table/{Footer.js → footer.js} +41 -24
- package/es/table/{Header.js → header.js} +54 -41
- package/es/table/index.js +300 -262
- package/es/table/menu/index.js +34 -32
- package/es/table/pover.js +154 -0
- package/es/table/prefix.js +2 -2
- package/es/table/style/Table.css +1 -1
- package/es/table/style/index.css +1 -1
- package/es/table/tableContent.js +120 -0
- package/es/tabs/ItemDropdown.js +51 -39
- package/es/tabs/TabPane.js +35 -25
- package/es/tabs/Tabs.js +91 -98
- package/es/tabs/index.js +3 -9
- package/es/tabs/style/index.css +1 -1
- package/es/timeline/__test__/index.test.js +49 -0
- package/es/timeline/foldingItem.js +82 -0
- package/es/timeline/index.js +127 -203
- package/es/timeline/style/index.css +1 -1
- package/es/tooltip/__test__/index.test.js +67 -0
- package/es/tooltip/index.js +39 -86
- package/es/tooltip/style/index.css +1 -1
- package/es/transfer/Item.js +44 -53
- package/es/transfer/__test__/index.test.js +11 -0
- package/es/transfer/index.js +443 -4
- package/es/transfer/style/index.css +1 -1
- package/es/tree/Tree.js +86 -76
- package/es/tree/TreeDivider.js +3 -3
- package/es/tree/TreeItem.js +108 -204
- package/es/tree/TreeNode.js +318 -457
- package/es/tree/index.js +2 -9
- package/es/tree/style/index.css +1 -1
- package/es/tree/util.js +257 -9
- package/es/upload/{upload-legacy/Preview.js → Preview.js} +39 -33
- package/es/upload/Upload.js +193 -289
- package/es/upload/UploadAvatar.js +58 -44
- package/es/upload/UploadClick.js +45 -49
- package/es/upload/UploadDrag.js +43 -44
- package/es/upload/UploadPhoto.js +55 -70
- package/es/upload/UploadPictureCard.js +44 -39
- package/es/upload/index.js +71 -8
- package/es/upload/style/index.css +1 -1
- package/es/upload/tool.js +1 -0
- package/package.json +4 -1
- package/es/_util/SwitchVersion.js +0 -44
- package/es/_util/depreactedPropsCompat.js +0 -58
- package/es/_util/index.js +0 -32
- package/es/alert/Alert.js +0 -134
- package/es/alert/__tests__/index.test.js +0 -88
- package/es/badge/Badge.js +0 -90
- package/es/badge/__tests__/index.test.js +0 -82
- package/es/breadcrumb/__tests__/index.test.js +0 -61
- package/es/breadcrumb/index.js +0 -93
- package/es/breadcrumb/style/index.css +0 -1
- package/es/button/__tests__/index.test.js +0 -219
- package/es/card/__tests__/index.test.js +0 -169
- package/es/carousel/__tests__/index.test.js +0 -104
- package/es/carousel/index.js +0 -227
- package/es/carousel/style/index.css +0 -1
- package/es/carousel/style/index.js +0 -3
- package/es/cascader/Menu.js +0 -174
- package/es/cascader/__tests__/index.test.js +0 -389
- package/es/checkbox/Checkbox.js +0 -144
- package/es/checkbox/Group.js +0 -202
- package/es/checkbox/__tests__/index.test.js +0 -226
- package/es/checkbox/checkbox-legacy/CheckBox.js +0 -165
- package/es/checkbox/checkbox-legacy/index.js +0 -15
- package/es/checkbox/checkbox-legacy/style/index.css +0 -1
- package/es/checkbox/checkbox-legacy/style/index.js +0 -3
- package/es/collapse/__tests__/index.test.js +0 -111
- package/es/counter/Counter.js +0 -343
- package/es/counter/__tests__/index.test.js +0 -134
- package/es/counter/counter-legacy/index.js +0 -271
- package/es/date-picker/TimeList.js +0 -254
- package/es/date-picker/YMRangePanel.js +0 -372
- package/es/date-picker/__tests__/index.test.js +0 -961
- package/es/date-picker/datepicker-legacy/BasePicker.js +0 -519
- package/es/date-picker/datepicker-legacy/Calender.js +0 -430
- package/es/date-picker/datepicker-legacy/DatePanel.js +0 -463
- package/es/date-picker/datepicker-legacy/DatePicker.js +0 -107
- package/es/date-picker/datepicker-legacy/DateRangePanel.js +0 -496
- package/es/date-picker/datepicker-legacy/Modal.js +0 -71
- package/es/date-picker/datepicker-legacy/Time.js +0 -413
- package/es/date-picker/datepicker-legacy/TimePanel.js +0 -93
- package/es/date-picker/datepicker-legacy/TimePeriodPanel.js +0 -126
- package/es/date-picker/datepicker-legacy/TimePicker.js +0 -82
- package/es/date-picker/datepicker-legacy/TimeRangePanel.js +0 -98
- package/es/date-picker/datepicker-legacy/Type.js +0 -31
- package/es/date-picker/datepicker-legacy/WeekRangePanel.js +0 -345
- package/es/date-picker/datepicker-legacy/constants.js +0 -79
- package/es/date-picker/datepicker-legacy/dateUtil.js +0 -258
- package/es/date-picker/datepicker-legacy/index.js +0 -15
- package/es/date-picker/datepicker-legacy/local.js +0 -11
- package/es/date-picker/datepicker-legacy/style/index.css +0 -1
- package/es/date-picker/datepicker-legacy/style/index.js +0 -3
- package/es/date-picker/datepicker-legacy/style/timepicker.css +0 -1
- package/es/date-picker/datepicker-legacy/util.js +0 -60
- package/es/date-picker/toLunar.js +0 -172
- package/es/dropdown/DropdownButton.js +0 -106
- package/es/dropdown/DropdownMenu.js +0 -111
- package/es/dropdown/DropdownMenuItem.js +0 -178
- package/es/dropdown/__tests__/index.test.js +0 -317
- package/es/dropdown/utils.js +0 -35
- package/es/form/Form.js +0 -184
- package/es/form/__tests__/index.test.js +0 -575
- package/es/grid/__tests__/index.test.js +0 -104
- package/es/input/Input.js +0 -412
- package/es/input/__tests__/index.test.js +0 -381
- package/es/input/input-legacy/index.js +0 -353
- package/es/input/input-legacy/util.js +0 -176
- package/es/loading/Loading.js +0 -181
- package/es/loading/__tests__/index.test.js +0 -110
- package/es/locales/zh-Hant-HK.js +0 -121
- package/es/locales/zh-Hant-TW.js +0 -123
- package/es/menu/Menu.js +0 -422
- package/es/menu/__tests__/index.test.js +0 -279
- package/es/message/__tests__/index.test.js +0 -75
- package/es/message/index.js +0 -58
- package/es/message/style/index.css +0 -1
- package/es/message/style/index.js +0 -5
- package/es/modal/__tests__/index.test.js +0 -178
- package/es/nav-menu/__tests__/index.test.js +0 -27
- package/es/notice/Notice.js +0 -142
- package/es/notice/NoticeContainer.js +0 -113
- package/es/notice/__tests__/index.test.js +0 -174
- package/es/notice/index.js +0 -66
- package/es/notice/style/index.css +0 -1
- package/es/notice/style/index.js +0 -5
- package/es/notification/HandleNotification/index.js +0 -224
- package/es/notification/HandleNotification/style/index.css +0 -1
- package/es/notification/HandleNotification/style/index.js +0 -5
- package/es/notification/__tests__/index.test.js +0 -118
- package/es/pagination/__tests__/index.test.js +0 -248
- package/es/popover/__tests__/index.test.js +0 -152
- package/es/preview/index.js +0 -527
- package/es/preview/style/index.css +0 -1
- package/es/preview/style/index.js +0 -3
- package/es/progress/Progress.js +0 -110
- package/es/progress/__tests__/index.test.js +0 -131
- package/es/radio/Group.js +0 -203
- package/es/radio/Radio.js +0 -151
- package/es/radio/__tests__/index.test.js +0 -128
- package/es/radio/radio-legacy/index.js +0 -222
- package/es/radio/radio-legacy/style/index.css +0 -1
- package/es/radio/radio-legacy/style/index.js +0 -3
- package/es/rate/__tests__/index.test.js +0 -124
- package/es/select/__tests__/index.test.js +0 -505
- package/es/select/select-legacy/Option.js +0 -81
- package/es/select/select-legacy/Select.js +0 -710
- package/es/select/select-legacy/SelectDropdown.js +0 -164
- package/es/select/select-legacy/SelectInput.js +0 -312
- package/es/select/select-legacy/common.js +0 -19
- package/es/select/select-legacy/index.js +0 -16
- package/es/stepper/Stepper.js +0 -151
- package/es/stepper/__tests__/index.test.js +0 -161
- package/es/table/ClickOuterside.js +0 -103
- package/es/table/TableContent.js +0 -109
- package/es/table/__tests__/index.test.js +0 -133
- package/es/table/checkbox/style/index.css +0 -1
- package/es/table/checkbox/style/index.js +0 -3
- package/es/tabs/__tests__/index.test.js +0 -333
- package/es/tabs/tabs-legacy/ItemDropdown.js +0 -170
- package/es/tabs/tabs-legacy/TabPane.js +0 -78
- package/es/tabs/tabs-legacy/Tabs.js +0 -299
- package/es/tabs/tabs-legacy/index.js +0 -18
- package/es/tabs/tabs-legacy/style/index.css +0 -1
- package/es/tabs/tabs-legacy/style/index.js +0 -3
- package/es/tag/__tests__/index.test.js +0 -46
- package/es/tag/index.js +0 -94
- package/es/tag/style/index.css +0 -1
- package/es/tag/style/index.js +0 -3
- package/es/timeline/__tests__/index.test.js +0 -198
- package/es/tooltip/__tests__/index.test.js +0 -170
- package/es/transfer/Transfer.js +0 -566
- package/es/transfer/__tests__/index.test.js +0 -210
- package/es/tree/IconLoading.js +0 -38
- package/es/tree/__tests__/index.test.js +0 -603
- package/es/tree/tree-legacy/Tree.js +0 -337
- package/es/tree/tree-legacy/TreeDivider.js +0 -25
- package/es/tree/tree-legacy/TreeItem.js +0 -333
- package/es/tree/tree-legacy/TreeNode.js +0 -719
- package/es/tree/tree-legacy/index.js +0 -13
- package/es/tree/tree-legacy/style/index.css +0 -1
- package/es/tree/tree-legacy/style/index.js +0 -3
- package/es/tree/tree-legacy/util.js +0 -434
- package/es/upload/__tests__/index.test.js +0 -760
- package/es/upload/main.js +0 -91
- package/es/upload/upload-legacy/Upload.js +0 -435
- package/es/upload/upload-legacy/UploadAvatar.js +0 -322
- package/es/upload/upload-legacy/UploadClick.js +0 -125
- package/es/upload/upload-legacy/UploadDrag.js +0 -180
- package/es/upload/upload-legacy/UploadPhoto.js +0 -183
- package/es/upload/upload-legacy/UploadPictureCard.js +0 -126
- package/es/upload/upload-legacy/index.js +0 -75
- package/es/upload/upload-legacy/style/index.css +0 -1
- package/es/upload/upload-legacy/style/index.js +0 -5
- package/es/upload/upload-legacy/tool.js +0 -84
- package/es/watermark/index.js +0 -101
- package/es/watermark/watermark.js +0 -252
- /package/es/checkbox/{checkbox-legacy/common.js → common.js} +0 -0
- /package/es/{breadcrumb/style → style}/index.js +0 -0
- /package/es/upload/{upload-legacy/style → style}/preview.css +0 -0
- /package/es/upload/{upload-legacy/style → style}/preview.js +0 -0
package/es/select/Select.js
CHANGED
|
@@ -1,34 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
6
|
exports["default"] = void 0;
|
|
11
7
|
|
|
12
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
-
|
|
18
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
|
-
|
|
20
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
21
|
-
|
|
22
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
23
|
-
|
|
24
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
25
|
-
|
|
26
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
27
|
-
|
|
28
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
29
|
-
|
|
30
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
|
-
|
|
32
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
33
9
|
|
|
34
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
@@ -37,6 +13,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
37
13
|
|
|
38
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
39
15
|
|
|
16
|
+
var _shallowequal = _interopRequireDefault(require("shallowequal"));
|
|
17
|
+
|
|
40
18
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
41
19
|
|
|
42
20
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
@@ -51,24 +29,58 @@ var _context = _interopRequireDefault(require("../context"));
|
|
|
51
29
|
|
|
52
30
|
var _fetchJsonp = _interopRequireDefault(require("fetch-jsonp"));
|
|
53
31
|
|
|
54
|
-
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
|
+
|
|
34
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
35
|
+
|
|
36
|
+
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; }
|
|
37
|
+
|
|
38
|
+
function _typeof(obj) { "@babel/helpers - typeof"; 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 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; }
|
|
55
41
|
|
|
56
|
-
var
|
|
42
|
+
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; }
|
|
57
43
|
|
|
58
|
-
function
|
|
44
|
+
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; }
|
|
59
45
|
|
|
60
|
-
function
|
|
46
|
+
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; }
|
|
61
47
|
|
|
62
|
-
function
|
|
48
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
63
49
|
|
|
64
|
-
function
|
|
50
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
65
51
|
|
|
66
|
-
function
|
|
52
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
67
53
|
|
|
68
|
-
function
|
|
54
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
55
|
+
|
|
56
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
57
|
+
|
|
58
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
59
|
+
|
|
60
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
61
|
+
|
|
62
|
+
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); } }
|
|
63
|
+
|
|
64
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
65
|
+
|
|
66
|
+
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); }
|
|
67
|
+
|
|
68
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
69
|
+
|
|
70
|
+
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); }; }
|
|
71
|
+
|
|
72
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
73
|
+
|
|
74
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
75
|
+
|
|
76
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
77
|
+
|
|
78
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
79
|
+
|
|
80
|
+
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; }
|
|
69
81
|
|
|
70
82
|
var Select = /*#__PURE__*/function (_Component) {
|
|
71
|
-
(
|
|
83
|
+
_inherits(Select, _Component);
|
|
72
84
|
|
|
73
85
|
var _super = _createSuper(Select);
|
|
74
86
|
|
|
@@ -76,15 +88,13 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
76
88
|
function Select(props) {
|
|
77
89
|
var _this;
|
|
78
90
|
|
|
79
|
-
(
|
|
91
|
+
_classCallCheck(this, Select);
|
|
92
|
+
|
|
80
93
|
_this = _super.call(this, props);
|
|
81
|
-
|
|
82
|
-
(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputClick", function (e) {
|
|
94
|
+
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "autoloadFlag", true);
|
|
96
|
+
|
|
97
|
+
_defineProperty(_assertThisInitialized(_this), "handleInputClick", function (e) {
|
|
88
98
|
var dropdownShow = _this.state.dropdownShow;
|
|
89
99
|
|
|
90
100
|
if (dropdownShow) {
|
|
@@ -93,49 +103,44 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
93
103
|
return;
|
|
94
104
|
}
|
|
95
105
|
|
|
96
|
-
|
|
106
|
+
_this.selectInput.focus();
|
|
97
107
|
|
|
98
108
|
if (_this.props.disabled) {
|
|
99
109
|
return;
|
|
100
110
|
}
|
|
101
111
|
|
|
102
|
-
if (dropdownShow
|
|
112
|
+
if (!dropdownShow) {
|
|
103
113
|
_this.showDropdown();
|
|
104
114
|
}
|
|
105
115
|
});
|
|
106
|
-
var data = props.data,
|
|
107
|
-
value = props.value,
|
|
108
|
-
defaultValue = props.defaultValue,
|
|
109
|
-
autoload = props.autoload;
|
|
110
|
-
var dropdownItems = (0, _cloneDeep["default"])(data);
|
|
111
|
-
var initialValue = value === undefined ? defaultValue : value;
|
|
112
116
|
|
|
113
|
-
var
|
|
117
|
+
var list = _this.props.list;
|
|
118
|
+
var dropdownItems = (0, _cloneDeep["default"])(list);
|
|
119
|
+
|
|
120
|
+
var selectedItems = _this.resetSelectedItems(_this.props.value, dropdownItems);
|
|
114
121
|
|
|
115
122
|
var searchable = _this.getSearchable();
|
|
116
123
|
|
|
117
|
-
_this.debouncedFilterItems = (0, _debounce["default"])(_this.onFilterItems.bind((
|
|
118
|
-
_this.clickOutsideHandel = _this.clickOutside.bind((
|
|
124
|
+
_this.debouncedFilterItems = (0, _debounce["default"])(_this.onFilterItems.bind(_assertThisInitialized(_this)), 300);
|
|
125
|
+
_this.clickOutsideHandel = _this.clickOutside.bind(_assertThisInitialized(_this)); // const focusedIndex = this.resetFocusedIndex(false)
|
|
126
|
+
|
|
119
127
|
_this.state = {
|
|
120
128
|
searchable: searchable,
|
|
121
129
|
queryLength: 1,
|
|
122
130
|
focusedIndex: 0,
|
|
123
|
-
stateAutoload: autoload,
|
|
124
131
|
selectedItems: selectedItems,
|
|
125
|
-
cacheSelectedItems: selectedItems,
|
|
126
132
|
dropdownItems: dropdownItems,
|
|
127
133
|
dropdownShow: false,
|
|
128
134
|
fetching: false,
|
|
129
135
|
keyword: '',
|
|
130
|
-
filterText: '',
|
|
131
136
|
searchInput: {
|
|
132
|
-
width:
|
|
137
|
+
width: '2px'
|
|
133
138
|
}
|
|
134
139
|
};
|
|
135
140
|
return _this;
|
|
136
141
|
}
|
|
137
142
|
|
|
138
|
-
(
|
|
143
|
+
_createClass(Select, [{
|
|
139
144
|
key: "getChildContext",
|
|
140
145
|
value: function getChildContext() {
|
|
141
146
|
return {
|
|
@@ -165,7 +170,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
165
170
|
value: function clickOutside(e) {
|
|
166
171
|
var selectInput = _reactDom["default"].findDOMNode(this.selectInput);
|
|
167
172
|
|
|
168
|
-
if (selectInput && selectInput.contains(e.target)
|
|
173
|
+
if (selectInput && selectInput.contains(e.target)) {
|
|
169
174
|
return;
|
|
170
175
|
}
|
|
171
176
|
|
|
@@ -173,40 +178,23 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
173
178
|
}
|
|
174
179
|
}, {
|
|
175
180
|
key: "componentWillReceiveProps",
|
|
176
|
-
value: function componentWillReceiveProps(
|
|
177
|
-
if (!
|
|
178
|
-
var selectedItems = this.resetSelectedItems(
|
|
181
|
+
value: function componentWillReceiveProps(props) {
|
|
182
|
+
if (!(0, _shallowequal["default"])(props.value, this.props.value)) {
|
|
183
|
+
var selectedItems = this.resetSelectedItems(props.value, this.state.dropdownItems); // 异步获取时会从内部改变dropdownItems,所以不能从list取
|
|
184
|
+
|
|
179
185
|
this.setState({
|
|
180
|
-
selectedItems: selectedItems
|
|
181
|
-
|
|
182
|
-
dropdownItems: (0, _cloneDeep["default"])(nextProps.data)
|
|
186
|
+
selectedItems: selectedItems
|
|
187
|
+
}, function () {// this.onChange()
|
|
183
188
|
});
|
|
184
|
-
}
|
|
185
|
-
var type = nextProps.type,
|
|
186
|
-
value = nextProps.value,
|
|
187
|
-
dataSource = nextProps.dataSource;
|
|
188
|
-
var oldValue = this.props.value;
|
|
189
|
-
|
|
190
|
-
if (!_lodash["default"].isEqual(value, oldValue)) {
|
|
191
|
-
var _this$state = this.state,
|
|
192
|
-
_this$state$dropdownI = _this$state.dropdownItems,
|
|
193
|
-
dropdownItems = _this$state$dropdownI === void 0 ? [] : _this$state$dropdownI,
|
|
194
|
-
stateSelectedItems = _this$state.selectedItems,
|
|
195
|
-
cacheSelectedItems = _this$state.cacheSelectedItems;
|
|
196
|
-
|
|
197
|
-
var _selectedItems2 = this.resetSelectedItems(value, dataSource && this.state.keyword === '' && !this.state.stateAutoload ? cacheSelectedItems : dropdownItems, type === 'multiple' ? _lodash["default"].cloneDeep(stateSelectedItems) : []);
|
|
198
|
-
|
|
199
|
-
if (Array.isArray(value)) {
|
|
200
|
-
_selectedItems2 = _selectedItems2.filter(function (item) {
|
|
201
|
-
return value.includes(item.id);
|
|
202
|
-
});
|
|
203
|
-
} // 异步获取时会从内部改变dropdownItems,所以不能从list取
|
|
189
|
+
}
|
|
204
190
|
|
|
191
|
+
if (!(0, _shallowequal["default"])(props.list, this.props.list)) {
|
|
192
|
+
var _selectedItems2 = this.resetSelectedItems(props.value, props.list, true);
|
|
205
193
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
194
|
+
this.setState({
|
|
195
|
+
selectedItems: _selectedItems2,
|
|
196
|
+
dropdownItems: (0, _cloneDeep["default"])(props.list)
|
|
197
|
+
});
|
|
210
198
|
}
|
|
211
199
|
}
|
|
212
200
|
}, {
|
|
@@ -216,9 +204,12 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
216
204
|
|
|
217
205
|
if (this.isRemote()) {
|
|
218
206
|
return true;
|
|
219
|
-
}
|
|
207
|
+
} // if(mode==='multiple' && searchable===undefined) {
|
|
208
|
+
// return true
|
|
209
|
+
// }
|
|
220
210
|
|
|
221
|
-
|
|
211
|
+
|
|
212
|
+
return !!searchable;
|
|
222
213
|
}
|
|
223
214
|
}, {
|
|
224
215
|
key: "parseValue",
|
|
@@ -226,13 +217,9 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
226
217
|
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.value;
|
|
227
218
|
|
|
228
219
|
if (Array.isArray(value)) {
|
|
229
|
-
return value.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
} else {
|
|
233
|
-
return v;
|
|
234
|
-
}
|
|
235
|
-
});
|
|
220
|
+
return value.slice();
|
|
221
|
+
} else if (typeof value === 'string') {
|
|
222
|
+
return value.split(',');
|
|
236
223
|
} else {
|
|
237
224
|
return [value];
|
|
238
225
|
}
|
|
@@ -240,62 +227,65 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
240
227
|
}, {
|
|
241
228
|
key: "isRemote",
|
|
242
229
|
value: function isRemote() {
|
|
243
|
-
var
|
|
244
|
-
|
|
245
|
-
onSearch = _this$props.onSearch;
|
|
246
|
-
return onSearch || dataSource;
|
|
230
|
+
var origin = this.props.origin;
|
|
231
|
+
return origin && !!origin.url;
|
|
247
232
|
}
|
|
248
233
|
}, {
|
|
249
234
|
key: "resetSelectedItems",
|
|
250
|
-
value: function resetSelectedItems(value) {
|
|
251
|
-
var
|
|
252
|
-
var reviceSelectedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
235
|
+
value: function resetSelectedItems(value, dropdownItems) {
|
|
236
|
+
var listChanged = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
253
237
|
var values = this.parseValue(value);
|
|
254
|
-
var selectedItems = [];
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
238
|
+
var selectedItems = listChanged && this.props.mode === 'multiple' ? this.state.selectedItems : []; // 如果是多选,dropdownItems有改动,需要保留之前的选中值
|
|
239
|
+
|
|
240
|
+
dropdownItems && dropdownItems.map(function (item) {
|
|
241
|
+
if (values.indexOf(item.id) !== -1) {
|
|
242
|
+
var itemIndex = selectedItems.findIndex(function (sItem) {
|
|
243
|
+
// 多选时检查是否已选中
|
|
244
|
+
return sItem.id === item.id;
|
|
245
|
+
});
|
|
246
|
+
itemIndex === -1 && selectedItems.push(item);
|
|
258
247
|
}
|
|
259
248
|
});
|
|
260
|
-
return
|
|
249
|
+
return selectedItems;
|
|
250
|
+
}
|
|
251
|
+
}, {
|
|
252
|
+
key: "addOption",
|
|
253
|
+
value: function addOption(option) {
|
|
254
|
+
var values = this.parseValue();
|
|
255
|
+
this.state.dropdownItems.push(option);
|
|
256
|
+
values.indexOf(option.id) > -1 && this.state.selectedItems.push(option);
|
|
257
|
+
this.forceUpdate();
|
|
261
258
|
}
|
|
262
259
|
}, {
|
|
263
260
|
key: "onEnterSelect",
|
|
264
261
|
value: function onEnterSelect() {
|
|
265
|
-
var _this$
|
|
266
|
-
dropdownItems = _this$
|
|
267
|
-
focusedIndex = _this$
|
|
262
|
+
var _this$state = this.state,
|
|
263
|
+
dropdownItems = _this$state.dropdownItems,
|
|
264
|
+
focusedIndex = _this$state.focusedIndex;
|
|
268
265
|
var item = dropdownItems[focusedIndex];
|
|
269
266
|
this.onClickOption(item, focusedIndex);
|
|
270
267
|
}
|
|
271
268
|
}, {
|
|
272
269
|
key: "onChange",
|
|
273
|
-
value: function onChange(
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
value = _this$props2.value;
|
|
277
|
-
value === undefined && this.setState({
|
|
278
|
-
selectedItems: selectedItems
|
|
279
|
-
}, callback);
|
|
280
|
-
var selectedIds = selectedItems.map(function (_ref) {
|
|
281
|
-
var id = _ref.id;
|
|
282
|
-
return id;
|
|
283
|
-
});
|
|
284
|
-
onChange && onChange(selectedIds, changedItems);
|
|
270
|
+
value: function onChange(changedItems) {
|
|
271
|
+
var selectedItems = this.state.selectedItems;
|
|
272
|
+
this.props.onChange && this.props.onChange(selectedItems, changedItems);
|
|
285
273
|
}
|
|
286
274
|
}, {
|
|
287
275
|
key: "checkAll",
|
|
288
|
-
value: function checkAll(
|
|
276
|
+
value: function checkAll(e) {
|
|
289
277
|
var _this2 = this;
|
|
290
278
|
|
|
291
279
|
// 全选
|
|
292
280
|
e && e.stopPropagation();
|
|
293
|
-
var
|
|
281
|
+
var _this$state2 = this.state,
|
|
282
|
+
dropdownItems = _this$state2.dropdownItems,
|
|
283
|
+
selectedItems = _this$state2.selectedItems;
|
|
294
284
|
|
|
295
|
-
var _selectedItems = (
|
|
285
|
+
var _selectedItems = _toConsumableArray(selectedItems);
|
|
296
286
|
|
|
297
287
|
var changedItems = [];
|
|
298
|
-
|
|
288
|
+
dropdownItems.forEach(function (item) {
|
|
299
289
|
if (!item.disabled && _this2.matchFilter(item)) {
|
|
300
290
|
if (!_selectedItems.map(function (selectItem) {
|
|
301
291
|
return selectItem.id;
|
|
@@ -306,7 +296,13 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
306
296
|
}
|
|
307
297
|
}
|
|
308
298
|
});
|
|
309
|
-
this.
|
|
299
|
+
this.setState({
|
|
300
|
+
selectedItems: _selectedItems
|
|
301
|
+
}, function () {
|
|
302
|
+
_this2.selectInput.focus();
|
|
303
|
+
|
|
304
|
+
_this2.onChange(changedItems);
|
|
305
|
+
});
|
|
310
306
|
}
|
|
311
307
|
}, {
|
|
312
308
|
key: "onClickOption",
|
|
@@ -317,7 +313,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
317
313
|
var selectedItems = this.state.selectedItems.concat();
|
|
318
314
|
var focusedIndex = index;
|
|
319
315
|
|
|
320
|
-
if (this.props.
|
|
316
|
+
if (this.props.mode === 'multiple') {
|
|
321
317
|
var itemIndex = this.state.selectedItems.findIndex(function (sItem) {
|
|
322
318
|
return sItem.id === item.id;
|
|
323
319
|
});
|
|
@@ -331,21 +327,21 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
331
327
|
selectedItems = [item];
|
|
332
328
|
}
|
|
333
329
|
|
|
334
|
-
this.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
330
|
+
this.setState({
|
|
331
|
+
selectedItems: selectedItems,
|
|
332
|
+
focusedIndex: focusedIndex
|
|
333
|
+
}, function () {
|
|
334
|
+
if (_this3.props.mode !== 'multiple') {
|
|
335
|
+
_this3.hideDropdown();
|
|
336
|
+
} else {
|
|
337
|
+
_this3.selectInput.focus();
|
|
338
|
+
|
|
339
|
+
_this3.clearKeyword(); // 多选状态清空筛选
|
|
338
340
|
|
|
339
|
-
if (_this3.props.type !== 'multiple') {
|
|
340
|
-
_this3.setState({
|
|
341
|
-
cacheSelectedItems: selectedItems
|
|
342
|
-
});
|
|
343
341
|
}
|
|
344
|
-
});
|
|
345
342
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
343
|
+
_this3.onChange(item);
|
|
344
|
+
});
|
|
349
345
|
}
|
|
350
346
|
}, {
|
|
351
347
|
key: "clearKeyword",
|
|
@@ -366,10 +362,6 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
366
362
|
this.state.dropdownShow === true && this.setState({
|
|
367
363
|
dropdownShow: false
|
|
368
364
|
}, function () {
|
|
369
|
-
_this5.setState({
|
|
370
|
-
cacheSelectedItems: _this5.state.selectedItems
|
|
371
|
-
});
|
|
372
|
-
|
|
373
365
|
_this5.clearKeyword();
|
|
374
366
|
});
|
|
375
367
|
}
|
|
@@ -379,6 +371,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
379
371
|
this.state.dropdownShow === false && this.setState({
|
|
380
372
|
dropdownShow: true
|
|
381
373
|
});
|
|
374
|
+
this.selectInput.focus();
|
|
382
375
|
}
|
|
383
376
|
}, {
|
|
384
377
|
key: "deleteItem",
|
|
@@ -391,9 +384,13 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
391
384
|
return obj.id === item.id;
|
|
392
385
|
});
|
|
393
386
|
selectedItems.splice(sIndex, 1);
|
|
394
|
-
this.
|
|
395
|
-
|
|
396
|
-
},
|
|
387
|
+
this.setState({
|
|
388
|
+
selectedItems: selectedItems
|
|
389
|
+
}, function () {
|
|
390
|
+
_this6.selectInput.focus();
|
|
391
|
+
|
|
392
|
+
_this6.onChange(item);
|
|
393
|
+
});
|
|
397
394
|
} // 全部删除
|
|
398
395
|
|
|
399
396
|
}, {
|
|
@@ -401,106 +398,75 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
401
398
|
value: function deleteAllItems() {
|
|
402
399
|
var _this7 = this;
|
|
403
400
|
|
|
404
|
-
var type = this.props.type;
|
|
405
401
|
var focusedIndex = this.resetFocusedIndex();
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
402
|
+
|
|
403
|
+
var changedItems = _toConsumableArray(this.state.selectedItems);
|
|
404
|
+
|
|
405
|
+
this.setState({
|
|
406
|
+
focusedIndex: focusedIndex,
|
|
407
|
+
selectedItems: []
|
|
408
|
+
}, function () {
|
|
409
|
+
_this7.onChange(_this7.props.mode === 'multiple' ? changedItems : changedItems[0]);
|
|
411
410
|
|
|
412
411
|
_this7.onFilterItems('');
|
|
413
|
-
}
|
|
412
|
+
});
|
|
414
413
|
}
|
|
415
414
|
}, {
|
|
416
415
|
key: "remoteSearch",
|
|
417
416
|
value: function remoteSearch(keyword) {
|
|
418
417
|
var _this8 = this;
|
|
419
418
|
|
|
420
|
-
var _this$
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
419
|
+
var _this$props$origin = this.props.origin,
|
|
420
|
+
url = _this$props$origin.url,
|
|
421
|
+
func = _this$props$origin.func,
|
|
422
|
+
error = _this$props$origin.error,
|
|
423
|
+
_this$props$origin$da = _this$props$origin.data,
|
|
424
|
+
data = _this$props$origin$da === void 0 ? {} : _this$props$origin$da,
|
|
425
|
+
_this$props$origin$ty = _this$props$origin.type,
|
|
426
|
+
type = _this$props$origin$ty === void 0 ? 'GET' : _this$props$origin$ty,
|
|
427
|
+
_this$props$origin$ke = _this$props$origin.key,
|
|
428
|
+
key = _this$props$origin$ke === void 0 ? 'keyword' : _this$props$origin$ke,
|
|
429
|
+
_this$props$origin$js = _this$props$origin.jsonpCallback,
|
|
430
|
+
jsonpCallback = _this$props$origin$js === void 0 ? 'callback' : _this$props$origin$js,
|
|
431
|
+
options = _objectWithoutProperties(_this$props$origin, ["url", "func", "error", "data", "type", "key", "jsonpCallback"]);
|
|
432
|
+
|
|
433
|
+
keyword = !keyword && this.autoloadFlag && this.props.autoload ? this.props.origin.keyword : keyword;
|
|
434
|
+
this.autoloadFlag = false; // 第一次自动加载数据后,输入的关键词即使为空也不再使用默认关键词
|
|
435
|
+
|
|
436
|
+
url = url.indexOf('?') === -1 ? "".concat(url, "?").concat([key], "=").concat(keyword) : "".concat(url, "&").concat([key], "=").concat(keyword);
|
|
437
|
+
|
|
438
|
+
if (type.toUpperCase() === 'POST') {
|
|
439
|
+
options.body = JSON.stringify(data);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
this.setState({
|
|
443
|
+
fetching: true
|
|
444
|
+
});
|
|
425
445
|
|
|
426
|
-
if (
|
|
427
|
-
|
|
428
|
-
|
|
446
|
+
if (type.toUpperCase() === 'JSONP') {
|
|
447
|
+
var _o = {
|
|
448
|
+
jsonpCallback: jsonpCallback,
|
|
449
|
+
jsonpCallbackFunction: jsonpCallback
|
|
450
|
+
};
|
|
451
|
+
(0, _fetchJsonp["default"])(url, _o).then(function (res) {
|
|
452
|
+
return res.json();
|
|
453
|
+
}).then(function (json) {
|
|
454
|
+
_this8._setDropdownItems(json, func);
|
|
429
455
|
});
|
|
430
|
-
|
|
456
|
+
} else {
|
|
457
|
+
window.fetch(url, _objectSpread({
|
|
458
|
+
method: type
|
|
459
|
+
}, options)).then(function (response) {
|
|
460
|
+
return response.json();
|
|
461
|
+
}).then(function (res) {
|
|
462
|
+
_this8._setDropdownItems(res, func);
|
|
463
|
+
}, function (err) {
|
|
464
|
+
error && error(err);
|
|
465
|
+
|
|
431
466
|
_this8.setState({
|
|
432
467
|
fetching: false
|
|
433
468
|
});
|
|
434
469
|
});
|
|
435
|
-
} else {
|
|
436
|
-
var _dataSource = typeof dataSource === 'function' ? dataSource(keyword) : dataSource;
|
|
437
|
-
|
|
438
|
-
var url = _dataSource.url,
|
|
439
|
-
transformResponse = _dataSource.transformResponse,
|
|
440
|
-
error = _dataSource.error,
|
|
441
|
-
params = _dataSource.params,
|
|
442
|
-
headers = _dataSource.headers,
|
|
443
|
-
mode = _dataSource.mode,
|
|
444
|
-
_dataSource$data = _dataSource.data,
|
|
445
|
-
data = _dataSource$data === void 0 ? {} : _dataSource$data,
|
|
446
|
-
_dataSource$type = _dataSource.type,
|
|
447
|
-
type = _dataSource$type === void 0 ? 'GET' : _dataSource$type,
|
|
448
|
-
key = _dataSource.key,
|
|
449
|
-
_dataSource$withCrede = _dataSource.withCredentials,
|
|
450
|
-
withCredentials = _dataSource$withCrede === void 0 ? propsWithCredentials : _dataSource$withCrede,
|
|
451
|
-
_dataSource$jsonpCall = _dataSource.jsonpCallback,
|
|
452
|
-
jsonpCallback = _dataSource$jsonpCall === void 0 ? 'callback' : _dataSource$jsonpCall,
|
|
453
|
-
options = (0, _objectWithoutProperties2["default"])(_dataSource, ["url", "transformResponse", "error", "params", "headers", "mode", "data", "type", "key", "withCredentials", "jsonpCallback"]);
|
|
454
|
-
keyword = !keyword && this.autoloadFlag && autoload ? _dataSource.keyword : keyword;
|
|
455
|
-
this.autoloadFlag = false; // 第一次自动加载数据后,输入的关键词即使为空也不再使用默认关键词
|
|
456
|
-
|
|
457
|
-
Object.assign(options, {
|
|
458
|
-
mode: mode
|
|
459
|
-
}, {
|
|
460
|
-
headers: headers
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
var queryParams = _qs["default"].stringify(Object.assign({}, params, key && (0, _defineProperty2["default"])({}, key, keyword)));
|
|
464
|
-
|
|
465
|
-
if (!_lodash["default"].isEmpty(queryParams)) {
|
|
466
|
-
url = url.includes('?') ? "".concat(url, "&").concat(queryParams) : "".concat(url, "?").concat(queryParams);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
if (type.toUpperCase() === 'POST') {
|
|
470
|
-
options.body = JSON.stringify(data);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
this.setState({
|
|
474
|
-
fetching: true
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
if (type.toUpperCase() === 'JSONP') {
|
|
478
|
-
var _o = {
|
|
479
|
-
jsonpCallback: jsonpCallback,
|
|
480
|
-
jsonpCallbackFunction: jsonpCallback
|
|
481
|
-
};
|
|
482
|
-
(0, _fetchJsonp["default"])(url, _o).then(function (res) {
|
|
483
|
-
return res.json();
|
|
484
|
-
}).then(function (json) {
|
|
485
|
-
_this8._setDropdownItems(json, transformResponse);
|
|
486
|
-
});
|
|
487
|
-
} else {
|
|
488
|
-
/* eslint-disable */
|
|
489
|
-
fetch(url, _objectSpread({
|
|
490
|
-
method: type,
|
|
491
|
-
credentials: withCredentials ? 'include' : 'same-origin'
|
|
492
|
-
}, options)).then(function (response) {
|
|
493
|
-
return response.json();
|
|
494
|
-
}).then(function (res) {
|
|
495
|
-
_this8._setDropdownItems(res, transformResponse);
|
|
496
|
-
}, function (err) {
|
|
497
|
-
error && error(err);
|
|
498
|
-
|
|
499
|
-
_this8.setState({
|
|
500
|
-
fetching: false
|
|
501
|
-
});
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
470
|
}
|
|
505
471
|
}
|
|
506
472
|
}, {
|
|
@@ -515,8 +481,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
515
481
|
}
|
|
516
482
|
|
|
517
483
|
if (Array.isArray(dropdownItems)) {
|
|
518
|
-
var
|
|
519
|
-
var selectedItems = this.resetSelectedItems(this.props.value, dropdownItems, _lodash["default"].cloneDeep(reviceSelectedItems));
|
|
484
|
+
var selectedItems = this.resetSelectedItems(this.props.value, dropdownItems, true);
|
|
520
485
|
this.setState({
|
|
521
486
|
dropdownItems: dropdownItems,
|
|
522
487
|
selectedItems: selectedItems
|
|
@@ -532,44 +497,28 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
532
497
|
value: function onFilterItems(keyword) {
|
|
533
498
|
var _this9 = this;
|
|
534
499
|
|
|
535
|
-
var _this$props4 = this.props,
|
|
536
|
-
onSearch = _this$props4.onSearch,
|
|
537
|
-
dataSource = _this$props4.dataSource,
|
|
538
|
-
autoload = _this$props4.autoload;
|
|
539
500
|
this.setState({
|
|
540
501
|
keyword: keyword
|
|
541
502
|
}, function () {
|
|
542
503
|
return _this9.resetFocusedIndex();
|
|
543
504
|
});
|
|
544
505
|
|
|
545
|
-
if (
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
if (autoload && this.state.stateAutoload || keyword && keyword.length >= this.state.queryLength) {
|
|
506
|
+
if (this.props.origin) {
|
|
507
|
+
// this.setState({
|
|
508
|
+
// dropdownItems: []
|
|
509
|
+
// })
|
|
510
|
+
if (this.props.autoload || keyword.toString().length >= this.state.queryLength) {
|
|
553
511
|
this.remoteSearch(keyword);
|
|
554
512
|
}
|
|
555
|
-
} else if (onSearch) {
|
|
556
|
-
this.remoteSearch(keyword);
|
|
557
513
|
}
|
|
558
514
|
}
|
|
559
515
|
}, {
|
|
560
516
|
key: "matchFilter",
|
|
561
517
|
value: function matchFilter(item) {
|
|
562
|
-
var filterOption = this.props.filterOption;
|
|
563
518
|
var _this$state3 = this.state,
|
|
564
519
|
searchable = _this$state3.searchable,
|
|
565
520
|
keyword = _this$state3.keyword;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (typeof filterOption === "function") {
|
|
569
|
-
return shouldMatch || filterOption(keyword, item);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
return shouldMatch || String(item.id).includes(keyword) || String(item.title).includes(keyword);
|
|
521
|
+
return this.isRemote() || !searchable || !keyword || searchable && keyword && (String(item.id).includes(keyword) || String(item.name).includes(keyword));
|
|
573
522
|
}
|
|
574
523
|
}, {
|
|
575
524
|
key: "resetFocusedIndex",
|
|
@@ -607,7 +556,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
607
556
|
var focusedIndex = this.state.focusedIndex;
|
|
608
557
|
var dropdownItems = this.state.dropdownItems;
|
|
609
558
|
|
|
610
|
-
if (direction ===
|
|
559
|
+
if (direction === 'up') {
|
|
611
560
|
dropdownItems.slice(0, focusedIndex).reverse().every(function (item) {
|
|
612
561
|
focusedIndex--;
|
|
613
562
|
|
|
@@ -649,43 +598,36 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
649
598
|
value: function render() {
|
|
650
599
|
var _this12 = this;
|
|
651
600
|
|
|
652
|
-
var _this$
|
|
653
|
-
|
|
654
|
-
showCheckAll = _this$
|
|
655
|
-
className = _this$
|
|
656
|
-
disabled = _this$
|
|
657
|
-
clearable = _this$
|
|
658
|
-
style = _this$
|
|
659
|
-
children = _this$
|
|
660
|
-
optionWidth = _this$
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
_onClick = _this$
|
|
664
|
-
onBlur = _this$
|
|
665
|
-
onFocus = _this$
|
|
666
|
-
|
|
667
|
-
filterOption = _this$props5.filterOption,
|
|
668
|
-
onSearch = _this$props5.onSearch,
|
|
669
|
-
theme = _this$props5.theme,
|
|
670
|
-
localeDatas = _this$props5.localeDatas;
|
|
601
|
+
var _this$props = this.props,
|
|
602
|
+
mode = _this$props.mode,
|
|
603
|
+
showCheckAll = _this$props.showCheckAll,
|
|
604
|
+
className = _this$props.className,
|
|
605
|
+
disabled = _this$props.disabled,
|
|
606
|
+
clearable = _this$props.clearable,
|
|
607
|
+
style = _this$props.style,
|
|
608
|
+
children = _this$props.children,
|
|
609
|
+
optionWidth = _this$props.optionWidth,
|
|
610
|
+
dropdownRender = _this$props.dropdownRender,
|
|
611
|
+
multipleMode = _this$props.multipleMode,
|
|
612
|
+
_onClick = _this$props.onClick,
|
|
613
|
+
onBlur = _this$props.onBlur,
|
|
614
|
+
onFocus = _this$props.onFocus,
|
|
615
|
+
locale = _this$props.locale;
|
|
671
616
|
var placeholder = this.localeDatasProps('placeholder');
|
|
672
|
-
var
|
|
673
|
-
var searchPlaceholder = this.localeDatasProps('searchPlaceholder');
|
|
617
|
+
var noFoundTip = this.localeDatasProps('noFoundTip');
|
|
674
618
|
var _this$state4 = this.state,
|
|
675
619
|
selectedItems = _this$state4.selectedItems,
|
|
676
|
-
cacheSelectedItems = _this$state4.cacheSelectedItems,
|
|
677
620
|
dropdownItems = _this$state4.dropdownItems,
|
|
678
621
|
searchable = _this$state4.searchable,
|
|
679
622
|
dropdownShow = _this$state4.dropdownShow,
|
|
680
623
|
focusedIndex = _this$state4.focusedIndex,
|
|
681
624
|
fetching = _this$state4.fetching;
|
|
682
625
|
var extraClass = {
|
|
683
|
-
|
|
684
|
-
|
|
626
|
+
'is-multiple': mode === 'multiple',
|
|
627
|
+
'is-single': mode === 'single'
|
|
685
628
|
};
|
|
686
|
-
var selectInputWidth = this.selectInputContainer ? this.selectInputContainer.getBoundingClientRect().width : null;
|
|
687
629
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
688
|
-
className: (0, _classnames["default"])(
|
|
630
|
+
className: (0, _classnames["default"])('hi-select', className, extraClass),
|
|
689
631
|
style: style
|
|
690
632
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
691
633
|
className: "hi-select__input-container",
|
|
@@ -696,16 +638,15 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
696
638
|
ref: function ref(node) {
|
|
697
639
|
_this12.selectInput = node;
|
|
698
640
|
},
|
|
699
|
-
|
|
700
|
-
mode: type,
|
|
641
|
+
mode: mode,
|
|
701
642
|
disabled: disabled,
|
|
702
643
|
searchable: searchable,
|
|
703
644
|
clearable: clearable,
|
|
704
|
-
show: dropdownShow && this.props.open,
|
|
705
645
|
dropdownShow: dropdownShow,
|
|
706
646
|
placeholder: placeholder,
|
|
707
647
|
selectedItems: selectedItems,
|
|
708
|
-
|
|
648
|
+
dropdownItems: dropdownItems,
|
|
649
|
+
multipleMode: multipleMode,
|
|
709
650
|
container: this.selectInputContainer,
|
|
710
651
|
moveFocusedIndex: this.moveFocusedIndex.bind(this),
|
|
711
652
|
onClick: function onClick() {
|
|
@@ -726,81 +667,68 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
726
667
|
attachEle: this.selectInputContainer,
|
|
727
668
|
zIndex: 1050,
|
|
728
669
|
topGap: 5,
|
|
729
|
-
leftGap: 0,
|
|
730
670
|
className: "hi-select__popper",
|
|
731
671
|
placement: "top-bottom-start"
|
|
732
672
|
}, /*#__PURE__*/_react["default"].createElement(_SelectDropdown["default"], {
|
|
733
|
-
noFoundTip:
|
|
734
|
-
|
|
735
|
-
mode: type,
|
|
736
|
-
searchPlaceholder: searchPlaceholder,
|
|
737
|
-
theme: theme,
|
|
738
|
-
onBlur: onBlur,
|
|
739
|
-
onFocus: onFocus,
|
|
740
|
-
isOnSearch: onSearch || dataSource,
|
|
741
|
-
onSearch: this.debouncedFilterItems.bind(this),
|
|
742
|
-
searchable: searchable,
|
|
673
|
+
noFoundTip: noFoundTip,
|
|
674
|
+
mode: mode,
|
|
743
675
|
showCheckAll: showCheckAll,
|
|
744
676
|
checkAll: this.checkAll.bind(this),
|
|
745
677
|
loading: fetching,
|
|
746
678
|
focusedIndex: focusedIndex,
|
|
747
|
-
setStateAutolaod: this.setStateAutolaod,
|
|
748
|
-
filterOption: filterOption,
|
|
749
679
|
matchFilter: this.matchFilter.bind(this),
|
|
750
680
|
setFocusedIndex: this.setFocusedIndex.bind(this),
|
|
751
|
-
show: dropdownShow && this.props.open,
|
|
752
681
|
optionWidth: optionWidth,
|
|
753
|
-
|
|
754
|
-
onEnterSelect: this.onEnterSelect.bind(this),
|
|
755
|
-
moveFocusedIndex: this.moveFocusedIndex.bind(this),
|
|
756
|
-
dropdownItems: dataSource && this.state.keyword === '' && !this.state.stateAutoload ? cacheSelectedItems : dropdownItems,
|
|
682
|
+
dropdownItems: dropdownItems,
|
|
757
683
|
selectedItems: selectedItems,
|
|
758
|
-
dropdownRender:
|
|
684
|
+
dropdownRender: dropdownRender // Popper 包裹的组件需要手动传入 locale
|
|
685
|
+
,
|
|
686
|
+
locale: locale,
|
|
759
687
|
onClickOption: this.onClickOption.bind(this)
|
|
760
688
|
})));
|
|
761
689
|
}
|
|
762
690
|
}]);
|
|
691
|
+
|
|
763
692
|
return Select;
|
|
764
693
|
}(_react.Component);
|
|
765
694
|
|
|
766
|
-
(
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
defaultValue: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array, _propTypes["default"].bool, _propTypes["default"].number]),
|
|
695
|
+
_defineProperty(Select, "propTypes", {
|
|
696
|
+
mode: _propTypes["default"].oneOf(['single', 'multiple']),
|
|
697
|
+
multipleMode: _propTypes["default"].oneOf(['wrap', 'nowrap']),
|
|
698
|
+
list: _propTypes["default"].array,
|
|
699
|
+
origin: _propTypes["default"].object,
|
|
772
700
|
value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].array, _propTypes["default"].bool, _propTypes["default"].number]),
|
|
773
701
|
showCheckAll: _propTypes["default"].bool,
|
|
774
702
|
autoload: _propTypes["default"].bool,
|
|
775
|
-
withCredentials: _propTypes["default"].bool,
|
|
776
703
|
searchable: _propTypes["default"].bool,
|
|
777
|
-
filterOption: _propTypes["default"].func,
|
|
778
704
|
clearable: _propTypes["default"].bool,
|
|
779
705
|
disabled: _propTypes["default"].bool,
|
|
780
706
|
placeholder: _propTypes["default"].string,
|
|
781
|
-
|
|
707
|
+
noFoundTip: _propTypes["default"].string,
|
|
782
708
|
optionWidth: _propTypes["default"].number,
|
|
783
709
|
style: _propTypes["default"].object,
|
|
784
710
|
onChange: _propTypes["default"].func,
|
|
785
|
-
|
|
711
|
+
dropdownRender: _propTypes["default"].func,
|
|
786
712
|
open: _propTypes["default"].bool
|
|
787
713
|
});
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
714
|
+
|
|
715
|
+
_defineProperty(Select, "defaultProps", {
|
|
716
|
+
list: [],
|
|
717
|
+
mode: 'single',
|
|
718
|
+
multipleMode: 'wrap',
|
|
792
719
|
disabled: false,
|
|
793
720
|
clearable: true,
|
|
794
|
-
|
|
721
|
+
value: '',
|
|
795
722
|
autoload: false,
|
|
723
|
+
placeholder: '',
|
|
724
|
+
noFoundTip: '',
|
|
796
725
|
showCheckAll: false,
|
|
797
726
|
open: true,
|
|
798
|
-
withCredentials: false,
|
|
799
|
-
stateAutoload: false,
|
|
800
727
|
onClick: function onClick() {},
|
|
801
728
|
onBlur: function onBlur() {},
|
|
802
729
|
onFocus: function onFocus() {}
|
|
803
730
|
});
|
|
731
|
+
|
|
804
732
|
Select.childContextTypes = {
|
|
805
733
|
component: _propTypes["default"].any
|
|
806
734
|
};
|