Socket
Socket
Sign inDemoInstall

@inquirer/select

Package Overview
Dependencies
Maintainers
3
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inquirer/select - npm Package Compare versions

Comparing version 2.4.7 to 2.5.0

41

dist/cjs/index.js

@@ -22,5 +22,27 @@ "use strict";

}
function normalizeChoices(choices) {
return choices.map((choice) => {
var _a, _b, _c;
if (core_1.Separator.isSeparator(choice))
return choice;
if (typeof choice === 'string') {
return {
value: choice,
name: choice,
short: choice,
disabled: false,
};
}
const name = (_a = choice.name) !== null && _a !== void 0 ? _a : String(choice.value);
return {
value: choice.value,
name,
description: choice.description,
short: (_b = choice.short) !== null && _b !== void 0 ? _b : name,
disabled: (_c = choice.disabled) !== null && _c !== void 0 ? _c : false,
};
});
}
exports.default = (0, core_1.createPrompt)((config, done) => {
var _a, _b;
const { choices: items, loop = true, pageSize = 7 } = config;
const { loop = true, pageSize = 7 } = config;
const firstRender = (0, core_1.useRef)(true);

@@ -31,2 +53,3 @@ const theme = (0, core_1.makeTheme)(selectTheme, config.theme);

const searchTimeoutRef = (0, core_1.useRef)();
const items = (0, core_1.useMemo)(() => normalizeChoices(config.choices), [config.choices]);
const bounds = (0, core_1.useMemo)(() => {

@@ -84,5 +107,3 @@ const first = items.findIndex(isSelectable);

return false;
return String(item.name || item.value)
.toLowerCase()
.startsWith(searchTerm);
return item.name.toLowerCase().startsWith(searchTerm);
});

@@ -120,10 +141,9 @@ if (matchIndex >= 0) {

}
const line = String(item.name || item.value);
if (item.disabled) {
const disabledLabel = typeof item.disabled === 'string' ? item.disabled : '(disabled)';
return theme.style.disabled(`${line} ${disabledLabel}`);
return theme.style.disabled(`${item.name} ${disabledLabel}`);
}
const color = isActive ? theme.style.highlight : (x) => x;
const cursor = isActive ? theme.icon.cursor : ` `;
return color(`${cursor} ${line}`);
return color(`${cursor} ${item.name}`);
},

@@ -134,6 +154,3 @@ pageSize,

if (status === 'done') {
const answer = (_b = (_a = selectedChoice.short) !== null && _a !== void 0 ? _a : selectedChoice.name) !== null && _b !== void 0 ? _b :
// TODO: Could we enforce that at the type level? Name should be defined for non-string values.
String(selectedChoice.value);
return `${prefix} ${message} ${theme.style.answer(answer)}`;
return `${prefix} ${message} ${theme.style.answer(selectedChoice.short)}`;
}

@@ -140,0 +157,0 @@ const choiceDescription = selectedChoice.description

@@ -23,3 +23,3 @@ import { Separator, type Theme } from '@inquirer/core';

message: string;
choices: readonly (Separator | Choice<Value>)[];
choices: readonly (string | Separator)[] | readonly (Separator | Choice<Value>)[];
pageSize?: number | undefined;

@@ -26,0 +26,0 @@ loop?: boolean | undefined;

{
"name": "@inquirer/select",
"version": "2.4.7",
"version": "2.5.0",
"description": "Inquirer select/list prompt",

@@ -57,5 +57,5 @@ "main": "./dist/cjs/index.js",

"dependencies": {
"@inquirer/core": "^9.0.10",
"@inquirer/core": "^9.1.0",
"@inquirer/figures": "^1.0.5",
"@inquirer/type": "^1.5.2",
"@inquirer/type": "^1.5.3",
"ansi-escapes": "^4.3.2",

@@ -65,3 +65,3 @@ "yoctocolors-cjs": "^2.1.2"

"devDependencies": {
"@inquirer/testing": "^2.1.31"
"@inquirer/testing": "^2.1.32"
},

@@ -93,3 +93,3 @@ "scripts": {

"sideEffects": false,
"gitHead": "273b16eeb96fab346854b9b92257c930d7ca7661"
"gitHead": "0c039599ef88fe9eb804fe083ee386ec906a856f"
}

@@ -121,2 +121,4 @@ # `@inquirer/select`

`choices` can also be an array of string, in which case the string will be used both as the `value` and the `name`.
## Theming

@@ -123,0 +125,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc