Skip to content

Commit 37fa7ae

Browse files
committed
Show multichoice hint for keys
1 parent f00bc25 commit 37fa7ae

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/prompts/src/multi-select.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
120120
);
121121
};
122122
const required = opts.required ?? true;
123+
const hint = ' ' + color.reset(
124+
color.dim(
125+
`Press ${color.gray(color.bgWhite(color.inverse(' space ')))} to select, ${color.gray(
126+
color.bgWhite(color.inverse(' enter ')),
127+
)} to submit`,
128+
),
129+
)
123130

124131
return new MultiSelectPrompt({
125132
options: opts.options,
@@ -131,13 +138,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
131138
cursorAt: opts.cursorAt,
132139
validate(selected: Value[] | undefined) {
133140
if (required && (selected === undefined || selected.length === 0)) {
134-
return `Please select at least one option.\n${color.reset(
135-
color.dim(
136-
`Press ${color.gray(color.bgWhite(color.inverse(' space ')))} to select, ${color.gray(
137-
color.bgWhite(color.inverse(' enter ')),
138-
)} to submit`,
139-
),
140-
)}`;
141+
return `Please select at least one option.\n${hint}`;
141142
}
142143
return undefined;
143144
},
@@ -221,7 +222,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
221222
columnPadding: prefix.length,
222223
rowPadding: titleLineCount + footerLineCount,
223224
style: styleOption,
224-
}).join(`\n${prefix}`)}\n${footer}\n`;
225+
}).join(`\n${prefix}`)}\n${hint}\n${footer}\n`;
225226
}
226227
default: {
227228
const prefix = hasGuide ? `${color.blue(S_BAR)} ` : nestedPrefix;
@@ -236,7 +237,7 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
236237
columnPadding: prefix.length,
237238
rowPadding: titleLineCount + footerLineCount,
238239
style: styleOption,
239-
}).join(`\n${prefix}`)}\n${hasGuide ? color.blue(S_BAR_END) : ''}\n`;
240+
}).join(`\n${prefix}`)}\n${hint}\n${hasGuide ? color.blue(S_BAR_END) : ''}\n`;
240241
}
241242
}
242243
},

0 commit comments

Comments
 (0)