11import {
22 block ,
33 ConfirmPrompt ,
4+ GroupMultiSelectPrompt ,
45 isCancel ,
56 MultiSelectPrompt ,
6- GroupMultiSelectPrompt ,
77 PasswordPrompt ,
88 SelectKeyPrompt ,
99 SelectPrompt ,
@@ -325,10 +325,12 @@ export const multiselect = <Options extends Option<Value>[], Value extends Primi
325325
326326 switch ( this . state ) {
327327 case 'submit' : {
328- return `${ title } ${ color . gray ( S_BAR ) } ${ this . options
329- . filter ( ( { value } ) => this . value . includes ( value ) )
330- . map ( ( option ) => opt ( option , 'submitted' ) )
331- . join ( color . dim ( ', ' ) ) || color . dim ( 'none' ) } `;
328+ return `${ title } ${ color . gray ( S_BAR ) } ${
329+ this . options
330+ . filter ( ( { value } ) => this . value . includes ( value ) )
331+ . map ( ( option ) => opt ( option , 'submitted' ) )
332+ . join ( color . dim ( ', ' ) ) || color . dim ( 'none' )
333+ } `;
332334 }
333335 case 'cancel' : {
334336 const label = this . options
@@ -400,8 +402,16 @@ export const groupMultiselect = <Options extends Option<Value>[], Value extends
400402) => {
401403 const opt = (
402404 option : Options [ number ] ,
403- state : 'inactive' | 'active' | 'selected' | 'active-selected' | 'group-active' | 'group-active-selected' | 'submitted' | 'cancelled' ,
404- options : Options = [ ] as any ,
405+ state :
406+ | 'inactive'
407+ | 'active'
408+ | 'selected'
409+ | 'active-selected'
410+ | 'group-active'
411+ | 'group-active-selected'
412+ | 'submitted'
413+ | 'cancelled' ,
414+ options : Options = [ ] as any
405415 ) => {
406416 const label = option . label ?? String ( option . value ) ;
407417 const isItem = typeof option . group === 'string' ;
@@ -474,9 +484,14 @@ export const groupMultiselect = <Options extends Option<Value>[], Value extends
474484 . join ( '\n' ) ;
475485 return `${ title } ${ color . yellow ( S_BAR ) } ${ this . options
476486 . map ( ( option , i , options ) => {
477- const selected = this . value . includes ( option . value ) || ( option . group === true && this . isGroupSelected ( option . value ) ) ;
487+ const selected =
488+ this . value . includes ( option . value ) ||
489+ ( option . group === true && this . isGroupSelected ( option . value ) ) ;
478490 const active = i === this . cursor ;
479- const groupActive = ! active && typeof option . group === 'string' && this . options [ this . cursor ] . value === option . group ;
491+ const groupActive =
492+ ! active &&
493+ typeof option . group === 'string' &&
494+ this . options [ this . cursor ] . value === option . group ;
480495 if ( groupActive ) {
481496 return opt ( option , selected ? 'group-active-selected' : 'group-active' , options ) ;
482497 }
@@ -493,9 +508,14 @@ export const groupMultiselect = <Options extends Option<Value>[], Value extends
493508 default : {
494509 return `${ title } ${ color . cyan ( S_BAR ) } ${ this . options
495510 . map ( ( option , i , options ) => {
496- const selected = this . value . includes ( option . value ) || ( option . group === true && this . isGroupSelected ( option . value ) ) ;
511+ const selected =
512+ this . value . includes ( option . value ) ||
513+ ( option . group === true && this . isGroupSelected ( option . value ) ) ;
497514 const active = i === this . cursor ;
498- const groupActive = ! active && typeof option . group === 'string' && this . options [ this . cursor ] . value === option . group ;
515+ const groupActive =
516+ ! active &&
517+ typeof option . group === 'string' &&
518+ this . options [ this . cursor ] . value === option . group ;
499519 if ( groupActive ) {
500520 return opt ( option , selected ? 'group-active-selected' : 'group-active' , options ) ;
501521 }
@@ -517,11 +537,14 @@ export const groupMultiselect = <Options extends Option<Value>[], Value extends
517537const strip = ( str : string ) => str . replace ( ansiRegex ( ) , '' ) ;
518538export const note = ( message = '' , title = '' ) => {
519539 const lines = `\n${ message } \n` . split ( '\n' ) ;
520- const len = Math . max (
521- lines . reduce ( ( sum , ln ) => {
522- ln = strip ( ln ) ;
523- return ln . length > sum ? ln . length : sum ;
524- } , 0 ) , strip ( title ) . length ) + 2 ;
540+ const len =
541+ Math . max (
542+ lines . reduce ( ( sum , ln ) => {
543+ ln = strip ( ln ) ;
544+ return ln . length > sum ? ln . length : sum ;
545+ } , 0 ) ,
546+ strip ( title ) . length
547+ ) + 2 ;
525548 const msg = lines
526549 . map (
527550 ( ln ) =>
@@ -641,7 +664,9 @@ export interface PromptGroupOptions<T> {
641664}
642665
643666export type PromptGroup < T > = {
644- [ P in keyof T ] : ( opts : { results : Partial < PromptGroupAwaitedReturn < T > > } ) => void | Promise < T [ P ] | void > ;
667+ [ P in keyof T ] : ( opts : {
668+ results : Partial < PromptGroupAwaitedReturn < T > > ;
669+ } ) => void | Promise < T [ P ] | void > ;
645670} ;
646671
647672/**
0 commit comments