@@ -20,7 +20,9 @@ export const text = (opts: TextOptions) => {
2020 signal : opts . signal ,
2121 input : opts . input ,
2222 render ( ) {
23- const title = `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } \n` ;
23+ const withBorder = opts . withBorder !== false ;
24+ const titlePrefix = withBorder ? `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ` : '' ;
25+ const title = `${ titlePrefix } ${ opts . message } \n` ;
2426 const placeholder = opts . placeholder
2527 ? color . inverse ( opts . placeholder [ 0 ] ) + color . dim ( opts . placeholder . slice ( 1 ) )
2628 : color . inverse ( color . hidden ( '_' ) ) ;
@@ -30,20 +32,26 @@ export const text = (opts: TextOptions) => {
3032 switch ( this . state ) {
3133 case 'error' : {
3234 const errorText = this . error ? ` ${ color . yellow ( this . error ) } ` : '' ;
33- return `${ title . trim ( ) } \n ${ color . yellow ( S_BAR ) } ${ userInput } \n ${ color . yellow (
34- S_BAR_END
35- ) } ${ errorText } \n`;
35+ const errorPrefix = withBorder ? `${ color . yellow ( S_BAR ) } ` : '' ;
36+ const errorPrefixEnd = withBorder ? color . yellow ( S_BAR_END ) : '' ;
37+ return ` ${ title . trim ( ) } \n ${ errorPrefix } ${ userInput } \n ${ errorPrefixEnd } ${ errorText } \n`;
3638 }
3739 case 'submit' : {
3840 const valueText = value ? ` ${ color . dim ( value ) } ` : '' ;
39- return `${ title } ${ color . gray ( S_BAR ) } ${ valueText } ` ;
41+ const submitPrefix = withBorder ? color . gray ( S_BAR ) : '' ;
42+ return `${ title } ${ submitPrefix } ${ valueText } ` ;
4043 }
4144 case 'cancel' : {
4245 const valueText = value ? ` ${ color . strikethrough ( color . dim ( value ) ) } ` : '' ;
43- return `${ title } ${ color . gray ( S_BAR ) } ${ valueText } ${ value . trim ( ) ? `\n${ color . gray ( S_BAR ) } ` : '' } ` ;
46+ const cancelPrefix = withBorder ? color . gray ( S_BAR ) : '' ;
47+ return `${ title } ${ cancelPrefix } ${ valueText } ${ value . trim ( ) ? `\n${ cancelPrefix } ` : '' } ` ;
48+ }
49+ default : {
50+ const defaultPrefix = withBorder ? `${ color . cyan ( S_BAR ) } ` : '' ;
51+ const defaultPrefixEnd = withBorder ? color . cyan ( S_BAR_END ) : '' ;
52+ color . cyan ( S_BAR_END ) ;
53+ return `${ title } ${ defaultPrefix } ${ userInput } \n${ defaultPrefixEnd } \n` ;
4454 }
45- default :
46- return `${ title } ${ color . cyan ( S_BAR ) } ${ userInput } \n${ color . cyan ( S_BAR_END ) } \n` ;
4755 }
4856 } ,
4957 } ) . prompt ( ) as Promise < string | symbol > ;
0 commit comments