@@ -462,8 +462,10 @@ export interface GroupMultiSelectOptions<Value> {
462462 initialValues ?: Value [ ] ;
463463 required ?: boolean ;
464464 cursorAt ?: Value ;
465+ selectableGroups ?: boolean ;
465466}
466467export const groupMultiselect = < Value > ( opts : GroupMultiSelectOptions < Value > ) => {
468+ const { selectableGroups = true } = opts ;
467469 const opt = (
468470 option : Option < Value > ,
469471 state :
@@ -481,7 +483,7 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
481483 const isItem = typeof ( option as any ) . group === 'string' ;
482484 const next = isItem && ( options [ options . indexOf ( option ) + 1 ] ?? { group : true } ) ;
483485 const isLast = isItem && ( next as any ) . group === true ;
484- const prefix = isItem ? `${ isLast ? S_BAR_END : S_BAR } ` : '' ;
486+ const prefix = isItem ? ( selectableGroups ? `${ isLast ? S_BAR_END : S_BAR } ` : ' ' ) : '' ;
485487
486488 if ( state === 'active' ) {
487489 return `${ color . dim ( prefix ) } ${ color . cyan ( S_CHECKBOX_ACTIVE ) } ${ label } ${
@@ -495,7 +497,8 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
495497 return `${ prefix } ${ color . green ( S_CHECKBOX_SELECTED ) } ${ color . dim ( label ) } ` ;
496498 }
497499 if ( state === 'selected' ) {
498- return `${ color . dim ( prefix ) } ${ color . green ( S_CHECKBOX_SELECTED ) } ${ color . dim ( label ) } ` ;
500+ const selectedCheckbox = isItem || selectableGroups ? color . green ( S_CHECKBOX_SELECTED ) : '' ;
501+ return `${ color . dim ( prefix ) } ${ selectedCheckbox } ${ color . dim ( label ) } ` ;
499502 }
500503 if ( state === 'cancelled' ) {
501504 return `${ color . strikethrough ( color . dim ( label ) ) } ` ;
@@ -508,14 +511,16 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
508511 if ( state === 'submitted' ) {
509512 return `${ color . dim ( label ) } ` ;
510513 }
511- return `${ color . dim ( prefix ) } ${ color . dim ( S_CHECKBOX_INACTIVE ) } ${ color . dim ( label ) } ` ;
514+ const unselectedCheckbox = isItem || selectableGroups ? color . dim ( S_CHECKBOX_INACTIVE ) : '' ;
515+ return `${ color . dim ( prefix ) } ${ unselectedCheckbox } ${ color . dim ( label ) } ` ;
512516 } ;
513517
514518 return new GroupMultiSelectPrompt ( {
515519 options : opts . options ,
516520 initialValues : opts . initialValues ,
517521 required : opts . required ?? true ,
518522 cursorAt : opts . cursorAt ,
523+ selectableGroups,
519524 validate ( selected : Value [ ] ) {
520525 if ( this . required && selected . length === 0 )
521526 return `Please select at least one option.\n${ color . reset (
0 commit comments