@@ -20,8 +20,6 @@ export interface PromptOptions<Self extends Prompt> {
20
20
debug ?: boolean ;
21
21
}
22
22
23
- export type State = 'initial' | 'active' | 'cancel' | 'submit' | 'error' ;
24
-
25
23
export type LineOption = 'firstLine' | 'newLine' | 'lastLine' ;
26
24
27
25
export interface FormatLineOptions {
@@ -313,8 +311,8 @@ export default class Prompt {
313
311
) : NonNullable < FormatOptions [ TLine ] [ TKey ] > => {
314
312
return (
315
313
key === 'style'
316
- ? options ?. [ line ] ?. [ key ] ?? options ?. default ?. [ key ] ?? ( ( line ) => line )
317
- : options ?. [ line ] ?. [ key ] ?? options ?. [ line ] ?. sides ?? options ?. default ?. [ key ] ?? ''
314
+ ? ( options ?. [ line ] ?. [ key ] ?? options ?. default ?. [ key ] ?? ( ( line ) => line ) )
315
+ : ( options ?. [ line ] ?. [ key ] ?? options ?. [ line ] ?. sides ?? options ?. default ?. [ key ] ?? '' )
318
316
) as NonNullable < FormatOptions [ TLine ] [ TKey ] > ;
319
317
} ;
320
318
const getLineOptions = ( line : LineOption ) : Omit < FormatLineOptions , 'sides' > => {
@@ -376,14 +374,14 @@ export default class Prompt {
376
374
) : FormatLineOptions [ TPosition ] => {
377
375
return (
378
376
i === 0 && ar . length === 1
379
- ? options ?. firstLine ?. [ position ] ??
380
- options ?. lastLine ?. [ position ] ??
381
- firstLine [ position ]
377
+ ? ( options ?. firstLine ?. [ position ] ??
378
+ options ?. lastLine ?. [ position ] ??
379
+ firstLine [ position ] )
382
380
: i === 0
383
- ? firstLine [ position ]
384
- : i + 1 === ar . length
385
- ? lastLine [ position ]
386
- : newLine [ position ]
381
+ ? firstLine [ position ]
382
+ : i + 1 === ar . length
383
+ ? lastLine [ position ]
384
+ : newLine [ position ]
387
385
) as FormatLineOptions [ TPosition ] ;
388
386
} ;
389
387
const startLine = opt ( 'start' ) ;
@@ -401,9 +399,10 @@ export default class Prompt {
401
399
. join ( '\n' ) ;
402
400
}
403
401
404
- private _prevFrame = '' ;
405
402
private render ( ) {
406
- const frame = wrap ( this . _render ( this ) ?? '' , process . stdout . columns , { hard : true } ) ;
403
+ const frame = wrap ( this . _render ( this ) ?? '' , process . stdout . columns , {
404
+ hard : true ,
405
+ } ) ;
407
406
if ( frame === this . _prevFrame ) return ;
408
407
409
408
if ( this . state === 'initial' ) {
0 commit comments