@inquirer/rawlist 2.1.18 → 2.2.0

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/cjs/index.js CHANGED
@@ -18,6 +18,7 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
18
18
  const theme = (0, core_1.makeTheme)(config.theme);
19
19
  const prefix = (0, core_1.usePrefix)({ theme });
20
20
  (0, core_1.useKeypress)((key, rl) => {
21
+ var _a, _b;
21
22
  if ((0, core_1.isEnterKey)(key)) {
22
23
  let selectedChoice;
23
24
  if (numberRegex.test(value)) {
@@ -25,11 +26,10 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
25
26
  selectedChoice = choices.filter(isSelectableChoice)[answer];
26
27
  }
27
28
  else {
28
- const answer = value.toLowerCase();
29
- selectedChoice = choices.find((choice) => isSelectableChoice(choice) && choice.key === answer);
29
+ selectedChoice = choices.find((choice) => isSelectableChoice(choice) && choice.key === value);
30
30
  }
31
31
  if (isSelectableChoice(selectedChoice)) {
32
- setValue(selectedChoice.name || String(selectedChoice.value));
32
+ setValue((_b = (_a = selectedChoice.short) !== null && _a !== void 0 ? _a : selectedChoice.name) !== null && _b !== void 0 ? _b : String(selectedChoice.value));
33
33
  setStatus('done');
34
34
  done(selectedChoice.value);
35
35
  }
@@ -3,6 +3,7 @@ import type { PartialDeep } from '@inquirer/type';
3
3
  type Choice<Value> = {
4
4
  value: Value;
5
5
  name?: string;
6
+ short?: string;
6
7
  key?: string;
7
8
  };
8
9
  declare const _default: <Value>(config: {
@@ -19,11 +19,10 @@ export default createPrompt((config, done) => {
19
19
  selectedChoice = choices.filter(isSelectableChoice)[answer];
20
20
  }
21
21
  else {
22
- const answer = value.toLowerCase();
23
- selectedChoice = choices.find((choice) => isSelectableChoice(choice) && choice.key === answer);
22
+ selectedChoice = choices.find((choice) => isSelectableChoice(choice) && choice.key === value);
24
23
  }
25
24
  if (isSelectableChoice(selectedChoice)) {
26
- setValue(selectedChoice.name || String(selectedChoice.value));
25
+ setValue(selectedChoice.short ?? selectedChoice.name ?? String(selectedChoice.value));
27
26
  setStatus('done');
28
27
  done(selectedChoice.value);
29
28
  }
@@ -3,6 +3,7 @@ import type { PartialDeep } from '@inquirer/type';
3
3
  type Choice<Value> = {
4
4
  value: Value;
5
5
  name?: string;
6
+ short?: string;
6
7
  key?: string;
7
8
  };
8
9
  declare const _default: <Value>(config: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/rawlist",
3
- "version": "2.1.18",
3
+ "version": "2.2.0",
4
4
  "description": "Inquirer rawlist prompt",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "typings": "./dist/cjs/types/index.d.ts",
@@ -86,5 +86,5 @@
86
86
  }
87
87
  },
88
88
  "sideEffects": false,
89
- "gitHead": "7a061f13e053dd64ef7373b08e8a10130131ea59"
89
+ "gitHead": "f881e68060d48fdc27424b738e84f61eecae981f"
90
90
  }