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