11import { styleText } from 'node:util' ;
2- import { GroupMultiSelectPrompt } from '@clack/core' ;
2+ import { GroupMultiSelectPrompt , settings } from '@clack/core' ;
33import {
44 type CommonOptions ,
55 S_BAR ,
@@ -104,7 +104,8 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
104104 ) } `;
105105 } ,
106106 render ( ) {
107- const title = `${ styleText ( 'gray' , S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } \n` ;
107+ const hasGuide = opts . withGuide ?? settings . withGuide ;
108+ const title = `${ hasGuide ? `${ styleText ( 'gray' , S_BAR ) } \n` : '' } ${ symbol ( this . state ) } ${ opts . message } \n` ;
108109 const value = this . value ?? [ ] ;
109110
110111 switch ( this . state ) {
@@ -114,25 +115,27 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
114115 . map ( ( option ) => opt ( option , 'submitted' ) ) ;
115116 const optionsText =
116117 selectedOptions . length === 0 ? '' : ` ${ selectedOptions . join ( styleText ( 'dim' , ', ' ) ) } ` ;
117- return `${ title } ${ styleText ( 'gray' , S_BAR ) } ${ optionsText } ` ;
118+ return `${ title } ${ hasGuide ? styleText ( 'gray' , S_BAR ) : '' } ${ optionsText } ` ;
118119 }
119120 case 'cancel' : {
120121 const label = this . options
121122 . filter ( ( { value : optionValue } ) => value . includes ( optionValue ) )
122123 . map ( ( option ) => opt ( option , 'cancelled' ) )
123124 . join ( styleText ( 'dim' , ', ' ) ) ;
124- return `${ title } ${ styleText ( 'gray' , S_BAR ) } ${
125- label . trim ( ) ? `${ label } \n${ styleText ( 'gray' , S_BAR ) } ` : ''
125+ return `${ title } ${ hasGuide ? ` ${ styleText ( 'gray' , S_BAR ) } ` : '' } ${
126+ label . trim ( ) ? `${ label } ${ hasGuide ? ` \n${ styleText ( 'gray' , S_BAR ) } ` : '' } ` : ''
126127 } `;
127128 }
128129 case 'error' : {
129130 const footer = this . error
130131 . split ( '\n' )
131132 . map ( ( ln , i ) =>
132- i === 0 ? `${ styleText ( 'yellow' , S_BAR_END ) } ${ styleText ( 'yellow' , ln ) } ` : ` ${ ln } `
133+ i === 0
134+ ? `${ hasGuide ? `${ styleText ( 'yellow' , S_BAR_END ) } ` : '' } ${ styleText ( 'yellow' , ln ) } `
135+ : ` ${ ln } `
133136 )
134137 . join ( '\n' ) ;
135- return `${ title } ${ styleText ( 'yellow' , S_BAR ) } ${ this . options
138+ return `${ title } ${ hasGuide ? ` ${ styleText ( 'yellow' , S_BAR ) } ` : '' } ${ this . options
136139 . map ( ( option , i , options ) => {
137140 const selected =
138141 value . includes ( option . value ) ||
@@ -153,7 +156,7 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
153156 }
154157 return opt ( option , active ? 'active' : 'inactive' , options ) ;
155158 } )
156- . join ( `\n${ styleText ( 'yellow' , S_BAR ) } ` ) } \n${ footer } \n`;
159+ . join ( `\n${ hasGuide ? ` ${ styleText ( 'yellow' , S_BAR ) } ` : '' } ` ) } \n${ footer } \n`;
157160 }
158161 default : {
159162 const optionsText = this . options
@@ -183,9 +186,11 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
183186 const prefix = i !== 0 && ! optionText . startsWith ( '\n' ) ? ' ' : '' ;
184187 return `${ prefix } ${ optionText } ` ;
185188 } )
186- . join ( `\n${ styleText ( 'cyan' , S_BAR ) } ` ) ;
189+ . join ( `\n${ hasGuide ? styleText ( 'cyan' , S_BAR ) : '' } ` ) ;
187190 const optionsPrefix = optionsText . startsWith ( '\n' ) ? '' : ' ' ;
188- return `${ title } ${ styleText ( 'cyan' , S_BAR ) } ${ optionsPrefix } ${ optionsText } \n${ styleText ( 'cyan' , S_BAR_END ) } \n` ;
191+ return `${ title } ${ hasGuide ? styleText ( 'cyan' , S_BAR ) : '' } ${ optionsPrefix } ${ optionsText } \n${
192+ hasGuide ? styleText ( 'cyan' , S_BAR_END ) : ''
193+ } \n`;
189194 }
190195 }
191196 } ,
0 commit comments