@inquirer/rawlist 5.3.4 → 5.3.6

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/README.md CHANGED
@@ -8,46 +8,116 @@ Simple interactive command line prompt to display a raw list of choices (single
8
8
 
9
9
  <table>
10
10
  <tr>
11
- <th>npm</th>
12
11
  <th>yarn</th>
12
+ <th>pnpm</th>
13
13
  </tr>
14
14
  <tr>
15
15
  <td>
16
16
 
17
17
  ```sh
18
- npm install @inquirer/prompts
18
+ yarn add @inquirer/prompts
19
19
  ```
20
20
 
21
21
  </td>
22
22
  <td>
23
23
 
24
24
  ```sh
25
- yarn add @inquirer/prompts
25
+ pnpm add @inquirer/prompts
26
26
  ```
27
27
 
28
28
  </td>
29
29
  </tr>
30
30
  <tr>
31
- <td colSpan="2" align="center">Or</td>
31
+ <th>bun</th>
32
+ <th>deno</th>
32
33
  </tr>
33
34
  <tr>
34
35
  <td>
35
36
 
36
37
  ```sh
37
- npm install @inquirer/rawlist
38
+ bun add @inquirer/prompts
38
39
  ```
39
40
 
40
41
  </td>
41
42
  <td>
42
43
 
44
+ ```sh
45
+ deno add npm:@inquirer/prompts
46
+ ```
47
+
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <th colSpan="2">npm</th>
52
+ </tr>
53
+ <tr>
54
+ <td colSpan="2">
55
+
56
+ ```sh
57
+ npm install @inquirer/prompts
58
+ ```
59
+
60
+ </td>
61
+ </tr>
62
+ <tr>
63
+ <td colSpan="2" align="center">Or</td>
64
+ </tr>
65
+ <tr>
66
+ <th>yarn</th>
67
+ <th>pnpm</th>
68
+ </tr>
69
+ <tr>
70
+ <td>
71
+
43
72
  ```sh
44
73
  yarn add @inquirer/rawlist
45
74
  ```
46
75
 
76
+ </td>
77
+ <td>
78
+
79
+ ```sh
80
+ pnpm add @inquirer/rawlist
81
+ ```
82
+
83
+ </td>
84
+ </tr>
85
+ <tr>
86
+ <th>bun</th>
87
+ <th>deno</th>
88
+ </tr>
89
+ <tr>
90
+ <td>
91
+
92
+ ```sh
93
+ bun add @inquirer/rawlist
94
+ ```
95
+
96
+ </td>
97
+ <td>
98
+
99
+ ```sh
100
+ deno add npm:@inquirer/rawlist
101
+ ```
102
+
103
+ </td>
104
+ </tr>
105
+ <tr>
106
+ <th colSpan="2">npm</th>
107
+ </tr>
108
+ <tr>
109
+ <td colSpan="2">
110
+
111
+ ```sh
112
+ npm install @inquirer/rawlist
113
+ ```
114
+
47
115
  </td>
48
116
  </tr>
49
117
  </table>
50
118
 
119
+ On Deno, prompts detect the terminal's unicode and color support from the environment, so run your script with `--allow-env`.
120
+
51
121
  # Usage
52
122
 
53
123
  ```js
package/dist/index.js CHANGED
@@ -37,8 +37,9 @@ function normalizeChoices(choices) {
37
37
  function getSelectedChoice(input, choices) {
38
38
  let selectedChoice;
39
39
  const selectableChoices = choices.filter(isSelectableChoice);
40
- // First, try to match by custom key (exact match)
41
- selectedChoice = selectableChoices.find((choice) => choice.key === input);
40
+ // First, try to match by custom key (exact match, then ignoring surrounding whitespace)
41
+ const trimmedInput = input.trim();
42
+ selectedChoice = selectableChoices.find((choice) => choice.key === input || choice.key === trimmedInput);
42
43
  // If no custom key match and input is numeric, try 1-based index
43
44
  if (!selectedChoice && numberRegex.test(input)) {
44
45
  const answer = Number.parseInt(input, 10) - 1;
@@ -116,13 +117,14 @@ export default createPrompt((config, done) => {
116
117
  if (status === 'done') {
117
118
  return `${prefix} ${message} ${theme.style.answer(value)}`;
118
119
  }
120
+ const [selectedChoice] = getSelectedChoice(value, choices);
119
121
  const choicesStr = choices
120
122
  .map((choice) => {
121
123
  if (Separator.isSeparator(choice)) {
122
124
  return ` ${choice.separator}`;
123
125
  }
124
126
  const line = ` ${choice.key}) ${choice.name}`;
125
- if (choice.key === value) {
127
+ if (selectedChoice && choice.key === selectedChoice.key) {
126
128
  return theme.style.highlight(line);
127
129
  }
128
130
  return line;
@@ -132,7 +134,6 @@ export default createPrompt((config, done) => {
132
134
  if (errorMsg) {
133
135
  error = theme.style.error(errorMsg);
134
136
  }
135
- const [selectedChoice] = getSelectedChoice(value, choices);
136
137
  let description = '';
137
138
  if (!errorMsg && selectedChoice?.description) {
138
139
  description = theme.style.description(selectedChoice.description);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/rawlist",
3
- "version": "5.3.4",
3
+ "version": "5.3.6",
4
4
  "description": "Inquirer rawlist prompt",
5
5
  "keywords": [
6
6
  "answer",
@@ -67,8 +67,8 @@
67
67
  "tsc": "tsc"
68
68
  },
69
69
  "dependencies": {
70
- "@inquirer/core": "^12.0.2",
71
- "@inquirer/type": "4.1.1"
70
+ "@inquirer/core": "^12.0.4",
71
+ "@inquirer/type": "4.2.0"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@repo/tsconfig": "0.0.0",
@@ -87,5 +87,5 @@
87
87
  },
88
88
  "main": "./dist/index.js",
89
89
  "types": "./dist/index.d.ts",
90
- "gitHead": "5748bd9966b5e175ddf5995ee4cdce6f60c4272e"
90
+ "gitHead": "a9436bd94d55a439df308f50e77a7cd0b2078e98"
91
91
  }