Skip to content

Commit 57df900

Browse files
authored
multiselect: initialValue -> initialValues (#73)
2 parents 68f5c56 + 038b137 commit 57df900

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.changeset/tall-hairs-knock.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@clack/core": minor
3+
"@clack/prompts": minor
4+
---
5+
6+
**Breaking Change** `multiselect` has renamed `initialValue` to `initialValues`

examples/basic/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function main() {
4242
tools: () =>
4343
p.multiselect({
4444
message: 'Select additional tools.',
45-
initialValue: ['prettier', 'eslint'],
45+
initialValues: ['prettier', 'eslint'],
4646
options: [
4747
{ value: 'prettier', label: 'Prettier', hint: 'recommended' },
4848
{ value: 'eslint', label: 'ESLint', hint: 'recommended' },

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Prompt, { PromptOptions } from './prompt';
22

33
interface MultiSelectOptions<T extends { value: any }> extends PromptOptions<MultiSelectPrompt<T>> {
44
options: T[];
5-
initialValue?: T['value'][];
5+
initialValues?: T['value'][];
66
required?: boolean;
77
cursorAt?: T['value'];
88
}
@@ -25,7 +25,7 @@ export default class MultiSelectPrompt<T extends { value: any }> extends Prompt
2525
super(opts, false);
2626

2727
this.options = opts.options;
28-
this.value = [...(opts.initialValue ?? [])];
28+
this.value = [...(opts.initialValues ?? [])];
2929
this.cursor = Math.max(
3030
this.options.findIndex(({ value }) => value === opts.cursorAt),
3131
0

packages/prompts/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export const select = <Options extends Option<Value>[], Value extends Primitive>
219219
export interface MultiSelectOptions<Options extends Option<Value>[], Value extends Primitive> {
220220
message: string;
221221
options: Options;
222-
initialValue?: Options[number]['value'][];
222+
initialValues?: Options[number]['value'][];
223223
required?: boolean;
224224
cursorAt?: Options[number]['value'];
225225
}
@@ -251,7 +251,7 @@ export const multiselect = <Options extends Option<Value>[], Value extends Primi
251251

252252
return new MultiSelectPrompt({
253253
options: opts.options,
254-
initialValue: opts.initialValue,
254+
initialValues: opts.initialValues,
255255
required: opts.required ?? true,
256256
cursorAt: opts.cursorAt,
257257
validate(selected: Value[]) {

0 commit comments

Comments
 (0)