@@ -138,7 +138,9 @@ function applyTheme(data: ThemeParams): string {
138138 style : ( line ) => color . strikethrough ( color . dim ( line ) ) ,
139139 } ,
140140 } ) ,
141- ] . join ( '\n' ) ;
141+ ]
142+ . filter ( Boolean )
143+ . join ( '\n' ) ;
142144
143145 case 'error' :
144146 return [
@@ -311,17 +313,16 @@ export const select = <Value>(opts: SelectOptions<Value>) => {
311313 value = opt ( this . options [ this . cursor ] , 'selected' ) ;
312314 break ;
313315 case 'cancel' :
314- return `${ title } ${ color . gray ( S_BAR ) } ${ opt (
315- this . options [ this . cursor ] ,
316- 'cancelled'
317- ) } \n${ color . gray ( S_BAR ) } `;
316+ value = opt ( this . options [ this . cursor ] , 'cancelled' ) ;
317+ break ;
318318 default : {
319- return ` ${ title } ${ color . cyan ( S_BAR ) } ${ limitOptions ( {
319+ value = limitOptions ( {
320320 cursor : this . cursor ,
321321 options : this . options ,
322322 maxItems : opts . maxItems ,
323323 style : ( item , active ) => opt ( item , active ? 'active' : 'inactive' ) ,
324- } ) . join ( `\n${ color . cyan ( S_BAR ) } ` ) } \n${ color . cyan ( S_BAR_END ) } \n`;
324+ } ) . join ( '\n' ) ;
325+ break ;
325326 }
326327 }
327328 return applyTheme ( {
@@ -362,26 +363,19 @@ export const selectKey = <Value extends string>(opts: SelectOptions<Value>) => {
362363
363364 switch ( this . state ) {
364365 case 'submit' :
365- return `${ title } ${ color . gray ( S . BAR ) } ${ opt (
366+ return `${ title } \n ${ color . gray ( S_BAR ) } ${ opt (
366367 this . options . find ( ( opt ) => opt . value === this . value ) ! ,
367368 'selected'
368369 ) } `;
369370 case 'cancel' :
370- return `${ title } ${ color . gray ( S_BAR ) } ${ opt ( this . options [ 0 ] , 'cancelled' ) } \n${ color . gray (
371+ return `${ title } \n ${ color . gray ( S_BAR ) } ${ opt ( this . options [ 0 ] , 'cancelled' ) } \n${ color . gray (
371372 S_BAR
372373 ) } `;
373374 default :
374- return `${ title } ${ color . cyan ( S_BAR ) } ${ this . options
375+ return `${ title } \n ${ color . cyan ( S_BAR ) } ${ this . options
375376 . map ( ( option , i ) => opt ( option , i === this . cursor ? 'active' : 'inactive' ) )
376377 . join ( `\n${ color . cyan ( S_BAR ) } ` ) } \n${ color . cyan ( S_BAR_END ) } \n`;
377378 }
378-
379- return applyTheme ( {
380- ctx : this ,
381- message : opts . message ,
382- value,
383- valueWithCursor : undefined ,
384- } ) ;
385379 } ,
386380 } ) . prompt ( ) as Promise < Value | symbol > ;
387381} ;
@@ -465,34 +459,36 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
465459 . join ( color . dim ( ', ' ) ) ?? '' ;
466460 }
467461 case 'error' : {
468- const footer = this . error
469- . split ( '\n' )
470- . map ( ( ln , i ) =>
471- i === 0 ? `${ color . yellow ( S_BAR_END ) } ${ color . yellow ( ln ) } ` : ` ${ ln } `
472- )
473- . join ( '\n' ) ;
474- return (
475- title +
476- color . yellow ( S_BAR ) +
477- ' ' +
478- limitOptions ( {
479- options : this . options ,
480- cursor : this . cursor ,
481- maxItems : opts . maxItems ,
482- style : styleOption ,
483- } ) . join ( `\n${ color . yellow ( S_BAR ) } ` ) +
484- '\n' +
485- footer +
486- '\n'
462+ error = format (
463+ this . error
464+ . split ( '\n' )
465+ . map ( ( ln , i ) => ( i === 0 ? color . yellow ( ln ) : ln ) )
466+ . join ( '\n' ) ,
467+ {
468+ firstLine : {
469+ start : color . yellow ( S_BAR_END ) ,
470+ } ,
471+ default : {
472+ start : color . hidden ( '-' ) ,
473+ } ,
474+ }
487475 ) ;
476+ value = limitOptions ( {
477+ cursor : this . cursor ,
478+ maxItems : opts . maxItems ,
479+ options : this . options ,
480+ style : styleOption ,
481+ } ) . join ( '\n' ) ;
482+ break ;
488483 }
489484 default : {
490- return `${ title } ${ color . cyan ( S_BAR ) } ${ limitOptions ( {
491- options : this . options ,
485+ value = limitOptions ( {
492486 cursor : this . cursor ,
493487 maxItems : opts . maxItems ,
488+ options : this . options ,
494489 style : styleOption ,
495- } ) . join ( `\n${ color . cyan ( S_BAR ) } ` ) } \n${ color . cyan ( S_BAR_END ) } \n`;
490+ } ) . join ( '\n' ) ;
491+ break ;
496492 }
497493 }
498494 return applyTheme ( {
@@ -585,7 +581,7 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
585581 }
586582 } ;
587583
588- let title = `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } \n ` ;
584+ let title = `${ color . gray ( S_BAR ) } \n${ symbol ( this . state ) } ${ opts . message } ` ;
589585
590586 switch ( this . state ) {
591587 case 'submit' : {
@@ -868,9 +864,8 @@ export const spinner = () => {
868864 : code === 1
869865 ? color . red ( S_STEP_CANCEL )
870866 : color . red ( S_STEP_ERROR ) ;
871- process . stdout . write ( cursor . move ( - 999 , 0 ) ) ;
872- process . stdout . write ( erase . down ( 1 ) ) ;
873- process . stdout . write ( `${ step } ${ _message } \n` ) ;
867+ _message = formatMessage ( step , msg || _message ) ;
868+ process . stdout . write ( _message + '\n' ) ;
874869 clearHooks ( ) ;
875870 unblock ( ) ;
876871 } ;
0 commit comments