@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.
- package/es/select/Select.js +19 -26
- package/package.json +1 -1
package/es/select/Select.js
CHANGED
|
@@ -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
|
-
|
|
426
|
-
|
|
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
|
-
|
|
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