@inquirer/rawlist 5.2.8 → 5.3.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/README.md CHANGED
@@ -101,6 +101,12 @@ Here's each property:
101
101
 
102
102
  `choices` can also be an array of string, in which case the string will be used both as the `value` and the `name`.
103
103
 
104
+ ## Keybindings
105
+
106
+ Set `INQUIRER_KEYBINDINGS=vim`, `INQUIRER_KEYBINDINGS=emacs`, or `INQUIRER_KEYBINDINGS=vim,emacs` to enable alternative navigation keybindings globally.
107
+
108
+ You can override the environment setting per prompt with `theme.keybindings`.
109
+
104
110
  ## Theming
105
111
 
106
112
  You can theme a prompt by passing a `theme` object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.
@@ -119,6 +125,7 @@ type Theme = {
119
125
  highlight: (text: string) => string;
120
126
  description: (text: string) => string;
121
127
  };
128
+ keybindings: readonly ('emacs' | 'vim')[];
122
129
  };
123
130
  ```
124
131
 
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ type Choice<Value> = {
12
12
  key?: string;
13
13
  description?: string;
14
14
  };
15
- declare const _default: <Value>(config: {
15
+ declare const _default: <const Value>(config: {
16
16
  message: string;
17
17
  choices: readonly (Separator | Value | Choice<Value>)[];
18
18
  loop?: boolean | undefined;
package/dist/index.js CHANGED
@@ -60,6 +60,7 @@ export default createPrompt((config, done) => {
60
60
  });
61
61
  const [errorMsg, setError] = useState();
62
62
  const theme = makeTheme(rawlistTheme, config.theme);
63
+ const { keybindings } = theme;
63
64
  const prefix = usePrefix({ status, theme });
64
65
  const bounds = useMemo(() => {
65
66
  const first = choices.findIndex(isSelectableChoice);
@@ -84,19 +85,19 @@ export default createPrompt((config, done) => {
84
85
  setError(`"${styleText('red', value)}" isn't an available option`);
85
86
  }
86
87
  }
87
- else if (isUpKey(key) || isDownKey(key)) {
88
+ else if (isUpKey(key, keybindings) || isDownKey(key, keybindings)) {
88
89
  rl.clearLine(0);
89
90
  const [selectedChoice, active] = getSelectedChoice(value, choices);
90
91
  if (!selectedChoice) {
91
- const firstChoice = isDownKey(key)
92
+ const firstChoice = isDownKey(key, keybindings)
92
93
  ? choices.find(isSelectableChoice)
93
94
  : choices.findLast(isSelectableChoice);
94
95
  setValue(firstChoice.key);
95
96
  }
96
97
  else if (loop ||
97
- (isUpKey(key) && active !== bounds.first) ||
98
- (isDownKey(key) && active !== bounds.last)) {
99
- const offset = isUpKey(key) ? -1 : 1;
98
+ (isUpKey(key, keybindings) && active !== bounds.first) ||
99
+ (isDownKey(key, keybindings) && active !== bounds.last)) {
100
+ const offset = isUpKey(key, keybindings) ? -1 : 1;
100
101
  let next = active;
101
102
  let nextChoice;
102
103
  do {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquirer/rawlist",
3
- "version": "5.2.8",
3
+ "version": "5.3.0",
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": "^11.1.9",
71
- "@inquirer/type": "^4.0.5"
70
+ "@inquirer/core": "^11.2.0",
71
+ "@inquirer/type": "^4.0.6"
72
72
  },
73
73
  "devDependencies": {
74
74
  "typescript": "^6.0.2"
@@ -86,5 +86,5 @@
86
86
  },
87
87
  "main": "./dist/index.js",
88
88
  "types": "./dist/index.d.ts",
89
- "gitHead": "35bda2afd31b4acca8f800259b9f7ca4e95a1d9d"
89
+ "gitHead": "5ca6d1101d5d3f8fb066cd5b389bccfdafbbe0c0"
90
90
  }