@@ -57,14 +57,18 @@ const S_ERROR = s("■", "x");
5757const symbol = ( state : State ) => {
5858 switch ( state ) {
5959 case "initial" :
60- case "active" :
60+ case "active" : {
6161 return color . cyan ( S_STEP_ACTIVE ) ;
62- case "cancel" :
62+ }
63+ case "cancel" : {
6364 return color . red ( S_STEP_CANCEL ) ;
64- case "error" :
65+ }
66+ case "error" : {
6567 return color . yellow ( S_STEP_ERROR ) ;
66- case "submit" :
68+ }
69+ case "submit" : {
6770 return color . green ( S_STEP_SUBMIT ) ;
71+ }
6872 }
6973} ;
7074
@@ -89,27 +93,31 @@ export const text = (opts: TextOptions) => {
8993 ? color . inverse ( opts . placeholder [ 0 ] ) +
9094 color . dim ( opts . placeholder . slice ( 1 ) )
9195 : color . inverse ( color . hidden ( "_" ) ) ;
92- const value = ! this . value ? placeholder : this . valueWithCursor ;
96+ const value = this . value ? this . valueWithCursor : placeholder ;
9397
9498 switch ( this . state ) {
95- case "error" :
99+ case "error" : {
96100 return `${ title . trim ( ) } \n${ color . yellow (
97101 S_BAR
98102 ) } ${ value } \n${ color . yellow ( S_BAR_END ) } ${ color . yellow (
99103 this . error
100104 ) } \n`;
101- case "submit" :
105+ }
106+ case "submit" : {
102107 return `${ title } ${ color . gray ( S_BAR ) } ${ color . dim (
103108 this . value || opts . placeholder
104109 ) } `;
105- case "cancel" :
110+ }
111+ case "cancel" : {
106112 return `${ title } ${ color . gray ( S_BAR ) } ${ color . strikethrough (
107113 color . dim ( this . value ?? "" )
108114 ) } ${ this . value ?. trim ( ) ? "\n" + color . gray ( S_BAR ) : "" } `;
109- default :
115+ }
116+ default : {
110117 return `${ title } ${ color . cyan ( S_BAR ) } ${ value } \n${ color . cyan (
111118 S_BAR_END
112119 ) } \n`;
120+ }
113121 }
114122 } ,
115123 } ) . prompt ( ) as Promise < string | symbol > ;
@@ -132,22 +140,26 @@ export const password = (opts: PasswordOptions) => {
132140 const masked = this . masked ;
133141
134142 switch ( this . state ) {
135- case "error" :
143+ case "error" : {
136144 return `${ title . trim ( ) } \n${ color . yellow (
137145 S_BAR
138146 ) } ${ masked } \n${ color . yellow ( S_BAR_END ) } ${ color . yellow (
139147 this . error
140148 ) } \n`;
141- case "submit" :
149+ }
150+ case "submit" : {
142151 return `${ title } ${ color . gray ( S_BAR ) } ${ color . dim ( masked ) } ` ;
143- case "cancel" :
152+ }
153+ case "cancel" : {
144154 return `${ title } ${ color . gray ( S_BAR ) } ${ color . strikethrough (
145155 color . dim ( masked ?? "" )
146156 ) } ${ masked ? "\n" + color . gray ( S_BAR ) : "" } `;
147- default :
157+ }
158+ default : {
148159 return `${ title } ${ color . cyan ( S_BAR ) } ${ value } \n${ color . cyan (
149160 S_BAR_END
150161 ) } \n`;
162+ }
151163 }
152164 } ,
153165 } ) . prompt ( ) as Promise < string | symbol > ;
@@ -173,21 +185,23 @@ export const confirm = (opts: ConfirmOptions) => {
173185 const value = this . value ? active : inactive ;
174186
175187 switch ( this . state ) {
176- case "submit" :
188+ case "submit" : {
177189 return `${ title } ${ color . gray ( S_BAR ) } ${ color . dim ( value ) } ` ;
178- case "cancel" :
190+ }
191+ case "cancel" : {
179192 return `${ title } ${ color . gray ( S_BAR ) } ${ color . strikethrough (
180193 color . dim ( value )
181194 ) } \n${ color . gray ( S_BAR ) } `;
195+ }
182196 default : {
183197 return `${ title } ${ color . cyan ( S_BAR ) } ${
184198 this . value
185199 ? `${ color . green ( S_RADIO_ACTIVE ) } ${ active } `
186200 : `${ color . dim ( S_RADIO_INACTIVE ) } ${ color . dim ( active ) } `
187201 } ${ color . dim ( "/" ) } ${
188- ! this . value
189- ? `${ color . green ( S_RADIO_ACTIVE ) } ${ inactive } `
190- : `${ color . dim ( S_RADIO_INACTIVE ) } ${ color . dim ( inactive ) } `
202+ this . value
203+ ? `${ color . dim ( S_RADIO_INACTIVE ) } ${ color . dim ( inactive ) } `
204+ : `${ color . green ( S_RADIO_ACTIVE ) } ${ inactive } `
191205 } \n${ color . cyan ( S_BAR_END ) } \n`;
192206 }
193207 }
@@ -241,16 +255,18 @@ export const select = <Options extends Option<Value>[], Value>(
241255 } \n`;
242256
243257 switch ( this . state ) {
244- case "submit" :
258+ case "submit" : {
245259 return `${ title } ${ color . gray ( S_BAR ) } ${ opt (
246260 this . options [ this . cursor ] ,
247261 "selected"
248262 ) } `;
249- case "cancel" :
263+ }
264+ case "cancel" : {
250265 return `${ title } ${ color . gray ( S_BAR ) } ${ opt (
251266 this . options [ this . cursor ] ,
252267 "cancelled"
253268 ) } \n${ color . gray ( S_BAR ) } `;
269+ }
254270 default : {
255271 return `${ title } ${ color . cyan ( S_BAR ) } ${ this . options
256272 . map ( ( option , i ) =>
@@ -302,17 +318,19 @@ export const selectKey = <
302318 } \n`;
303319
304320 switch ( this . state ) {
305- case "submit" :
321+ case "submit" : {
306322 return `${ title } ${ color . gray ( S_BAR ) } ${ opt (
307323 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
308324 this . options . find ( ( opt ) => opt . value === this . value ) ! ,
309325 "selected"
310326 ) } `;
311- case "cancel" :
327+ }
328+ case "cancel" : {
312329 return `${ title } ${ color . gray ( S_BAR ) } ${ opt (
313330 this . options [ 0 ] ,
314331 "cancelled"
315332 ) } \n${ color . gray ( S_BAR ) } `;
333+ }
316334 default : {
317335 return `${ title } ${ color . cyan ( S_BAR ) } ${ this . options
318336 . map ( ( option , i ) =>
0 commit comments