@@ -30,6 +30,7 @@ type SelectTheme = {
30
30
description : ( text : string ) => string ;
31
31
} ;
32
32
helpMode : 'always' | 'never' | 'auto' ;
33
+ indexMode : 'hidden' | 'number' ;
33
34
} ;
34
35
35
36
const selectTheme : SelectTheme = {
@@ -39,6 +40,7 @@ const selectTheme: SelectTheme = {
39
40
description : ( text : string ) => colors . cyan ( text ) ,
40
41
} ,
41
42
helpMode : 'auto' ,
43
+ indexMode : 'hidden' ,
42
44
} ;
43
45
44
46
type Choice < Value > = {
@@ -222,20 +224,21 @@ export default createPrompt(
222
224
const page = usePagination ( {
223
225
items,
224
226
active,
225
- renderItem ( { item, isActive } ) {
227
+ renderItem ( { item, isActive, index } ) {
226
228
if ( Separator . isSeparator ( item ) ) {
227
229
return ` ${ item . separator } ` ;
228
230
}
229
231
232
+ const indexLabel = theme . indexMode === 'number' ? `${ index + 1 } . ` : '' ;
230
233
if ( item . disabled ) {
231
234
const disabledLabel =
232
235
typeof item . disabled === 'string' ? item . disabled : '(disabled)' ;
233
- return theme . style . disabled ( `${ item . name } ${ disabledLabel } ` ) ;
236
+ return theme . style . disabled ( `${ indexLabel } ${ item . name } ${ disabledLabel } ` ) ;
234
237
}
235
238
236
239
const color = isActive ? theme . style . highlight : ( x : string ) => x ;
237
240
const cursor = isActive ? theme . icon . cursor : ` ` ;
238
- return color ( `${ cursor } ${ item . name } ` ) ;
241
+ return color ( `${ cursor } ${ indexLabel } ${ item . name } ` ) ;
239
242
} ,
240
243
pageSize,
241
244
loop,
0 commit comments