diff --git a/packages/prompts/src/index.ts b/packages/prompts/src/index.ts index b33bfb7..9969315 100644 --- a/packages/prompts/src/index.ts +++ b/packages/prompts/src/index.ts @@ -69,7 +69,7 @@ function formatTextWithMaxWidth( lineWrapper?: (line: string) => string; } ): string { - const defaultSymbol = options?.defaultSymbol ?? color.cyan(S_BAR); + const defaultSymbol = options?.defaultSymbol ?? color.gray(S_BAR); const initialSymbol = options?.initialSymbol ?? defaultSymbol; const newLineSymbol = options?.newLineSymbol ?? defaultSymbol; const endSymbol = options?.endSymbol ?? defaultSymbol; @@ -153,15 +153,19 @@ export const text = (opts: TextOptions) => { return [ title, formatTextWithMaxWidth(this.value ?? '', { - defaultSymbol: color.gray(S_BAR), endSymbol: color.gray(S_BAR_END), lineWrapper: (line) => color.strikethrough(color.dim(line)), }), ].join('\n'); default: return [ - title, + color.gray(S_BAR), + formatTextWithMaxWidth(opts.message, { + initialSymbol: symbol(this.state), + defaultSymbol: color.cyan(S_BAR), + }), formatTextWithMaxWidth(value, { + defaultSymbol: color.cyan(S_BAR), endSymbol: color.cyan(S_BAR_END), }), ].join('\n'); @@ -208,15 +212,22 @@ export const password = (opts: PasswordOptions) => { return [ title, formatTextWithMaxWidth(masked ?? '', { - defaultSymbol: color.gray(S_BAR), endSymbol: color.gray(S_BAR_END), lineWrapper: (line) => color.strikethrough(color.dim(line)), }), ].join('\n'); default: - return [title, formatTextWithMaxWidth(value, { endSymbol: color.cyan(S_BAR_END) })].join( - '\n' - ); + return [ + color.gray(S_BAR), + formatTextWithMaxWidth(opts.message, { + initialSymbol: symbol(this.state), + defaultSymbol: color.cyan(S_BAR), + }), + formatTextWithMaxWidth(value, { + defaultSymbol: color.cyan(S_BAR), + endSymbol: color.cyan(S_BAR_END), + }), + ].join('\n'); } }, }).prompt() as Promise; @@ -251,7 +262,6 @@ export const confirm = (opts: ConfirmOptions) => { return [ title, formatTextWithMaxWidth(value, { - defaultSymbol: color.gray(S_BAR), endSymbol: color.gray(S_BAR_END), lineWrapper: (line) => color.strikethrough(color.dim(line)), }), @@ -330,7 +340,6 @@ export const select = [], Value>( return [ title, formatTextWithMaxWidth(opt(this.options[this.cursor], 'cancelled'), { - defaultSymbol: color.gray(S_BAR), endSymbol: color.gray(S_BAR_END), lineWrapper: (line) => color.strikethrough(color.dim(line)), }), @@ -354,7 +363,11 @@ export const select = [], Value>( slidingWindowLocation + maxItems < this.options.length; return [ - title, + color.gray(S_BAR), + formatTextWithMaxWidth(opts.message, { + initialSymbol: symbol(this.state), + defaultSymbol: color.cyan(S_BAR), + }), this.options .slice(slidingWindowLocation, slidingWindowLocation + maxItems) .map((option, i, arr) => { @@ -364,7 +377,8 @@ export const select = [], Value>( return color.dim('...'); } else { return formatTextWithMaxWidth( - opt(option, i + slidingWindowLocation === this.cursor ? 'active' : 'inactive') + opt(option, i + slidingWindowLocation === this.cursor ? 'active' : 'inactive'), + { defaultSymbol: color.cyan(S_BAR) } ); } }) @@ -498,7 +512,6 @@ export const multiselect = [], Value>( return [ title, formatTextWithMaxWidth(label ?? '', { - defaultSymbol: color.gray(S_BAR), endSymbol: color.gray(S_BAR_END), lineWrapper: (line) => color.strikethrough(color.dim(line)), }), @@ -531,7 +544,11 @@ export const multiselect = [], Value>( } default: { return [ - title, + color.gray(S_BAR), + formatTextWithMaxWidth(opts.message, { + initialSymbol: symbol(this.state), + defaultSymbol: color.cyan(S_BAR), + }), this.options .map((option, i) => { const selected = this.value.includes(option.value); @@ -722,7 +739,6 @@ export const note = (message = '', title = '') => { )}`, color.gray(S_BAR + ' '.repeat(len) + S_BAR), formatTextWithMaxWidth(message, { - defaultSymbol: color.gray(S_BAR), maxWidth: messageLen, lineWrapper: (line) => line + ' '.repeat(len - strLength(line) - 1) + color.gray(S_BAR), }), @@ -736,7 +752,6 @@ export const note = (message = '', title = '') => { export const cancel = (message = '') => { process.stdout.write( formatTextWithMaxWidth(message, { - defaultSymbol: color.gray(S_BAR), endSymbol: color.gray(S_BAR_END), lineWrapper: color.red, }) + '\n\n' @@ -747,7 +762,6 @@ export const intro = (title = '') => { process.stdout.write( formatTextWithMaxWidth(title, { initialSymbol: color.gray(S_BAR_START), - defaultSymbol: color.gray(S_BAR), }) ); }; @@ -757,7 +771,6 @@ export const outro = (message = '') => { [ color.gray(S_BAR), formatTextWithMaxWidth(message, { - defaultSymbol: color.gray(S_BAR), endSymbol: color.gray(S_BAR_END), }), '', @@ -774,7 +787,6 @@ export const log = { process.stdout.write( formatTextWithMaxWidth(message, { initialSymbol: symbol, - defaultSymbol: color.gray(S_BAR), }) ); }, @@ -782,7 +794,6 @@ export const log = { process.stdout.write( formatTextWithMaxWidth(message, { initialSymbol: color.blue(S_INFO), - defaultSymbol: color.blue(S_BAR), }) ); }, @@ -790,7 +801,6 @@ export const log = { process.stdout.write( formatTextWithMaxWidth(message, { initialSymbol: color.green(S_SUCCESS), - defaultSymbol: color.green(S_BAR), }) ); }, @@ -798,7 +808,6 @@ export const log = { process.stdout.write( formatTextWithMaxWidth(message, { initialSymbol: color.green(S_STEP_SUBMIT), - defaultSymbol: color.green(S_BAR), }) ); }, @@ -806,7 +815,6 @@ export const log = { process.stdout.write( formatTextWithMaxWidth(message, { initialSymbol: color.yellow(S_WARN), - defaultSymbol: color.yellow(S_BAR), }) ); }, @@ -818,7 +826,6 @@ export const log = { process.stdout.write( formatTextWithMaxWidth(message, { initialSymbol: color.red(S_ERROR), - defaultSymbol: color.red(S_BAR), }) ); }, @@ -837,7 +844,6 @@ export const spinner = () => { const formatMessage = (symbol: string, msg: string): string => { return formatTextWithMaxWidth(msg, { initialSymbol: symbol, - defaultSymbol: '', }); };