@inquirer/rawlist 4.1.6 → 4.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/index.js +4 -4
- package/dist/esm/index.js +4 -4
- package/package.json +4 -4
package/dist/commonjs/index.js
CHANGED
|
@@ -36,13 +36,13 @@ function normalizeChoices(choices) {
|
|
|
36
36
|
function getSelectedChoice(input, choices) {
|
|
37
37
|
let selectedChoice;
|
|
38
38
|
const selectableChoices = choices.filter(isSelectableChoice);
|
|
39
|
-
|
|
39
|
+
// First, try to match by custom key (exact match)
|
|
40
|
+
selectedChoice = selectableChoices.find((choice) => choice.key === input);
|
|
41
|
+
// If no custom key match and input is numeric, try 1-based index
|
|
42
|
+
if (!selectedChoice && numberRegex.test(input)) {
|
|
40
43
|
const answer = Number.parseInt(input, 10) - 1;
|
|
41
44
|
selectedChoice = selectableChoices[answer];
|
|
42
45
|
}
|
|
43
|
-
else {
|
|
44
|
-
selectedChoice = selectableChoices.find((choice) => choice.key === input);
|
|
45
|
-
}
|
|
46
46
|
return selectedChoice
|
|
47
47
|
? [selectedChoice, choices.indexOf(selectedChoice)]
|
|
48
48
|
: [undefined, undefined];
|
package/dist/esm/index.js
CHANGED
|
@@ -30,13 +30,13 @@ function normalizeChoices(choices) {
|
|
|
30
30
|
function getSelectedChoice(input, choices) {
|
|
31
31
|
let selectedChoice;
|
|
32
32
|
const selectableChoices = choices.filter(isSelectableChoice);
|
|
33
|
-
|
|
33
|
+
// First, try to match by custom key (exact match)
|
|
34
|
+
selectedChoice = selectableChoices.find((choice) => choice.key === input);
|
|
35
|
+
// If no custom key match and input is numeric, try 1-based index
|
|
36
|
+
if (!selectedChoice && numberRegex.test(input)) {
|
|
34
37
|
const answer = Number.parseInt(input, 10) - 1;
|
|
35
38
|
selectedChoice = selectableChoices[answer];
|
|
36
39
|
}
|
|
37
|
-
else {
|
|
38
|
-
selectedChoice = selectableChoices.find((choice) => choice.key === input);
|
|
39
|
-
}
|
|
40
40
|
return selectedChoice
|
|
41
41
|
? [selectedChoice, choices.indexOf(selectedChoice)]
|
|
42
42
|
: [undefined, undefined];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/rawlist",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.8",
|
|
4
4
|
"description": "Inquirer rawlist prompt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"tsc": "tshy"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@inquirer/core": "^10.2.
|
|
77
|
+
"@inquirer/core": "^10.2.2",
|
|
78
78
|
"@inquirer/type": "^3.0.8",
|
|
79
79
|
"yoctocolors-cjs": "^2.1.2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
83
|
-
"@inquirer/testing": "^2.1.
|
|
83
|
+
"@inquirer/testing": "^2.1.50",
|
|
84
84
|
"tshy": "^3.0.2"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"optional": true
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "3fdf43342deb468ee41d698e407d8800700e08dc"
|
|
110
110
|
}
|