@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.
Files changed (340) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/es/_util/warning.js +2 -2
  3. package/es/alert/__test__/index.test.js +67 -0
  4. package/es/alert/index.js +147 -6
  5. package/es/alert/style/index.css +1 -1
  6. package/es/badge/index.js +87 -9
  7. package/es/badge/style/index.css +1 -1
  8. package/es/badge/style/index.js +0 -0
  9. package/es/button/Button.js +51 -59
  10. package/es/button/ButtonGroup.js +31 -23
  11. package/es/button/IconLoading.js +2 -2
  12. package/es/button/__test__/index.test.js +29 -0
  13. package/es/button/index.js +2 -3
  14. package/es/button/style/index.css +1 -1
  15. package/es/card/index.js +42 -54
  16. package/es/card/style/index.css +1 -1
  17. package/es/cascader/Cascader.js +116 -181
  18. package/es/cascader/__test__/index.test.js +283 -0
  19. package/es/cascader/index.js +2 -5
  20. package/es/cascader/menu.js +155 -0
  21. package/es/cascader/style/cascader.css +1 -1
  22. package/es/cascader/style/menu.css +1 -1
  23. package/es/checkbox/{checkbox-legacy/Base.js → Base.js} +31 -46
  24. package/es/checkbox/CheckBox.js +185 -0
  25. package/es/checkbox/index.js +4 -13
  26. package/es/checkbox/style/index.css +1 -1
  27. package/es/collapse/__test__/index.test.js +58 -0
  28. package/es/collapse/index.js +93 -79
  29. package/es/collapse/style/index.css +1 -1
  30. package/es/confirm/index.js +50 -37
  31. package/es/context/index.js +37 -39
  32. package/es/counter/__test__/index.test.js +52 -0
  33. package/es/counter/index.js +270 -6
  34. package/es/counter/style/index.css +1 -1
  35. package/es/date-picker/BasePicker.js +288 -374
  36. package/es/date-picker/Calender.js +90 -326
  37. package/es/date-picker/DatePanel.js +186 -175
  38. package/es/date-picker/DatePicker.js +51 -151
  39. package/es/date-picker/DateRangePanel.js +181 -253
  40. package/es/date-picker/Modal.js +25 -15
  41. package/es/date-picker/Time.js +336 -230
  42. package/es/date-picker/TimePanel.js +32 -27
  43. package/es/date-picker/TimePeriodPanel.js +32 -21
  44. package/es/date-picker/TimePicker.js +40 -42
  45. package/es/date-picker/TimeRangePanel.js +42 -32
  46. package/es/date-picker/Type.js +1 -5
  47. package/es/date-picker/WeekRangePanel.js +150 -237
  48. package/es/date-picker/constants.js +28 -14
  49. package/es/date-picker/dateUtil.js +52 -221
  50. package/es/date-picker/index.js +2 -5
  51. package/es/date-picker/style/index.css +1 -1
  52. package/es/date-picker/util.js +8 -101
  53. package/es/dropdown/Dropdown.js +199 -193
  54. package/es/dropdown/{tests → __test__}/index.test.js +2 -2
  55. package/es/dropdown/index.js +4 -73
  56. package/es/dropdown/style/index.css +1 -1
  57. package/es/dropdown/style/index.js +2 -0
  58. package/es/ficon/index.js +23 -13
  59. package/es/form/index.js +171 -6
  60. package/es/form/{Item.js → item.js} +53 -53
  61. package/es/form/style/index.css +1 -1
  62. package/es/grid/index.js +37 -25
  63. package/es/icon/index.js +32 -21
  64. package/es/index.js +9 -61
  65. package/es/input/index.js +345 -28
  66. package/es/input/style/index.css +1 -1
  67. package/es/input/util.js +18 -26
  68. package/es/lib/withDragDropContext.js +2 -2
  69. package/es/loading/index.js +129 -5
  70. package/es/loading/style/index.css +0 -0
  71. package/es/loading/style/index.js +0 -0
  72. package/es/locales/en-US.js +11 -45
  73. package/es/locales/index.js +2 -16
  74. package/es/locales/zh-CN.js +12 -46
  75. package/es/menu/Item.js +41 -32
  76. package/es/menu/ItemGroup.js +81 -0
  77. package/es/menu/SubMenu.js +74 -55
  78. package/es/menu/Title.js +42 -36
  79. package/es/menu/index.js +419 -12
  80. package/es/menu/style/index.css +1 -1
  81. package/es/modal/__test__/index.test.js +123 -0
  82. package/es/modal/index.js +61 -77
  83. package/es/modal/style/index.css +1 -1
  84. package/es/nav-menu/NavMenu.js +45 -31
  85. package/es/nav-menu/__test__/index.test.js +2 -2
  86. package/es/nav-menu/index.js +2 -2
  87. package/es/notification/__test__/index.test.js +56 -0
  88. package/es/notification/index.js +231 -68
  89. package/es/notification/style/index.css +1 -1
  90. package/es/notification/style/index.js +0 -0
  91. package/es/pagination/Pager.js +8 -6
  92. package/es/pagination/Pagination.js +115 -124
  93. package/es/pagination/__test__/index.test.js +140 -0
  94. package/es/pagination/index.js +8 -9
  95. package/es/pagination/style/index.css +1 -1
  96. package/es/panel/index.js +33 -23
  97. package/es/popover/__test__/index.test.js +2 -2
  98. package/es/popover/index.js +69 -71
  99. package/es/popper/index.js +54 -64
  100. package/es/popper/style/index.css +1 -1
  101. package/es/progress/BarProgress.js +43 -109
  102. package/es/progress/CircleProgress.js +10 -9
  103. package/es/progress/DashboardProgress.js +9 -7
  104. package/es/progress/index.js +100 -8
  105. package/es/progress/style/index.css +1 -1
  106. package/es/radio/{radio-legacy/__test__ → __test__}/index.test.js +10 -10
  107. package/es/radio/index.js +216 -10
  108. package/es/radio/style/index.css +1 -1
  109. package/es/rate/Icons.js +2 -2
  110. package/es/rate/Rate.js +90 -65
  111. package/es/rate/__test__/index.test.js +54 -0
  112. package/es/rate/index.js +2 -5
  113. package/es/rate/style/index.css +1 -1
  114. package/es/select/Option.js +93 -0
  115. package/es/select/Select.js +253 -325
  116. package/es/select/SelectDropdown.js +63 -215
  117. package/es/select/SelectInput.js +54 -88
  118. package/es/select/__test__/index.test.js +429 -0
  119. package/es/select/index.js +4 -6
  120. package/es/select/style/select-dropdown.css +1 -1
  121. package/es/select/style/select-input.css +1 -1
  122. package/es/stepper/index.js +127 -21
  123. package/es/stepper/style/index.css +1 -1
  124. package/es/style/color/colors.css +0 -0
  125. package/es/style/icon/diyIcon.css +1 -1
  126. package/es/style/icon/index.css +1 -1
  127. package/es/style/index.css +0 -0
  128. package/es/style/mixins/colors.css +0 -0
  129. package/es/style/mixins/index.css +0 -0
  130. package/es/style/theme/dark.css +0 -0
  131. package/es/style/theme/default.css +0 -0
  132. package/es/switch/{__tests__ → __test__}/index.test.js +2 -31
  133. package/es/switch/index.js +36 -24
  134. package/es/switch/style/index.css +1 -1
  135. package/es/table/__test__/index.test.js +73 -0
  136. package/es/table/{Body.js → body.js} +52 -36
  137. package/es/table/checkbox/index.js +36 -33
  138. package/es/table/clickOuterside.js +115 -0
  139. package/es/table/{Footer.js → footer.js} +41 -24
  140. package/es/table/{Header.js → header.js} +54 -41
  141. package/es/table/index.js +300 -262
  142. package/es/table/menu/index.js +34 -32
  143. package/es/table/pover.js +154 -0
  144. package/es/table/prefix.js +2 -2
  145. package/es/table/style/Table.css +1 -1
  146. package/es/table/style/index.css +1 -1
  147. package/es/table/tableContent.js +120 -0
  148. package/es/tabs/ItemDropdown.js +51 -39
  149. package/es/tabs/TabPane.js +35 -25
  150. package/es/tabs/Tabs.js +91 -98
  151. package/es/tabs/index.js +3 -9
  152. package/es/tabs/style/index.css +1 -1
  153. package/es/timeline/__test__/index.test.js +49 -0
  154. package/es/timeline/foldingItem.js +82 -0
  155. package/es/timeline/index.js +127 -203
  156. package/es/timeline/style/index.css +1 -1
  157. package/es/tooltip/__test__/index.test.js +67 -0
  158. package/es/tooltip/index.js +39 -86
  159. package/es/tooltip/style/index.css +1 -1
  160. package/es/transfer/Item.js +44 -53
  161. package/es/transfer/__test__/index.test.js +11 -0
  162. package/es/transfer/index.js +443 -4
  163. package/es/transfer/style/index.css +1 -1
  164. package/es/tree/Tree.js +86 -76
  165. package/es/tree/TreeDivider.js +3 -3
  166. package/es/tree/TreeItem.js +108 -204
  167. package/es/tree/TreeNode.js +318 -457
  168. package/es/tree/index.js +2 -9
  169. package/es/tree/style/index.css +1 -1
  170. package/es/tree/util.js +257 -9
  171. package/es/upload/{upload-legacy/Preview.js → Preview.js} +39 -33
  172. package/es/upload/Upload.js +193 -289
  173. package/es/upload/UploadAvatar.js +58 -44
  174. package/es/upload/UploadClick.js +45 -49
  175. package/es/upload/UploadDrag.js +43 -44
  176. package/es/upload/UploadPhoto.js +55 -70
  177. package/es/upload/UploadPictureCard.js +44 -39
  178. package/es/upload/index.js +71 -8
  179. package/es/upload/style/index.css +1 -1
  180. package/es/upload/tool.js +1 -0
  181. package/package.json +4 -1
  182. package/es/_util/SwitchVersion.js +0 -44
  183. package/es/_util/depreactedPropsCompat.js +0 -58
  184. package/es/_util/index.js +0 -32
  185. package/es/alert/Alert.js +0 -134
  186. package/es/alert/__tests__/index.test.js +0 -88
  187. package/es/badge/Badge.js +0 -90
  188. package/es/badge/__tests__/index.test.js +0 -82
  189. package/es/breadcrumb/__tests__/index.test.js +0 -61
  190. package/es/breadcrumb/index.js +0 -93
  191. package/es/breadcrumb/style/index.css +0 -1
  192. package/es/button/__tests__/index.test.js +0 -219
  193. package/es/card/__tests__/index.test.js +0 -169
  194. package/es/carousel/__tests__/index.test.js +0 -104
  195. package/es/carousel/index.js +0 -227
  196. package/es/carousel/style/index.css +0 -1
  197. package/es/carousel/style/index.js +0 -3
  198. package/es/cascader/Menu.js +0 -174
  199. package/es/cascader/__tests__/index.test.js +0 -389
  200. package/es/checkbox/Checkbox.js +0 -144
  201. package/es/checkbox/Group.js +0 -202
  202. package/es/checkbox/__tests__/index.test.js +0 -226
  203. package/es/checkbox/checkbox-legacy/CheckBox.js +0 -165
  204. package/es/checkbox/checkbox-legacy/index.js +0 -15
  205. package/es/checkbox/checkbox-legacy/style/index.css +0 -1
  206. package/es/checkbox/checkbox-legacy/style/index.js +0 -3
  207. package/es/collapse/__tests__/index.test.js +0 -111
  208. package/es/counter/Counter.js +0 -343
  209. package/es/counter/__tests__/index.test.js +0 -134
  210. package/es/counter/counter-legacy/index.js +0 -271
  211. package/es/date-picker/TimeList.js +0 -254
  212. package/es/date-picker/YMRangePanel.js +0 -372
  213. package/es/date-picker/__tests__/index.test.js +0 -961
  214. package/es/date-picker/datepicker-legacy/BasePicker.js +0 -519
  215. package/es/date-picker/datepicker-legacy/Calender.js +0 -430
  216. package/es/date-picker/datepicker-legacy/DatePanel.js +0 -463
  217. package/es/date-picker/datepicker-legacy/DatePicker.js +0 -107
  218. package/es/date-picker/datepicker-legacy/DateRangePanel.js +0 -496
  219. package/es/date-picker/datepicker-legacy/Modal.js +0 -71
  220. package/es/date-picker/datepicker-legacy/Time.js +0 -413
  221. package/es/date-picker/datepicker-legacy/TimePanel.js +0 -93
  222. package/es/date-picker/datepicker-legacy/TimePeriodPanel.js +0 -126
  223. package/es/date-picker/datepicker-legacy/TimePicker.js +0 -82
  224. package/es/date-picker/datepicker-legacy/TimeRangePanel.js +0 -98
  225. package/es/date-picker/datepicker-legacy/Type.js +0 -31
  226. package/es/date-picker/datepicker-legacy/WeekRangePanel.js +0 -345
  227. package/es/date-picker/datepicker-legacy/constants.js +0 -79
  228. package/es/date-picker/datepicker-legacy/dateUtil.js +0 -258
  229. package/es/date-picker/datepicker-legacy/index.js +0 -15
  230. package/es/date-picker/datepicker-legacy/local.js +0 -11
  231. package/es/date-picker/datepicker-legacy/style/index.css +0 -1
  232. package/es/date-picker/datepicker-legacy/style/index.js +0 -3
  233. package/es/date-picker/datepicker-legacy/style/timepicker.css +0 -1
  234. package/es/date-picker/datepicker-legacy/util.js +0 -60
  235. package/es/date-picker/toLunar.js +0 -172
  236. package/es/dropdown/DropdownButton.js +0 -106
  237. package/es/dropdown/DropdownMenu.js +0 -111
  238. package/es/dropdown/DropdownMenuItem.js +0 -178
  239. package/es/dropdown/__tests__/index.test.js +0 -317
  240. package/es/dropdown/utils.js +0 -35
  241. package/es/form/Form.js +0 -184
  242. package/es/form/__tests__/index.test.js +0 -575
  243. package/es/grid/__tests__/index.test.js +0 -104
  244. package/es/input/Input.js +0 -412
  245. package/es/input/__tests__/index.test.js +0 -381
  246. package/es/input/input-legacy/index.js +0 -353
  247. package/es/input/input-legacy/util.js +0 -176
  248. package/es/loading/Loading.js +0 -181
  249. package/es/loading/__tests__/index.test.js +0 -110
  250. package/es/locales/zh-Hant-HK.js +0 -121
  251. package/es/locales/zh-Hant-TW.js +0 -123
  252. package/es/menu/Menu.js +0 -422
  253. package/es/menu/__tests__/index.test.js +0 -279
  254. package/es/message/__tests__/index.test.js +0 -75
  255. package/es/message/index.js +0 -58
  256. package/es/message/style/index.css +0 -1
  257. package/es/message/style/index.js +0 -5
  258. package/es/modal/__tests__/index.test.js +0 -178
  259. package/es/nav-menu/__tests__/index.test.js +0 -27
  260. package/es/notice/Notice.js +0 -142
  261. package/es/notice/NoticeContainer.js +0 -113
  262. package/es/notice/__tests__/index.test.js +0 -174
  263. package/es/notice/index.js +0 -66
  264. package/es/notice/style/index.css +0 -1
  265. package/es/notice/style/index.js +0 -5
  266. package/es/notification/HandleNotification/index.js +0 -224
  267. package/es/notification/HandleNotification/style/index.css +0 -1
  268. package/es/notification/HandleNotification/style/index.js +0 -5
  269. package/es/notification/__tests__/index.test.js +0 -118
  270. package/es/pagination/__tests__/index.test.js +0 -248
  271. package/es/popover/__tests__/index.test.js +0 -152
  272. package/es/preview/index.js +0 -527
  273. package/es/preview/style/index.css +0 -1
  274. package/es/preview/style/index.js +0 -3
  275. package/es/progress/Progress.js +0 -110
  276. package/es/progress/__tests__/index.test.js +0 -131
  277. package/es/radio/Group.js +0 -203
  278. package/es/radio/Radio.js +0 -151
  279. package/es/radio/__tests__/index.test.js +0 -128
  280. package/es/radio/radio-legacy/index.js +0 -222
  281. package/es/radio/radio-legacy/style/index.css +0 -1
  282. package/es/radio/radio-legacy/style/index.js +0 -3
  283. package/es/rate/__tests__/index.test.js +0 -124
  284. package/es/select/__tests__/index.test.js +0 -505
  285. package/es/select/select-legacy/Option.js +0 -81
  286. package/es/select/select-legacy/Select.js +0 -710
  287. package/es/select/select-legacy/SelectDropdown.js +0 -164
  288. package/es/select/select-legacy/SelectInput.js +0 -312
  289. package/es/select/select-legacy/common.js +0 -19
  290. package/es/select/select-legacy/index.js +0 -16
  291. package/es/stepper/Stepper.js +0 -151
  292. package/es/stepper/__tests__/index.test.js +0 -161
  293. package/es/table/ClickOuterside.js +0 -103
  294. package/es/table/TableContent.js +0 -109
  295. package/es/table/__tests__/index.test.js +0 -133
  296. package/es/table/checkbox/style/index.css +0 -1
  297. package/es/table/checkbox/style/index.js +0 -3
  298. package/es/tabs/__tests__/index.test.js +0 -333
  299. package/es/tabs/tabs-legacy/ItemDropdown.js +0 -170
  300. package/es/tabs/tabs-legacy/TabPane.js +0 -78
  301. package/es/tabs/tabs-legacy/Tabs.js +0 -299
  302. package/es/tabs/tabs-legacy/index.js +0 -18
  303. package/es/tabs/tabs-legacy/style/index.css +0 -1
  304. package/es/tabs/tabs-legacy/style/index.js +0 -3
  305. package/es/tag/__tests__/index.test.js +0 -46
  306. package/es/tag/index.js +0 -94
  307. package/es/tag/style/index.css +0 -1
  308. package/es/tag/style/index.js +0 -3
  309. package/es/timeline/__tests__/index.test.js +0 -198
  310. package/es/tooltip/__tests__/index.test.js +0 -170
  311. package/es/transfer/Transfer.js +0 -566
  312. package/es/transfer/__tests__/index.test.js +0 -210
  313. package/es/tree/IconLoading.js +0 -38
  314. package/es/tree/__tests__/index.test.js +0 -603
  315. package/es/tree/tree-legacy/Tree.js +0 -337
  316. package/es/tree/tree-legacy/TreeDivider.js +0 -25
  317. package/es/tree/tree-legacy/TreeItem.js +0 -333
  318. package/es/tree/tree-legacy/TreeNode.js +0 -719
  319. package/es/tree/tree-legacy/index.js +0 -13
  320. package/es/tree/tree-legacy/style/index.css +0 -1
  321. package/es/tree/tree-legacy/style/index.js +0 -3
  322. package/es/tree/tree-legacy/util.js +0 -434
  323. package/es/upload/__tests__/index.test.js +0 -760
  324. package/es/upload/main.js +0 -91
  325. package/es/upload/upload-legacy/Upload.js +0 -435
  326. package/es/upload/upload-legacy/UploadAvatar.js +0 -322
  327. package/es/upload/upload-legacy/UploadClick.js +0 -125
  328. package/es/upload/upload-legacy/UploadDrag.js +0 -180
  329. package/es/upload/upload-legacy/UploadPhoto.js +0 -183
  330. package/es/upload/upload-legacy/UploadPictureCard.js +0 -126
  331. package/es/upload/upload-legacy/index.js +0 -75
  332. package/es/upload/upload-legacy/style/index.css +0 -1
  333. package/es/upload/upload-legacy/style/index.js +0 -5
  334. package/es/upload/upload-legacy/tool.js +0 -84
  335. package/es/watermark/index.js +0 -101
  336. package/es/watermark/watermark.js +0 -252
  337. /package/es/checkbox/{checkbox-legacy/common.js → common.js} +0 -0
  338. /package/es/{breadcrumb/style → style}/index.js +0 -0
  339. /package/es/upload/{upload-legacy/style → style}/preview.css +0 -0
  340. /package/es/upload/{upload-legacy/style → style}/preview.js +0 -0
@@ -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
- var _qs = _interopRequireDefault(require("qs"));
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 _lodash = _interopRequireDefault(require("lodash"));
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 _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 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; }
48
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
63
49
 
64
- 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; }
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 _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
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
- (0, _inherits2["default"])(Select, _Component);
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
- (0, _classCallCheck2["default"])(this, Select);
91
+ _classCallCheck(this, Select);
92
+
80
93
  _this = _super.call(this, props);
81
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "autoloadFlag", true);
82
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "setStateAutolaod", function () {
83
- _this.setState({
84
- stateAutoload: false
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
- !_this.getSearchable() && _this.selectInput.focus();
106
+ _this.selectInput.focus();
97
107
 
98
108
  if (_this.props.disabled) {
99
109
  return;
100
110
  }
101
111
 
102
- if (dropdownShow === false) {
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 selectedItems = _this.resetSelectedItems(initialValue, dropdownItems, []);
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((0, _assertThisInitialized2["default"])(_this)), 300);
118
- _this.clickOutsideHandel = _this.clickOutside.bind((0, _assertThisInitialized2["default"])(_this));
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: 2
137
+ width: '2px'
133
138
  }
134
139
  };
135
140
  return _this;
136
141
  }
137
142
 
138
- (0, _createClass2["default"])(Select, [{
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) || e.target.tagName === 'INPUT' && e.target.className.includes('hi-select__dropdown__searchbar--input')) {
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(nextProps) {
177
- if (!_lodash["default"].isEqual(nextProps.data, this.props.data)) {
178
- var selectedItems = this.resetSelectedItems(nextProps.value || this.state.selectedItems, nextProps.data, []);
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
- cacheSelectedItems: selectedItems,
182
- dropdownItems: (0, _cloneDeep["default"])(nextProps.data)
186
+ selectedItems: selectedItems
187
+ }, function () {// this.onChange()
183
188
  });
184
- } else {
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
- this.setState({
207
- selectedItems: _selectedItems2
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
- return searchable;
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.map(function (v) {
230
- if ((0, _typeof2["default"])(v) === 'object') {
231
- return v.id;
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 _this$props = this.props,
244
- dataSource = _this$props.dataSource,
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 dropdownItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
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
- dropdownItems.forEach(function (item) {
256
- if (values.includes(item.id)) {
257
- selectedItems.push(item);
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 _lodash["default"].uniqBy(reviceSelectedItems.concat(selectedItems), 'id');
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$state2 = this.state,
266
- dropdownItems = _this$state2.dropdownItems,
267
- focusedIndex = _this$state2.focusedIndex;
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(selectedItems, changedItems, callback) {
274
- var _this$props2 = this.props,
275
- onChange = _this$props2.onChange,
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(filterItems, e) {
276
+ value: function checkAll(e) {
289
277
  var _this2 = this;
290
278
 
291
279
  // 全选
292
280
  e && e.stopPropagation();
293
- var selectedItems = this.state.selectedItems;
281
+ var _this$state2 = this.state,
282
+ dropdownItems = _this$state2.dropdownItems,
283
+ selectedItems = _this$state2.selectedItems;
294
284
 
295
- var _selectedItems = (0, _toConsumableArray2["default"])(selectedItems);
285
+ var _selectedItems = _toConsumableArray(selectedItems);
296
286
 
297
287
  var changedItems = [];
298
- filterItems.forEach(function (item) {
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.onChange(_selectedItems, changedItems, function () {}, _selectedItems);
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.type === 'multiple') {
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.onChange(_lodash["default"].cloneDeep(selectedItems), item, function () {
335
- _this3.setState({
336
- focusedIndex: focusedIndex
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
- if (this.props.type !== 'multiple') {
347
- this.hideDropdown();
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.onChange(selectedItems, item, function () {
395
- !_this6.getSearchable() && _this6.selectInput.focus();
396
- }, selectedItems);
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
- var changedItems = (0, _toConsumableArray2["default"])(this.state.selectedItems);
407
- this.onChange([], type === 'multiple' ? changedItems : changedItems[0], function () {
408
- _this7.setState({
409
- focusedIndex: focusedIndex
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$props3 = this.props,
421
- onSearch = _this$props3.onSearch,
422
- dataSource = _this$props3.dataSource,
423
- autoload = _this$props3.autoload,
424
- propsWithCredentials = _this$props3.withCredentials;
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 (onSearch && typeof onSearch === 'function') {
427
- this.setState({
428
- fetching: true
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
- onSearch(keyword)["finally"](function () {
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 reviceSelectedItems = this.props.type === 'multiple' ? this.props.dataSource && this.state.selectedItems || [] : this.state.cacheSelectedItems;
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 (dataSource) {
546
- if (!(keyword && keyword.length >= this.state.queryLength)) {
547
- this.setState({
548
- cacheSelectedItems: this.state.selectedItems
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
- var shouldMatch = this.isRemote() || !searchable || !keyword;
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 === "up") {
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$props5 = this.props,
653
- type = _this$props5.type,
654
- showCheckAll = _this$props5.showCheckAll,
655
- className = _this$props5.className,
656
- disabled = _this$props5.disabled,
657
- clearable = _this$props5.clearable,
658
- style = _this$props5.style,
659
- children = _this$props5.children,
660
- optionWidth = _this$props5.optionWidth,
661
- render = _this$props5.render,
662
- multipleWrap = _this$props5.multipleWrap,
663
- _onClick = _this$props5.onClick,
664
- onBlur = _this$props5.onBlur,
665
- onFocus = _this$props5.onFocus,
666
- dataSource = _this$props5.dataSource,
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 emptyContent = this.localeDatasProps('emptyContent');
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
- "is-multiple": type === "multiple",
684
- "is-single": type === "single"
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"])("hi-select", className, extraClass),
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
- theme: theme,
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
- multipleMode: multipleWrap,
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: emptyContent,
734
- localeMap: localeDatas.select || {},
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
- selectInputWidth: selectInputWidth,
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: render,
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
- (0, _defineProperty2["default"])(Select, "propTypes", {
767
- type: _propTypes["default"].oneOf(['single', 'multiple']),
768
- multipleWrap: _propTypes["default"].oneOf(['wrap', 'nowrap']),
769
- data: _propTypes["default"].array,
770
- dataSource: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
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
- emptyContent: _propTypes["default"].string,
707
+ noFoundTip: _propTypes["default"].string,
782
708
  optionWidth: _propTypes["default"].number,
783
709
  style: _propTypes["default"].object,
784
710
  onChange: _propTypes["default"].func,
785
- render: _propTypes["default"].func,
711
+ dropdownRender: _propTypes["default"].func,
786
712
  open: _propTypes["default"].bool
787
713
  });
788
- (0, _defineProperty2["default"])(Select, "defaultProps", {
789
- data: [],
790
- type: 'single',
791
- multipleWrap: 'nowrap',
714
+
715
+ _defineProperty(Select, "defaultProps", {
716
+ list: [],
717
+ mode: 'single',
718
+ multipleMode: 'wrap',
792
719
  disabled: false,
793
720
  clearable: true,
794
- defaultValue: '',
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
  };