@inquirer/core 11.1.10 → 11.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/README.md +3 -0
- package/dist/lib/key.d.ts +1 -0
- package/dist/lib/key.js +14 -0
- package/dist/lib/make-theme.js +2 -2
- package/dist/lib/theme.d.ts +11 -0
- package/dist/lib/theme.js +8 -0
- package/dist/lib/utils.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -248,6 +248,8 @@ Listening for keypress events inside an inquirer prompt is a very common pattern
|
|
|
248
248
|
- `isDownKey()` - Note: this utility will handle vim and emacs keybindings (down, `j`, and `ctrl+n`)
|
|
249
249
|
- `isNumberKey()` one of 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
|
|
250
250
|
|
|
251
|
+
Set `INQUIRER_KEYBINDINGS=vim`, `INQUIRER_KEYBINDINGS=emacs`, or `INQUIRER_KEYBINDINGS=vim,emacs` to enable alternative navigation keybindings globally. Prompt-level `theme.keybindings` values override the environment variable.
|
|
252
|
+
|
|
251
253
|
## Theming
|
|
252
254
|
|
|
253
255
|
Theming utilities will allow you to expose customization of the prompt style. Inquirer also has a few standard theme values shared across all the official prompts.
|
|
@@ -305,6 +307,7 @@ type DefaultTheme = {
|
|
|
305
307
|
interval: number;
|
|
306
308
|
frames: string[];
|
|
307
309
|
};
|
|
310
|
+
keybindings: readonly ('emacs' | 'vim')[];
|
|
308
311
|
style: {
|
|
309
312
|
answer: (text: string) => string;
|
|
310
313
|
message: (text: string, status: 'idle' | 'done' | 'loading') => string;
|
package/dist/lib/key.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type KeypressEvent = {
|
|
|
4
4
|
shift: boolean;
|
|
5
5
|
};
|
|
6
6
|
export type Keybinding = 'emacs' | 'vim';
|
|
7
|
+
export declare function getDefaultKeybindings(): ReadonlyArray<Keybinding>;
|
|
7
8
|
export declare const isUpKey: (key: KeypressEvent, keybindings?: ReadonlyArray<Keybinding>) => boolean;
|
|
8
9
|
export declare const isDownKey: (key: KeypressEvent, keybindings?: ReadonlyArray<Keybinding>) => boolean;
|
|
9
10
|
export declare const isSpaceKey: (key: KeypressEvent) => boolean;
|
package/dist/lib/key.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
const keybindings = ['emacs', 'vim'];
|
|
2
|
+
const keybindingLookup = new Set(keybindings);
|
|
3
|
+
function isKeybinding(value) {
|
|
4
|
+
return keybindingLookup.has(value);
|
|
5
|
+
}
|
|
6
|
+
export function getDefaultKeybindings() {
|
|
7
|
+
const env = process.env['INQUIRER_KEYBINDINGS'];
|
|
8
|
+
if (!env)
|
|
9
|
+
return [];
|
|
10
|
+
return Array.from(new Set(env
|
|
11
|
+
.toLowerCase()
|
|
12
|
+
.split(/[\s,]+/)
|
|
13
|
+
.filter(isKeybinding)));
|
|
14
|
+
}
|
|
1
15
|
export const isUpKey = (key, keybindings = []) =>
|
|
2
16
|
// The up key
|
|
3
17
|
key.name === 'up' ||
|
package/dist/lib/make-theme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDefaultTheme } from "./theme.js";
|
|
2
2
|
function isPlainObject(value) {
|
|
3
3
|
if (typeof value !== 'object' || value === null)
|
|
4
4
|
return false;
|
|
@@ -25,7 +25,7 @@ function deepMerge(...objects) {
|
|
|
25
25
|
export function makeTheme(...themes) {
|
|
26
26
|
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
27
27
|
const themesToMerge = [
|
|
28
|
-
|
|
28
|
+
getDefaultTheme(),
|
|
29
29
|
...themes.filter((theme) => theme != null),
|
|
30
30
|
];
|
|
31
31
|
return deepMerge(...themesToMerge);
|
package/dist/lib/theme.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Prettify } from '@inquirer/type';
|
|
2
|
+
import { type Keybinding } from './key.ts';
|
|
2
3
|
/**
|
|
3
4
|
* Union type representing the possible statuses of a prompt.
|
|
4
5
|
*
|
|
@@ -52,6 +53,15 @@ type DefaultTheme = {
|
|
|
52
53
|
*/
|
|
53
54
|
frames: string[];
|
|
54
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Alternative keybindings enabled for prompt navigation.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue
|
|
60
|
+
* ```ts
|
|
61
|
+
* process.env['INQUIRER_KEYBINDINGS']
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
keybindings: ReadonlyArray<Keybinding>;
|
|
55
65
|
/**
|
|
56
66
|
* Object containing functions to style different parts of the prompt.
|
|
57
67
|
*/
|
|
@@ -152,4 +162,5 @@ type DefaultTheme = {
|
|
|
152
162
|
};
|
|
153
163
|
export type Theme<Extension extends object = object> = Prettify<Extension & DefaultTheme>;
|
|
154
164
|
export declare const defaultTheme: DefaultTheme;
|
|
165
|
+
export declare function getDefaultTheme(): DefaultTheme;
|
|
155
166
|
export {};
|
package/dist/lib/theme.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
2
|
import figures from '@inquirer/figures';
|
|
3
|
+
import { getDefaultKeybindings } from "./key.js";
|
|
3
4
|
export const defaultTheme = {
|
|
4
5
|
prefix: {
|
|
5
6
|
idle: styleText('blue', '?'),
|
|
@@ -9,6 +10,7 @@ export const defaultTheme = {
|
|
|
9
10
|
interval: 80,
|
|
10
11
|
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'].map((frame) => styleText('yellow', frame)),
|
|
11
12
|
},
|
|
13
|
+
keybindings: [],
|
|
12
14
|
style: {
|
|
13
15
|
answer: (text) => styleText('cyan', text),
|
|
14
16
|
message: (text) => styleText('bold', text),
|
|
@@ -19,3 +21,9 @@ export const defaultTheme = {
|
|
|
19
21
|
key: (text) => styleText('cyan', styleText('bold', `<${text}>`)),
|
|
20
22
|
},
|
|
21
23
|
};
|
|
24
|
+
export function getDefaultTheme() {
|
|
25
|
+
return {
|
|
26
|
+
...defaultTheme,
|
|
27
|
+
keybindings: getDefaultKeybindings(),
|
|
28
|
+
};
|
|
29
|
+
}
|
package/dist/lib/utils.js
CHANGED
|
@@ -11,7 +11,7 @@ import { readline } from "./hook-engine.js";
|
|
|
11
11
|
export function breakLines(content, width) {
|
|
12
12
|
return content
|
|
13
13
|
.split('\n')
|
|
14
|
-
.flatMap((line) => wrapAnsi(line, width, { trim: false,
|
|
14
|
+
.flatMap((line) => wrapAnsi(line, width, { trim: false, wordWrap: false })
|
|
15
15
|
.split('\n')
|
|
16
16
|
.map((str) => str.trimEnd()))
|
|
17
17
|
.join('\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/core",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Core Inquirer prompt API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"tsc": "tsc"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@inquirer/ansi": "^2.0.
|
|
71
|
-
"@inquirer/figures": "^2.0.
|
|
72
|
-
"@inquirer/type": "^4.0.
|
|
70
|
+
"@inquirer/ansi": "^2.0.6",
|
|
71
|
+
"@inquirer/figures": "^2.0.6",
|
|
72
|
+
"@inquirer/type": "^4.0.6",
|
|
73
73
|
"cli-width": "^4.1.0",
|
|
74
74
|
"fast-wrap-ansi": "^0.2.0",
|
|
75
|
-
"mute-stream": "^
|
|
75
|
+
"mute-stream": "^4.0.0",
|
|
76
76
|
"signal-exit": "^4.1.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
},
|
|
94
94
|
"main": "./dist/index.js",
|
|
95
95
|
"types": "./dist/index.d.ts",
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "5ca6d1101d5d3f8fb066cd5b389bccfdafbbe0c0"
|
|
97
97
|
}
|