@hi-ui/hiui 3.9.0-rc.3 → 3.9.0-rc.4

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 (2) hide show
  1. package/es/select/Select.js +19 -26
  2. package/package.json +1 -1
@@ -422,36 +422,29 @@ var InternalSelect = function InternalSelect(props) {
422
422
  return shouldMatch || String(item[(0, _utils.transKeys)(fieldNames, 'id')] || '').includes(keyword) || String(item[(0, _utils.transKeys)(fieldNames, 'title')] || '').includes(keyword);
423
423
  }, [dataSource, searchable, keyword, filterOption]);
424
424
  var remoteSearch = (0, _react.useCallback)(function (keyword) {
425
- if (typeof dataSource === 'function') {
426
- var resultMayBePromise = dataSource(keyword);
427
-
428
- if (resultMayBePromise !== undefined && resultMayBePromise !== null) {
429
- if (resultMayBePromise.toString() === '[object Promise]') {
430
- // 处理promise函数
431
- setLoading(true);
432
- resultMayBePromise.then(function (res) {
433
- setLoading(false);
434
-
435
- if (res !== undefined && res !== null) {
436
- setDropdownItems(Array.isArray(res) ? res : []);
437
- }
438
- })["catch"](function () {
439
- setLoading(false);
440
- setDropdownItems([]);
441
- });
442
- } else {
443
- setDropdownItems(Array.isArray(resultMayBePromise) ? resultMayBePromise : []);
444
- }
445
- }
425
+ var resultMayBePromise = typeof dataSource === 'function' ? dataSource(keyword) : dataSource;
426
+ if ((0, _lodash.isNil)(resultMayBePromise)) return;
446
427
 
428
+ if (Array.isArray(resultMayBePromise)) {
429
+ setDropdownItems(resultMayBePromise);
447
430
  return;
448
- } // 支持传入对象
431
+ }
449
432
 
433
+ if (resultMayBePromise.toString() === '[object Promise]') {
434
+ setLoading(true);
435
+ resultMayBePromise.then(function (res) {
436
+ setLoading(false);
437
+ if ((0, _lodash.isNil)(res)) return;
438
+ setDropdownItems(Array.isArray(res) ? res : []);
439
+ }, function () {
440
+ setLoading(false);
441
+ setDropdownItems([]);
442
+ });
443
+ return;
444
+ } // 传入对象, 调用接口
450
445
 
451
- if (dataSource) {
452
- // 调用接口
453
- HiRequestSearch(dataSource, keyword);
454
- }
446
+
447
+ HiRequestSearch(resultMayBePromise, keyword);
455
448
  }, [dataSource, keyword]);
456
449
  var HiRequestSearch = (0, _react.useCallback)(function (_dataSource, keyword) {
457
450
  var url = _dataSource.url,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/hiui",
3
- "version": "3.9.0-rc.3",
3
+ "version": "3.9.0-rc.4",
4
4
  "description": "HIUI for React",
5
5
  "scripts": {
6
6
  "test": "node_modules/.bin/standard && node_modules/.bin/stylelint --config .stylelintrc 'components/**/*.scss'",