@inquirer/select 1.2.9 → 1.2.11
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
|
@@ -25,11 +25,11 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
25
25
|
return startIndex;
|
|
26
26
|
});
|
|
27
27
|
// Safe to assume the cursor position always point to a Choice.
|
|
28
|
-
const
|
|
28
|
+
const selectedChoice = choices[cursorPosition];
|
|
29
29
|
(0, core_1.useKeypress)((key) => {
|
|
30
30
|
if ((0, core_1.isEnterKey)(key)) {
|
|
31
31
|
setStatus('done');
|
|
32
|
-
done(
|
|
32
|
+
done(selectedChoice.value);
|
|
33
33
|
}
|
|
34
34
|
else if ((0, core_1.isUpKey)(key) || (0, core_1.isDownKey)(key)) {
|
|
35
35
|
let newCursorPosition = cursorPosition;
|
|
@@ -78,8 +78,10 @@ exports.default = (0, core_1.createPrompt)((config, done) => {
|
|
|
78
78
|
pageSize: config.pageSize,
|
|
79
79
|
});
|
|
80
80
|
if (status === 'done') {
|
|
81
|
-
return `${prefix} ${message} ${chalk_1.default.cyan(
|
|
81
|
+
return `${prefix} ${message} ${chalk_1.default.cyan(selectedChoice.name || selectedChoice.value)}`;
|
|
82
82
|
}
|
|
83
|
-
const choiceDescription =
|
|
83
|
+
const choiceDescription = selectedChoice.description
|
|
84
|
+
? `\n${selectedChoice.description}`
|
|
85
|
+
: ``;
|
|
84
86
|
return `${prefix} ${message}\n${windowedChoices}${choiceDescription}${ansi_escapes_1.default.cursorHide}`;
|
|
85
87
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Separator
|
|
1
|
+
import { Separator } from '@inquirer/core';
|
|
2
2
|
type Choice<Value> = {
|
|
3
3
|
value: Value;
|
|
4
4
|
name?: string;
|
|
@@ -6,7 +6,8 @@ type Choice<Value> = {
|
|
|
6
6
|
disabled?: boolean | string;
|
|
7
7
|
type?: never;
|
|
8
8
|
};
|
|
9
|
-
declare const _default: <Value extends unknown>(config:
|
|
9
|
+
declare const _default: <Value extends unknown>(config: {
|
|
10
|
+
message: string | Promise<string> | (() => Promise<string>);
|
|
10
11
|
choices: readonly (Separator | Choice<Value>)[];
|
|
11
12
|
pageSize?: number | undefined;
|
|
12
13
|
}, context?: import("@inquirer/type").Context | undefined) => import("@inquirer/type").CancelablePromise<Value>;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -18,11 +18,11 @@ export default createPrompt((config, done) => {
|
|
|
18
18
|
return startIndex;
|
|
19
19
|
});
|
|
20
20
|
// Safe to assume the cursor position always point to a Choice.
|
|
21
|
-
const
|
|
21
|
+
const selectedChoice = choices[cursorPosition];
|
|
22
22
|
useKeypress((key) => {
|
|
23
23
|
if (isEnterKey(key)) {
|
|
24
24
|
setStatus('done');
|
|
25
|
-
done(
|
|
25
|
+
done(selectedChoice.value);
|
|
26
26
|
}
|
|
27
27
|
else if (isUpKey(key) || isDownKey(key)) {
|
|
28
28
|
let newCursorPosition = cursorPosition;
|
|
@@ -71,9 +71,11 @@ export default createPrompt((config, done) => {
|
|
|
71
71
|
pageSize: config.pageSize,
|
|
72
72
|
});
|
|
73
73
|
if (status === 'done') {
|
|
74
|
-
return `${prefix} ${message} ${chalk.cyan(
|
|
74
|
+
return `${prefix} ${message} ${chalk.cyan(selectedChoice.name || selectedChoice.value)}`;
|
|
75
75
|
}
|
|
76
|
-
const choiceDescription =
|
|
76
|
+
const choiceDescription = selectedChoice.description
|
|
77
|
+
? `\n${selectedChoice.description}`
|
|
78
|
+
: ``;
|
|
77
79
|
return `${prefix} ${message}\n${windowedChoices}${choiceDescription}${ansiEscapes.cursorHide}`;
|
|
78
80
|
});
|
|
79
81
|
export { Separator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Separator
|
|
1
|
+
import { Separator } from '@inquirer/core';
|
|
2
2
|
type Choice<Value> = {
|
|
3
3
|
value: Value;
|
|
4
4
|
name?: string;
|
|
@@ -6,7 +6,8 @@ type Choice<Value> = {
|
|
|
6
6
|
disabled?: boolean | string;
|
|
7
7
|
type?: never;
|
|
8
8
|
};
|
|
9
|
-
declare const _default: <Value extends unknown>(config:
|
|
9
|
+
declare const _default: <Value extends unknown>(config: {
|
|
10
|
+
message: string | Promise<string> | (() => Promise<string>);
|
|
10
11
|
choices: readonly (Separator | Choice<Value>)[];
|
|
11
12
|
pageSize?: number | undefined;
|
|
12
13
|
}, context?: import("@inquirer/type").Context | undefined) => import("@inquirer/type").CancelablePromise<Value>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/select",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "Inquirer select/list prompt",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"typings": "./dist/cjs/types/index.d.ts",
|
|
@@ -54,20 +54,19 @@
|
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/select/README.md",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@inquirer/core": "^
|
|
58
|
-
"@inquirer/type": "^1.1.
|
|
57
|
+
"@inquirer/core": "^5.0.0",
|
|
58
|
+
"@inquirer/type": "^1.1.4",
|
|
59
59
|
"ansi-escapes": "^4.3.2",
|
|
60
60
|
"chalk": "^4.1.2",
|
|
61
61
|
"figures": "^3.2.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@inquirer/testing": "^2.1.
|
|
64
|
+
"@inquirer/testing": "^2.1.6"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
|
-
"tsc": "yarn run
|
|
68
|
-
"
|
|
69
|
-
"tsc:
|
|
70
|
-
"tsc:cjs": "tsc -p ./tsconfig.cjs.json && node ../../tools/fix-ext.mjs"
|
|
67
|
+
"tsc": "yarn run tsc:esm && yarn run tsc:cjs",
|
|
68
|
+
"tsc:esm": "rm -rf dist/esm && tsc -p ./tsconfig.json",
|
|
69
|
+
"tsc:cjs": "rm -rf dist/cjs && tsc -p ./tsconfig.cjs.json && node ../../tools/fix-ext.mjs"
|
|
71
70
|
},
|
|
72
71
|
"publishConfig": {
|
|
73
72
|
"access": "public"
|
|
@@ -87,5 +86,5 @@
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
},
|
|
90
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "c2d1c5fdfd1029f78351fb04e06f1cfb29d55bb6"
|
|
91
90
|
}
|