( nextState: TextState, options: TextOptionsReq, submitted: boolean, renderOptions?: RenderOptions | undefined )
| 3489 | }) |
| 3490 | |
| 3491 | const renderTextInput = ( |
| 3492 | nextState: TextState, |
| 3493 | options: TextOptionsReq, |
| 3494 | submitted: boolean, |
| 3495 | renderOptions?: RenderOptions | undefined |
| 3496 | ) => { |
| 3497 | const text = nextState.value |
| 3498 | if (renderOptions?.plain === true) { |
| 3499 | switch (options.type) { |
| 3500 | case "hidden": { |
| 3501 | return "" |
| 3502 | } |
| 3503 | case "password": { |
| 3504 | return "*".repeat(text.length) |
| 3505 | } |
| 3506 | case "text": { |
| 3507 | return text |
| 3508 | } |
| 3509 | } |
| 3510 | } |
| 3511 | |
| 3512 | const annotation = Option.isSome(nextState.error) ? |
| 3513 | Ansi.red |
| 3514 | : submitted ? |
| 3515 | Ansi.white |
| 3516 | : nextState.value.length === 0 ? |
| 3517 | Ansi.blackBright |
| 3518 | : Ansi.combine(Ansi.underlined, Ansi.cyanBright) |
| 3519 | |
| 3520 | switch (options.type) { |
| 3521 | case "hidden": { |
| 3522 | return "" |
| 3523 | } |
| 3524 | case "password": { |
| 3525 | return Ansi.annotate("*".repeat(text.length), annotation) |
| 3526 | } |
| 3527 | case "text": { |
| 3528 | return Ansi.annotate(text, annotation) |
| 3529 | } |
| 3530 | } |
| 3531 | } |
| 3532 | |
| 3533 | const renderTextError = ( |
| 3534 | nextState: TextState, |
no test coverage detected