1- import { SelectKeyPrompt , wrapTextWithPrefix } from '@clack/core' ;
1+ import { SelectKeyPrompt , settings , wrapTextWithPrefix } from '@clack/core' ;
22import color from 'picocolors' ;
33import { type CommonOptions , S_BAR , S_BAR_END , symbol } from './common.js' ;
44import type { Option } from './select.js' ;
@@ -40,11 +40,12 @@ export const selectKey = <Value extends string>(opts: SelectKeyOptions<Value>) =
4040 initialValue : opts . initialValue ,
4141 caseSensitive : opts . caseSensitive ,
4242 render ( ) {
43- const title = `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } \n` ;
43+ const hasGuide = ( opts . withGuide ?? settings . withGuide ) !== false ;
44+ const title = `${ hasGuide ? `${ color . gray ( S_BAR ) } \n` : '' } ${ symbol ( this . state ) } ${ opts . message } \n` ;
4445
4546 switch ( this . state ) {
4647 case 'submit' : {
47- const submitPrefix = `${ color . gray ( S_BAR ) } ` ;
48+ const submitPrefix = hasGuide ? `${ color . gray ( S_BAR ) } ` : '' ;
4849 const selectedOption =
4950 this . options . find ( ( opt ) => opt . value === this . value ) ?? opts . options [ 0 ] ;
5051 const wrapped = wrapTextWithPrefix (
@@ -55,16 +56,17 @@ export const selectKey = <Value extends string>(opts: SelectKeyOptions<Value>) =
5556 return `${ title } ${ wrapped } ` ;
5657 }
5758 case 'cancel' : {
58- const cancelPrefix = `${ color . gray ( S_BAR ) } ` ;
59+ const cancelPrefix = hasGuide ? `${ color . gray ( S_BAR ) } ` : '' ;
5960 const wrapped = wrapTextWithPrefix (
6061 opts . output ,
6162 opt ( this . options [ 0 ] , 'cancelled' ) ,
6263 cancelPrefix
6364 ) ;
64- return `${ title } ${ wrapped } \n${ color . gray ( S_BAR ) } ` ;
65+ return `${ title } ${ wrapped } ${ hasGuide ? ` \n${ color . gray ( S_BAR ) } ` : '' } ` ;
6566 }
6667 default : {
67- const defaultPrefix = `${ color . cyan ( S_BAR ) } ` ;
68+ const defaultPrefix = hasGuide ? `${ color . cyan ( S_BAR ) } ` : '' ;
69+ const defaultPrefixEnd = hasGuide ? color . cyan ( S_BAR_END ) : '' ;
6870 const wrapped = this . options
6971 . map ( ( option , i ) =>
7072 wrapTextWithPrefix (
@@ -74,7 +76,7 @@ export const selectKey = <Value extends string>(opts: SelectKeyOptions<Value>) =
7476 )
7577 )
7678 . join ( '\n' ) ;
77- return `${ title } ${ wrapped } \n${ color . cyan ( S_BAR_END ) } \n` ;
79+ return `${ title } ${ wrapped } \n${ defaultPrefixEnd } \n` ;
7880 }
7981 }
8082 } ,
0 commit comments