@@ -7,7 +7,7 @@ import { isValidElement } from '../_util/props-util';
7
7
import createRef from '../_util/createRef' ;
8
8
import type { PropType } from 'vue' ;
9
9
import { computed , defineComponent , nextTick , reactive , watch } from 'vue' ;
10
- import List from '../vc-virtual-list/List ' ;
10
+ import List from '../vc-virtual-list' ;
11
11
import type {
12
12
OptionsType as SelectOptionsType ,
13
13
OptionData ,
@@ -346,85 +346,95 @@ const OptionList = defineComponent<OptionListProps<SelectOptionsType[number]>, {
346
346
onScroll = { onScroll }
347
347
virtual = { virtual }
348
348
onMouseenter = { onMouseenter }
349
- children = { ( { group, groupOption, data, label, value } , itemIndex ) => {
350
- const { key } = data ;
351
- // Group
352
- if ( group ) {
353
- return (
354
- < div class = { classNames ( itemPrefixCls , `${ itemPrefixCls } -group` ) } >
355
- { renderOption ? renderOption ( data ) : label !== undefined ? label : key }
356
- </ div >
357
- ) ;
358
- }
359
-
360
- const { disabled, title, children, style, class : cls , className, ...otherProps } = data ;
361
- const passedProps = omit ( otherProps , omitFieldNameList ) ;
362
- // Option
363
- const selected = values . has ( value ) ;
364
-
365
- const optionPrefixCls = `${ itemPrefixCls } -option` ;
366
- const optionClassName = classNames ( itemPrefixCls , optionPrefixCls , cls , className , {
367
- [ `${ optionPrefixCls } -grouped` ] : groupOption ,
368
- [ `${ optionPrefixCls } -active` ] : activeIndex === itemIndex && ! disabled ,
369
- [ `${ optionPrefixCls } -disabled` ] : disabled ,
370
- [ `${ optionPrefixCls } -selected` ] : selected ,
371
- } ) ;
372
-
373
- const mergedLabel = childrenAsData ? children : label ;
374
-
375
- const iconVisible =
376
- ! menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected ;
349
+ v-slots = { {
350
+ default : ( { group, groupOption, data, label, value } , itemIndex ) => {
351
+ const { key } = data ;
352
+ // Group
353
+ if ( group ) {
354
+ return (
355
+ < div class = { classNames ( itemPrefixCls , `${ itemPrefixCls } -group` ) } >
356
+ { renderOption ? renderOption ( data ) : label !== undefined ? label : key }
357
+ </ div >
358
+ ) ;
359
+ }
377
360
378
- const content = mergedLabel || value ;
379
- // https://github.com/ant-design/ant-design/issues/26717
380
- let optionTitle =
381
- typeof content === 'string' || typeof content === 'number'
382
- ? content . toString ( )
383
- : undefined ;
384
- if ( title !== undefined ) {
385
- optionTitle = title ;
386
- }
361
+ const {
362
+ disabled,
363
+ title,
364
+ children,
365
+ style,
366
+ class : cls ,
367
+ className,
368
+ ...otherProps
369
+ } = data ;
370
+ const passedProps = omit ( otherProps , omitFieldNameList ) ;
371
+ // Option
372
+ const selected = values . has ( value ) ;
373
+
374
+ const optionPrefixCls = `${ itemPrefixCls } -option` ;
375
+ const optionClassName = classNames ( itemPrefixCls , optionPrefixCls , cls , className , {
376
+ [ `${ optionPrefixCls } -grouped` ] : groupOption ,
377
+ [ `${ optionPrefixCls } -active` ] : activeIndex === itemIndex && ! disabled ,
378
+ [ `${ optionPrefixCls } -disabled` ] : disabled ,
379
+ [ `${ optionPrefixCls } -selected` ] : selected ,
380
+ } ) ;
381
+
382
+ const mergedLabel = childrenAsData ? children : label ;
383
+
384
+ const iconVisible =
385
+ ! menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected ;
386
+
387
+ const content = mergedLabel || value ;
388
+ // https://github.com/ant-design/ant-design/issues/26717
389
+ let optionTitle =
390
+ typeof content === 'string' || typeof content === 'number'
391
+ ? content . toString ( )
392
+ : undefined ;
393
+ if ( title !== undefined ) {
394
+ optionTitle = title ;
395
+ }
387
396
388
- return (
389
- < div
390
- { ...passedProps }
391
- aria-selected = { selected }
392
- class = { optionClassName }
393
- title = { optionTitle }
394
- onMousemove = { e => {
395
- if ( otherProps . onMousemove ) {
396
- otherProps . onMousemove ( e ) ;
397
- }
398
- if ( activeIndex === itemIndex || disabled ) {
399
- return ;
400
- }
401
- setActive ( itemIndex ) ;
402
- } }
403
- onClick = { e => {
404
- if ( ! disabled ) {
405
- onSelectValue ( value ) ;
406
- }
407
- if ( otherProps . onClick ) {
408
- otherProps . onClick ( e ) ;
409
- }
410
- } }
411
- style = { style }
412
- >
413
- < div class = { `${ optionPrefixCls } -content` } >
414
- { renderOption ? renderOption ( data ) : content }
397
+ return (
398
+ < div
399
+ { ...passedProps }
400
+ aria-selected = { selected }
401
+ class = { optionClassName }
402
+ title = { optionTitle }
403
+ onMousemove = { e => {
404
+ if ( otherProps . onMousemove ) {
405
+ otherProps . onMousemove ( e ) ;
406
+ }
407
+ if ( activeIndex === itemIndex || disabled ) {
408
+ return ;
409
+ }
410
+ setActive ( itemIndex ) ;
411
+ } }
412
+ onClick = { e => {
413
+ if ( ! disabled ) {
414
+ onSelectValue ( value ) ;
415
+ }
416
+ if ( otherProps . onClick ) {
417
+ otherProps . onClick ( e ) ;
418
+ }
419
+ } }
420
+ style = { style }
421
+ >
422
+ < div class = { `${ optionPrefixCls } -content` } >
423
+ { renderOption ? renderOption ( data ) : content }
424
+ </ div >
425
+ { isValidElement ( menuItemSelectedIcon ) || selected }
426
+ { iconVisible && (
427
+ < TransBtn
428
+ class = { `${ itemPrefixCls } -option-state` }
429
+ customizeIcon = { menuItemSelectedIcon }
430
+ customizeIconProps = { { isSelected : selected } }
431
+ >
432
+ { selected ? '✓' : null }
433
+ </ TransBtn >
434
+ ) }
415
435
</ div >
416
- { isValidElement ( menuItemSelectedIcon ) || selected }
417
- { iconVisible && (
418
- < TransBtn
419
- class = { `${ itemPrefixCls } -option-state` }
420
- customizeIcon = { menuItemSelectedIcon }
421
- customizeIconProps = { { isSelected : selected } }
422
- >
423
- { selected ? '✓' : null }
424
- </ TransBtn >
425
- ) }
426
- </ div >
427
- ) ;
436
+ ) ;
437
+ } ,
428
438
} }
429
439
> </ List >
430
440
</ >
0 commit comments