Skip to content

Commit 87136d2

Browse files
committed
fix: use required default
1 parent ae329d7 commit 87136d2

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

packages/prompts/src/group-multi-select.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,18 @@ export const groupMultiselect = <Value>(opts: GroupMultiSelectOptions<Value>) =>
7474
const unselectedCheckbox = isItem || selectableGroups ? color.dim(S_CHECKBOX_INACTIVE) : '';
7575
return `${spacingPrefix}${color.dim(prefix)}${unselectedCheckbox} ${color.dim(label)}`;
7676
};
77+
const required = opts.required ?? true;
7778

7879
return new GroupMultiSelectPrompt({
7980
options: opts.options,
8081
input: opts.input,
8182
output: opts.output,
8283
initialValues: opts.initialValues,
83-
required: opts.required ?? true,
84+
required,
8485
cursorAt: opts.cursorAt,
8586
selectableGroups,
8687
validate(selected: Value[] | undefined) {
87-
if (opts.required && (selected === undefined || selected.length === 0))
88+
if (required && (selected === undefined || selected.length === 0))
8889
return `Please select at least one option.\n${color.reset(
8990
color.dim(
9091
`Press ${color.gray(color.bgWhite(color.inverse(' space ')))} to select, ${color.gray(

packages/prompts/src/multi-select.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,17 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
4949
}
5050
return `${color.dim(S_CHECKBOX_INACTIVE)} ${color.dim(label)}`;
5151
};
52+
const required = opts.required ?? true;
5253

5354
return new MultiSelectPrompt({
5455
options: opts.options,
5556
input: opts.input,
5657
output: opts.output,
5758
initialValues: opts.initialValues,
58-
required: opts.required ?? true,
59+
required,
5960
cursorAt: opts.cursorAt,
6061
validate(selected: Value[] | undefined) {
61-
if (opts.required && (selected === undefined || selected.length === 0))
62+
if (required && (selected === undefined || selected.length === 0))
6263
return `Please select at least one option.\n${color.reset(
6364
color.dim(
6465
`Press ${color.gray(color.bgWhite(color.inverse(' space ')))} to select, ${color.gray(

packages/prompts/src/path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { existsSync, lstatSync, readdirSync } from 'node:fs';
2-
import { join, dirname } from 'node:path';
2+
import { dirname, join } from 'node:path';
33
import { autocomplete } from './autocomplete.js';
44
import type { CommonOptions } from './common.js';
55

packages/prompts/test/__snapshots__/autocomplete.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ exports[`autocomplete > shows no matches message when search has no results 1`]
173173
"<cursor.down count=1>",
174174
"<erase.down>",
175175
"◇ Select a fruit
176-
[90m│[39m [2mApple[22m",
176+
[90m│[39m[2m[22m",
177177
"
178178
",
179179
"<cursor.show>",

0 commit comments

Comments
 (0)