1- import { PasswordPrompt } from '@clack/core' ;
1+ import { PasswordPrompt , settings } from '@clack/core' ;
22import color from 'picocolors' ;
33import { type CommonOptions , S_BAR , S_BAR_END , S_PASSWORD_MASK , symbol } from './common.js' ;
44
@@ -16,7 +16,8 @@ export const password = (opts: PasswordOptions) => {
1616 input : opts . input ,
1717 output : opts . output ,
1818 render ( ) {
19- const title = `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } \n` ;
19+ const hasGuide = ( opts . withGuide ?? settings . withGuide ) !== false ;
20+ const title = `${ hasGuide ? `${ color . gray ( S_BAR ) } \n` : '' } ${ symbol ( this . state ) } ${ opts . message } \n` ;
2021 const userInput = this . userInputWithCursor ;
2122 const masked = this . masked ;
2223
@@ -26,22 +27,27 @@ export const password = (opts: PasswordOptions) => {
2627 if ( opts . clearOnError ) {
2728 this . clear ( ) ;
2829 }
29- return `${ title . trim ( ) } \n ${ color . yellow ( S_BAR ) } ${ maskedText } \n ${ color . yellow (
30- S_BAR_END
31- ) } ${ color . yellow ( this . error ) } \n`;
30+ const errorPrefix = hasGuide ? `${ color . yellow ( S_BAR ) } ` : '' ;
31+ const errorPrefixEnd = hasGuide ? color . yellow ( S_BAR_END ) : '' ;
32+ return ` ${ title . trim ( ) } \n ${ errorPrefix } ${ maskedText } \n ${ errorPrefixEnd } ${ color . yellow ( this . error ) } \n`;
3233 }
3334 case 'submit' : {
3435 const maskedText = masked ? ` ${ color . dim ( masked ) } ` : '' ;
35- return `${ title } ${ color . gray ( S_BAR ) } ${ maskedText } ` ;
36+ const submitPrefix = hasGuide ? color . gray ( S_BAR ) : '' ;
37+ return `${ title } ${ submitPrefix } ${ maskedText } ` ;
3638 }
3739 case 'cancel' : {
3840 const maskedText = masked ? ` ${ color . strikethrough ( color . dim ( masked ) ) } ` : '' ;
39- return `${ title } ${ color . gray ( S_BAR ) } ${ maskedText } ${
40- masked ? `\n${ color . gray ( S_BAR ) } ` : ''
41+ const cancelPrefix = hasGuide ? color . gray ( S_BAR ) : '' ;
42+ return `${ title } ${ cancelPrefix } ${ maskedText } ${
43+ masked && hasGuide ? `\n${ color . gray ( S_BAR ) } ` : ''
4144 } `;
4245 }
43- default :
44- return `${ title } ${ color . cyan ( S_BAR ) } ${ userInput } \n${ color . cyan ( S_BAR_END ) } \n` ;
46+ default : {
47+ const defaultPrefix = hasGuide ? `${ color . cyan ( S_BAR ) } ` : '' ;
48+ const defaultPrefixEnd = hasGuide ? color . cyan ( S_BAR_END ) : '' ;
49+ return `${ title } ${ defaultPrefix } ${ userInput } \n${ defaultPrefixEnd } \n` ;
50+ }
4551 }
4652 } ,
4753 } ) . prompt ( ) as Promise < string | symbol > ;
0 commit comments