@inquirer/expand
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Separator = void 0; | ||
const core_1 = require("@inquirer/core"); | ||
@@ -11,2 +12,5 @@ const yoctocolors_cjs_1 = __importDefault(require("yoctocolors-cjs")); | ||
return choices.map((choice) => { | ||
if (core_1.Separator.isSeparator(choice)) { | ||
return choice; | ||
} | ||
const name = 'name' in choice ? choice.name : String(choice.value); | ||
@@ -43,3 +47,3 @@ const value = 'value' in choice ? choice.value : name; | ||
else { | ||
const selectedChoice = choices.find(({ key }) => key === answer); | ||
const selectedChoice = choices.find((choice) => !core_1.Separator.isSeparator(choice) && choice.key === answer); | ||
if (selectedChoice) { | ||
@@ -67,3 +71,3 @@ setStatus('done'); | ||
// If the prompt is done, it's safe to assume there is a selected value. | ||
const selectedChoice = choices.find(({ key }) => key === value); | ||
const selectedChoice = choices.find((choice) => !core_1.Separator.isSeparator(choice) && choice.key === value.toLowerCase()); | ||
return `${prefix} ${message} ${theme.style.answer(selectedChoice.name)}`; | ||
@@ -76,2 +80,4 @@ } | ||
.map((choice) => { | ||
if (core_1.Separator.isSeparator(choice)) | ||
return ''; | ||
if (choice.key === defaultKey) { | ||
@@ -89,2 +95,5 @@ return choice.key.toUpperCase(); | ||
.map((choice) => { | ||
if (core_1.Separator.isSeparator(choice)) { | ||
return ` ${choice.separator}`; | ||
} | ||
const line = ` ${choice.key}) ${choice.name}`; | ||
@@ -99,3 +108,3 @@ if (choice.key === value.toLowerCase()) { | ||
let helpTip = ''; | ||
const currentOption = allChoices.find(({ key }) => key === value.toLowerCase()); | ||
const currentOption = choices.find((choice) => !core_1.Separator.isSeparator(choice) && choice.key === value.toLowerCase()); | ||
if (currentOption) { | ||
@@ -113,1 +122,3 @@ helpTip = `${yoctocolors_cjs_1.default.cyan('>>')} ${currentOption.name}`; | ||
}); | ||
var core_2 = require("@inquirer/core"); | ||
Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return core_2.Separator; } }); |
@@ -1,2 +0,2 @@ | ||
import { type Theme } from '@inquirer/core'; | ||
import { Separator, type Theme } from '@inquirer/core'; | ||
import type { PartialDeep } from '@inquirer/type'; | ||
@@ -17,3 +17,3 @@ type Key = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'; | ||
name: string; | ||
}[] | readonly Choice<Value>[]; | ||
}[] | readonly (Separator | Choice<Value>)[]; | ||
default?: (Key | "h") | undefined; | ||
@@ -24,1 +24,2 @@ expanded?: boolean | undefined; | ||
export default _default; | ||
export { Separator } from '@inquirer/core'; |
{ | ||
"name": "@inquirer/expand", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Inquirer checkbox prompt", | ||
@@ -89,3 +89,3 @@ "main": "./dist/cjs/index.js", | ||
"sideEffects": false, | ||
"gitHead": "0c039599ef88fe9eb804fe083ee386ec906a856f" | ||
"gitHead": "4937ea3a74152b59bf4198dbaa803119ed4ef8e2" | ||
} |
@@ -97,2 +97,4 @@ # `@inquirer/expand` | ||
`Separator` objects can be used in the `choices` array to render non-selectable lines in the choice list. By default it'll render a line, but you can provide the text as argument (`new Separator('-- Dependencies --')`). This option is often used to add labels to groups within long list of options. | ||
### `Choice` object | ||
@@ -99,0 +101,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17643
269
142