@@ -12,6 +12,9 @@ import { optionProps } from '../vc-mentions/src/Option';
12
12
import type { KeyboardEventHandler } from '../_util/EventInterface' ;
13
13
import type { InputStatus } from '../_util/statusUtils' ;
14
14
import { getStatusClassNames , getMergedStatus } from '../_util/statusUtils' ;
15
+ import useStyle from './style' ;
16
+ import { useProvideOverride } from '../menu/src/OverrideContext' ;
17
+ import warning from '../_util/warning' ;
15
18
16
19
interface MentionsConfig {
17
20
prefix ?: string | string [ ] ;
@@ -98,12 +101,27 @@ const Mentions = defineComponent({
98
101
slots : [ 'notFoundContent' , 'option' ] ,
99
102
setup ( props , { slots, emit, attrs, expose } ) {
100
103
const { prefixCls, renderEmpty, direction } = useConfigInject ( 'mentions' , props ) ;
104
+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
101
105
const focused = ref ( false ) ;
102
106
const vcMentions = ref ( null ) ;
103
107
const value = ref ( props . value ?? props . defaultValue ?? '' ) ;
104
108
const formItemContext = useInjectFormItemContext ( ) ;
105
109
const formItemInputContext = FormItemInputContext . useInject ( ) ;
106
110
const mergedStatus = computed ( ( ) => getMergedStatus ( formItemInputContext . status , props . status ) ) ;
111
+ useProvideOverride ( {
112
+ prefixCls : computed ( ( ) => `${ prefixCls . value } -menu` ) ,
113
+ mode : computed ( ( ) => 'vertical' ) ,
114
+ selectable : computed ( ( ) => false ) ,
115
+ onClick : ( ) => { } ,
116
+ validator : ( { mode } ) => {
117
+ // Warning if use other mode
118
+ warning (
119
+ ! mode || mode === 'vertical' ,
120
+ 'Mentions' ,
121
+ `mode="${ mode } " is not supported for Mentions's Menu.` ,
122
+ ) ;
123
+ } ,
124
+ } ) ;
107
125
watch (
108
126
( ) => props . value ,
109
127
val => {
@@ -182,6 +200,7 @@ const Mentions = defineComponent({
182
200
} ,
183
201
getStatusClassNames ( prefixCls . value , mergedStatus . value ) ,
184
202
! hasFeedback && className ,
203
+ hashId . value ,
185
204
) ;
186
205
187
206
const mentionsProps = {
@@ -206,11 +225,12 @@ const Mentions = defineComponent({
206
225
const mentions = (
207
226
< VcMentions
208
227
{ ...mentionsProps }
228
+ dropdownClassName = { hashId . value }
209
229
v-slots = { { notFoundContent : getNotFoundContent , option : slots . option } }
210
230
> </ VcMentions >
211
231
) ;
212
232
if ( hasFeedback ) {
213
- return (
233
+ return wrapSSR (
214
234
< div
215
235
class = { classNames (
216
236
`${ prefixCls . value } -affix-wrapper` ,
@@ -220,14 +240,15 @@ const Mentions = defineComponent({
220
240
hasFeedback ,
221
241
) ,
222
242
className ,
243
+ hashId . value ,
223
244
) }
224
245
>
225
246
{ mentions }
226
247
< span class = { `${ prefixCls . value } -suffix` } > { feedbackIcon } </ span >
227
- </ div >
248
+ </ div > ,
228
249
) ;
229
250
}
230
- return mentions ;
251
+ return wrapSSR ( mentions ) ;
231
252
} ;
232
253
} ,
233
254
} ) ;
0 commit comments