Comparing version 12.2.0 to 12.3.0
@@ -48,3 +48,5 @@ import { checkbox, confirm, editor, expand, input, number, password, rawlist, search, select } from '@inquirer/prompts'; | ||
}>; | ||
export type UnnamedDistinctQuestion<A extends Answers = object> = QuestionWithGetters<'checkbox', Parameters<typeof checkbox>[0], A> | QuestionWithGetters<'confirm', Parameters<typeof confirm>[0], A> | QuestionWithGetters<'editor', Parameters<typeof editor>[0], A> | QuestionWithGetters<'expand', Parameters<typeof expand>[0], A> | QuestionWithGetters<'input', Parameters<typeof input>[0], A> | QuestionWithGetters<'number', Parameters<typeof number>[0], A> | QuestionWithGetters<'password', Parameters<typeof password>[0], A> | QuestionWithGetters<'rawlist', Parameters<typeof rawlist>[0], A> | QuestionWithGetters<'search', Parameters<typeof search>[0], A> | QuestionWithGetters<'list', Parameters<typeof select>[0], A> | QuestionWithGetters<'select', Parameters<typeof select>[0], A>; | ||
export type UnnamedDistinctQuestion<A extends Answers = object> = QuestionWithGetters<'checkbox', Parameters<typeof checkbox>[0] & { | ||
default: unknown[]; | ||
}, A> | QuestionWithGetters<'confirm', Parameters<typeof confirm>[0], A> | QuestionWithGetters<'editor', Parameters<typeof editor>[0], A> | QuestionWithGetters<'expand', Parameters<typeof expand>[0], A> | QuestionWithGetters<'input', Parameters<typeof input>[0], A> | QuestionWithGetters<'number', Parameters<typeof number>[0], A> | QuestionWithGetters<'password', Parameters<typeof password>[0], A> | QuestionWithGetters<'rawlist', Parameters<typeof rawlist>[0], A> | QuestionWithGetters<'search', Parameters<typeof search>[0], A> | QuestionWithGetters<'list', Parameters<typeof select>[0], A> | QuestionWithGetters<'select', Parameters<typeof select>[0], A>; | ||
export type DistinctQuestion<A extends Answers = Answers> = Prettify<UnnamedDistinctQuestion<A> & { | ||
@@ -51,0 +53,0 @@ name: Extract<keyof A, string>; |
@@ -148,12 +148,20 @@ "use strict"; | ||
choices = resolvedChoices.map((choice) => { | ||
if (typeof choice === 'string' || typeof choice === 'number') { | ||
return { name: choice, value: choice }; | ||
const choiceObj = typeof choice !== 'object' || choice == null | ||
? { name: choice, value: choice } | ||
: { | ||
...choice, | ||
value: 'value' in choice | ||
? choice.value | ||
: 'name' in choice | ||
? choice.name | ||
: undefined, | ||
}; | ||
if ('value' in choiceObj && Array.isArray(defaultValue)) { | ||
// Add checked to question for backward compatibility. default was supported as alternative of per choice checked. | ||
return { | ||
checked: defaultValue.includes(choiceObj.value), | ||
...choiceObj, | ||
}; | ||
} | ||
else if (typeof choice === 'object' && | ||
choice != null && | ||
!('value' in choice) && | ||
'name' in choice) { | ||
return { ...choice, value: choice.name }; | ||
} | ||
return choice; | ||
return choiceObj; | ||
}); | ||
@@ -160,0 +168,0 @@ } |
@@ -48,3 +48,5 @@ import { checkbox, confirm, editor, expand, input, number, password, rawlist, search, select } from '@inquirer/prompts'; | ||
}>; | ||
export type UnnamedDistinctQuestion<A extends Answers = object> = QuestionWithGetters<'checkbox', Parameters<typeof checkbox>[0], A> | QuestionWithGetters<'confirm', Parameters<typeof confirm>[0], A> | QuestionWithGetters<'editor', Parameters<typeof editor>[0], A> | QuestionWithGetters<'expand', Parameters<typeof expand>[0], A> | QuestionWithGetters<'input', Parameters<typeof input>[0], A> | QuestionWithGetters<'number', Parameters<typeof number>[0], A> | QuestionWithGetters<'password', Parameters<typeof password>[0], A> | QuestionWithGetters<'rawlist', Parameters<typeof rawlist>[0], A> | QuestionWithGetters<'search', Parameters<typeof search>[0], A> | QuestionWithGetters<'list', Parameters<typeof select>[0], A> | QuestionWithGetters<'select', Parameters<typeof select>[0], A>; | ||
export type UnnamedDistinctQuestion<A extends Answers = object> = QuestionWithGetters<'checkbox', Parameters<typeof checkbox>[0] & { | ||
default: unknown[]; | ||
}, A> | QuestionWithGetters<'confirm', Parameters<typeof confirm>[0], A> | QuestionWithGetters<'editor', Parameters<typeof editor>[0], A> | QuestionWithGetters<'expand', Parameters<typeof expand>[0], A> | QuestionWithGetters<'input', Parameters<typeof input>[0], A> | QuestionWithGetters<'number', Parameters<typeof number>[0], A> | QuestionWithGetters<'password', Parameters<typeof password>[0], A> | QuestionWithGetters<'rawlist', Parameters<typeof rawlist>[0], A> | QuestionWithGetters<'search', Parameters<typeof search>[0], A> | QuestionWithGetters<'list', Parameters<typeof select>[0], A> | QuestionWithGetters<'select', Parameters<typeof select>[0], A>; | ||
export type DistinctQuestion<A extends Answers = Answers> = Prettify<UnnamedDistinctQuestion<A> & { | ||
@@ -51,0 +53,0 @@ name: Extract<keyof A, string>; |
@@ -142,12 +142,20 @@ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment */ | ||
choices = resolvedChoices.map((choice) => { | ||
if (typeof choice === 'string' || typeof choice === 'number') { | ||
return { name: choice, value: choice }; | ||
const choiceObj = typeof choice !== 'object' || choice == null | ||
? { name: choice, value: choice } | ||
: { | ||
...choice, | ||
value: 'value' in choice | ||
? choice.value | ||
: 'name' in choice | ||
? choice.name | ||
: undefined, | ||
}; | ||
if ('value' in choiceObj && Array.isArray(defaultValue)) { | ||
// Add checked to question for backward compatibility. default was supported as alternative of per choice checked. | ||
return { | ||
checked: defaultValue.includes(choiceObj.value), | ||
...choiceObj, | ||
}; | ||
} | ||
else if (typeof choice === 'object' && | ||
choice != null && | ||
!('value' in choice) && | ||
'name' in choice) { | ||
return { ...choice, value: choice.name }; | ||
} | ||
return choice; | ||
return choiceObj; | ||
}); | ||
@@ -154,0 +162,0 @@ } |
{ | ||
"name": "inquirer", | ||
"version": "12.2.0", | ||
"version": "12.3.0", | ||
"description": "A collection of common interactive command line user interfaces.", | ||
@@ -77,5 +77,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@inquirer/core": "^10.1.1", | ||
"@inquirer/prompts": "^7.2.0", | ||
"@inquirer/type": "^3.0.1", | ||
"@inquirer/core": "^10.1.2", | ||
"@inquirer/prompts": "^7.2.1", | ||
"@inquirer/type": "^3.0.2", | ||
"ansi-escapes": "^4.3.2", | ||
@@ -87,3 +87,3 @@ "mute-stream": "^2.0.0", | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "^0.17.0", | ||
"@arethetypeswrong/cli": "^0.17.2", | ||
"@repo/tsconfig": "workspace:*", | ||
@@ -108,3 +108,3 @@ "@types/mute-stream": "^0.0.4", | ||
}, | ||
"gitHead": "5713287885155c0081fca4190c17c18c598d9602" | ||
"gitHead": "7613d7474f1f17a18019b89f208f46be10c5b02f" | ||
} |
72643
1082
Updated@inquirer/core@^10.1.2
Updated@inquirer/prompts@^7.2.1
Updated@inquirer/type@^3.0.2