@inquirer/rawlist 5.4.0 → 5.4.1

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/index.d.ts CHANGED
@@ -24,7 +24,7 @@ declare const _default: <const Value>(config: {
24
24
  choices: readonly (Value | Choice<Value> | Separator)[];
25
25
  loop?: boolean;
26
26
  theme?: PartialDeep<Theme<RawlistTheme>>;
27
- default?: NoInfer<Value> | undefined;
27
+ default?: NoInfer<Value>;
28
28
  } & RawlistConfig<Value>, context?: import("@inquirer/type").Context) => Promise<Value>;
29
29
  export default _default;
30
30
  export { Separator } from '@inquirer/core';
package/dist/index.js CHANGED
@@ -25,13 +25,16 @@ function normalizeChoices(choices) {
25
25
  };
26
26
  }
27
27
  const name = choice.name ?? String(choice.value);
28
- return {
28
+ const normalizedChoice = {
29
29
  value: choice.value,
30
30
  name,
31
31
  short: choice.short ?? name,
32
32
  key: choice.key ?? String(index),
33
- description: choice.description,
34
33
  };
34
+ if (choice.description) {
35
+ normalizedChoice.description = choice.description;
36
+ }
37
+ return normalizedChoice;
35
38
  });
36
39
  }
37
40
  function getSelectedChoice(input, choices) {
@@ -54,7 +57,7 @@ export default createPrompt((config, done) => {
54
57
  const choices = useMemo(() => normalizeChoices(config.choices), [config.choices]);
55
58
  const [status, setStatus] = useState('idle');
56
59
  const [value, setValue] = useState(() => {
57
- const defaultChoice = config.default == null
60
+ const defaultChoice = config.default === undefined
58
61
  ? undefined
59
62
  : choices.find((choice) => isSelectableChoice(choice) && choice.value === config.default);
60
63
  return defaultChoice?.key ?? '';
@@ -83,10 +86,17 @@ export default createPrompt((config, done) => {
83
86
  setError('Please input a value');
84
87
  }
85
88
  else {
89
+ // The line event cleared readline's line; restore the rejected input
90
+ // so the user can fix it instead of retyping it.
91
+ rl.write(value);
86
92
  setError(`"${styleText('red', value)}" isn't an available option`);
87
93
  }
88
94
  }
89
95
  else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
96
+ // An arrow pick rewrites the displayed key while readline's line was
97
+ // cleared by the clearLine below; write the shown key back so the
98
+ // next keystroke edits it instead of replacing it.
99
+ const lineHadInput = rl.line !== '';
90
100
  rl.clearLine(0);
91
101
  const [selectedChoice, active] = getSelectedChoice(value, choices);
92
102
  if (!selectedChoice) {
@@ -94,6 +104,7 @@ export default createPrompt((config, done) => {
94
104
  ? choices.find(isSelectableChoice)
95
105
  : choices.findLast(isSelectableChoice);
96
106
  setValue(firstChoice.key);
107
+ rl.write(firstChoice.key);
97
108
  }
98
109
  else if (loop ||
99
110
  (isUpKey(key, keybindings) && active !== bounds.first) ||
@@ -106,6 +117,12 @@ export default createPrompt((config, done) => {
106
117
  nextChoice = choices[next];
107
118
  } while (!isSelectableChoice(nextChoice));
108
119
  setValue(nextChoice.key);
120
+ rl.write(nextChoice.key);
121
+ }
122
+ else if (lineHadInput) {
123
+ // Stopped at the edge: the typed input stays displayed, so restore
124
+ // the line the clearLine above emptied.
125
+ rl.write(value);
109
126
  }
110
127
  }
111
128
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/rawlist",
3
- "version": "5.4.0",
3
+ "version": "5.4.1",
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.1.0",
71
- "@inquirer/type": "4.3.0"
70
+ "@inquirer/core": "^12.1.1",
71
+ "@inquirer/type": "4.3.1"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@repo/tsconfig": "0.1.0",
@@ -83,9 +83,9 @@
83
83
  }
84
84
  },
85
85
  "engines": {
86
- "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
86
+ "node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
87
87
  },
88
88
  "main": "./dist/index.js",
89
89
  "types": "./dist/index.d.ts",
90
- "gitHead": "00ded073f80523aaeaf8a903bbfb535994990475"
90
+ "gitHead": "6570b8e4d5e33a00dad2b55fa5f5fa5d148a245b"
91
91
  }