1
1
import Input from 'antd/es/input'
2
+ import defaultRenderEmpty from 'antd/es/config-provider/defaultRenderEmpty'
3
+ import { ConfigContext } from 'antd/es/config-provider/context'
2
4
import type { InputProps } from 'antd/es/input'
3
5
import React from 'react'
4
6
import { ConditionInput } from '@template-pro/rc-ui'
7
+ import toArray from 'rc-util/es/Children/toArray'
5
8
import classNames from 'classnames'
6
9
import { useBoolean , useClickAway , useControllableValue } from 'ahooks'
7
10
import { defaultPrefixCls } from '../constants'
@@ -33,6 +36,8 @@ const SearchResult = (props: SearchResultProps, ref: React.Ref<SearchResultActio
33
36
{ onChange : onSearch } , { defaultValue : '' } ,
34
37
)
35
38
39
+ const { renderEmpty } = React . useContext ( ConfigContext )
40
+
36
41
const searchResultRef = React . useRef < HTMLDivElement > ( null )
37
42
const [ visibleDropdown , {
38
43
setTrue : openDropdown ,
@@ -52,6 +57,8 @@ const SearchResult = (props: SearchResultProps, ref: React.Ref<SearchResultActio
52
57
53
58
React . useImperativeHandle ( ref , ( ) => ( { close : handlerClose } ) , [ ] )
54
59
60
+ const arrayChildren = toArray ( children )
61
+
55
62
return (
56
63
< div
57
64
className = { classNames ( prefixedClassName , className ) }
@@ -73,7 +80,11 @@ const SearchResult = (props: SearchResultProps, ref: React.Ref<SearchResultActio
73
80
{
74
81
showChildren && (
75
82
< div className = { classNames ( `${ prefixedClassName } -result-wrapper` , resultWrapperClassName ) } >
76
- { children }
83
+ {
84
+ arrayChildren . length
85
+ ? arrayChildren
86
+ : ( renderEmpty || defaultRenderEmpty ) ( 'SearchResult' )
87
+ }
77
88
</ div >
78
89
)
79
90
}
0 commit comments