@@ -34,22 +34,22 @@ type Config<Value> = {
34
34
} ;
35
35
36
36
function isSelectableChoice < T > (
37
- choice : undefined | Separator | Choice < T >
37
+ choice : undefined | Separator | Choice < T > ,
38
38
) : choice is Choice < T > {
39
39
return choice != null && ! Separator . isSeparator ( choice ) && ! choice . disabled ;
40
40
}
41
41
42
42
export default createPrompt (
43
43
< Value extends unknown > (
44
44
config : Config < Value > ,
45
- done : ( value : Array < Value > ) => void
45
+ done : ( value : Array < Value > ) => void ,
46
46
) : string => {
47
47
const { prefix = usePrefix ( ) , instructions } = config ;
48
48
const paginator = useRef ( new Paginator ( ) ) . current ;
49
49
50
50
const [ status , setStatus ] = useState ( 'pending' ) ;
51
51
const [ choices , setChoices ] = useState < Array < Separator | Choice < Value > > > ( ( ) =>
52
- config . choices . map ( ( choice ) => ( { ...choice } ) )
52
+ config . choices . map ( ( choice ) => ( { ...choice } ) ) ,
53
53
) ;
54
54
const [ cursorPosition , setCursorPosition ] = useState ( 0 ) ;
55
55
const [ showHelpTip , setShowHelpTip ] = useState ( true ) ;
@@ -61,7 +61,7 @@ export default createPrompt(
61
61
done (
62
62
choices
63
63
. filter ( ( choice ) => isSelectableChoice ( choice ) && choice . checked )
64
- . map ( ( choice ) => ( choice as Choice < Value > ) . value )
64
+ . map ( ( choice ) => ( choice as Choice < Value > ) . value ) ,
65
65
) ;
66
66
} else if ( isUpKey ( key ) || isDownKey ( key ) ) {
67
67
const offset = isUpKey ( key ) ? - 1 : 1 ;
@@ -83,22 +83,22 @@ export default createPrompt(
83
83
}
84
84
85
85
return choice ;
86
- } )
86
+ } ) ,
87
87
) ;
88
88
} else if ( key . name === 'a' ) {
89
89
const selectAll = Boolean (
90
- choices . find ( ( choice ) => isSelectableChoice ( choice ) && ! choice . checked )
90
+ choices . find ( ( choice ) => isSelectableChoice ( choice ) && ! choice . checked ) ,
91
91
) ;
92
92
setChoices (
93
93
choices . map ( ( choice ) =>
94
- isSelectableChoice ( choice ) ? { ...choice , checked : selectAll } : choice
95
- )
94
+ isSelectableChoice ( choice ) ? { ...choice , checked : selectAll } : choice ,
95
+ ) ,
96
96
) ;
97
97
} else if ( key . name === 'i' ) {
98
98
setChoices (
99
99
choices . map ( ( choice ) =>
100
- isSelectableChoice ( choice ) ? { ...choice , checked : ! choice . checked } : choice
101
- )
100
+ isSelectableChoice ( choice ) ? { ...choice , checked : ! choice . checked } : choice ,
101
+ ) ,
102
102
) ;
103
103
} else if ( isNumberKey ( key ) ) {
104
104
// Adjust index to start at 1
@@ -117,7 +117,7 @@ export default createPrompt(
117
117
}
118
118
119
119
return choice ;
120
- } )
120
+ } ) ,
121
121
) ;
122
122
}
123
123
} ) ;
@@ -128,7 +128,7 @@ export default createPrompt(
128
128
const selection = choices
129
129
. filter ( ( choice ) => isSelectableChoice ( choice ) && choice . checked )
130
130
. map (
131
- ( choice ) => ( choice as Choice < Value > ) . name || ( choice as Choice < Value > ) . value
131
+ ( choice ) => ( choice as Choice < Value > ) . name || ( choice as Choice < Value > ) . value ,
132
132
) ;
133
133
return `${ prefix } ${ message } ${ chalk . cyan ( selection . join ( ', ' ) ) } ` ;
134
134
}
@@ -175,10 +175,10 @@ export default createPrompt(
175
175
const windowedChoices = paginator . paginate (
176
176
allChoices ,
177
177
cursorPosition ,
178
- config . pageSize
178
+ config . pageSize ,
179
179
) ;
180
180
return `${ prefix } ${ message } ${ helpTip } \n${ windowedChoices } ${ ansiEscapes . cursorHide } ` ;
181
- }
181
+ } ,
182
182
) ;
183
183
184
184
export { Separator } ;
0 commit comments